diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2016-06-27 23:16:17 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2016-06-27 23:16:17 +0300 |
commit | 3d7130be96c3bf8a84cd6092b1a26e055707d630 (patch) | |
tree | 97ee34bf667ee3e63e5ac554d7c7dcdb64cc1a1a /main/src | |
parent | c7606a74ffebf93da4967b053f154a37cf8a5ca7 (diff) | |
parent | 8c955ef9100378f8d2a5d7a83031c93aa43dec35 (diff) |
Merge remote-tracking branch 'origin/master' into run-configurations
Diffstat (limited to 'main/src')
669 files changed, 24416 insertions, 39649 deletions
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj index 243f52e79b..f44e80eb3a 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet.csproj +++ b/main/src/addins/AspNet/MonoDevelop.AspNet.csproj @@ -604,11 +604,4 @@ <Folder Include="Templates\images\" /> <Folder Include="WebForms\CSharp\" /> </ItemGroup> - <Target Name="BeforeBuild"> - <PropertyGroup> - <NuGet>$(SolutionDir)\external\nuget-binary\NuGet.exe</NuGet> - <NuGet Condition="$(OS)=='Unix'">mono $(NuGet)</NuGet> - </PropertyGroup> - <Exec Condition="Exists('$(SolutionDir)\..\.git')" Command="$(NuGet) restore -SolutionDirectory $(SolutionDir)" /> - </Target> </Project> diff --git a/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml b/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml index 90c042f2e2..0744e08040 100644 --- a/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml +++ b/main/src/addins/AspNet/Properties/MonoDevelop.AspNet.addin.xml @@ -226,26 +226,26 @@ type="array" />
<Command id = "MonoDevelop.AspNet.Commands.AspNetCommands.AddController"
_label = "Controller..."
+ _displayName = "Add Controller..."
_description = "Add an ASP.NET MVC controller" />
<Command id = "MonoDevelop.AspNet.Commands.AspNetCommands.AddView"
_label = "View..."
+ _displayName = "Add View..."
_description = "Add an ASP.NET MVC view" />
- </Category>
- </Extension>
-
- <Extension path = "/MonoDevelop/Ide/Commands/TextEditor">
<Command id = "MonoDevelop.AspNet.Commands.AspNetCommands.GoToView"
- _label = "Go To View"
+ _label = "Go to View"
defaultHandler = "MonoDevelop.AspNet.Commands.GoToViewCommandHandler"
description = "Go to the corresponding view file" />
<Command id = "MonoDevelop.AspNet.Commands.AspNetCommands.AddViewFromController"
_label = "Add View..."
+ _displayName = "Add View from Controller..."
defaultHandler = "MonoDevelop.AspNet.Commands.AddViewFromControllerCommandHandler"
description = "Add an ASP.NET MVC view" />
<Command id = "MonoDevelop.AspNet.Commands.AspNetCommands.GoToController"
- _label = "Go To Controller"
+ _label = "Go to Controller"
defaultHandler = "MonoDevelop.AspNet.Commands.GoToControllerCommandHandler"
description = "Go to the corresponding controller file" />
+ </Category>
</Extension>
<Extension path = "/MonoDevelop/Ide/ContextMenu/ProjectPad/Add">
diff --git a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml index 05b702f6a0..6c330c937f 100644 --- a/main/src/addins/CSharpBinding/CSharpBinding.addin.xml +++ b/main/src/addins/CSharpBinding/CSharpBinding.addin.xml @@ -8,28 +8,41 @@ <!-- Extensions --> <Extension path = "/MonoDevelop/Ide/Commands"> + <Category _name = "Edit" id="Edit"> + <Command id = "MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" - _label = "S_how Code Generation Window" + _label = "Show Code _Generation" shortcut = "Alt|Insert" macShortcut = "Meta|I" /> + </Category> + + <Category _name = "Code Navigation" id = "CodeNavigation"> + <Command id = "MonoDevelop.CSharp.Refactoring.FindProjectReferenceUsages" defaultHandler = "MonoDevelop.CSharp.Refactoring.FindProjectReferenceUsagesHandler" - _label = "_Find reference usages"/> + _label = "_Find Reference Usages" + macShortcut = "Meta+F12" /> <Command id = "MonoDevelop.CSharp.Navigation.FindExtensionMethods" defaultHandler = "MonoDevelop.CSharp.Navigation.FindExtensionMethodsHandler" - _label = "Extension Methods"/> + _label = "Extension Methods" + _displayName = "Find Extension Methods"/> <Command id = "MonoDevelop.Refactoring.Navigation.FindBaseSymbols" defaultHandler = "MonoDevelop.CSharp.Navigation.FindBaseSymbolsHandler" - _label = "Base Symbols"/> + _label = "Base Symbols" + _displayName = "Find Base Symbols"/> <Command id = "MonoDevelop.Refactoring.Navigation.FindDerivedSymbols" defaultHandler = "MonoDevelop.CSharp.Refactoring.FindDerivedSymbolsHandler" - _label = "Derived Symbols"/> + _label = "Derived Symbols" + _displayName = "Find Derived Symbols"/> <Command id = "MonoDevelop.CSharp.Navigation.FindMemberOverloads" defaultHandler = "MonoDevelop.CSharp.Navigation.FindMemberOverloadsHandler" - _label = "Member Overloads"/> + _label = "Member Overloads" + _displayName = "Find Member Overloads"/> <Command id = "MonoDevelop.CSharp.Navigation.FindImplementingMembers" defaultHandler = "MonoDevelop.CSharp.Navigation.FindImplementingMembersHandler" - _label = "Implementing Members"/> + _label = "Implementing Members" + _displayName = "Find Implementing Members"/> + </Category> </Extension> <Extension path = "/MonoDevelop/Ide/Commands/Refactoring"> @@ -56,7 +69,8 @@ /> <Command id = "MonoDevelop.CSharp.Refactoring.SortAndRemoveImportsCommand" defaultHandler = "MonoDevelop.CSharp.Refactoring.SortAndRemoveImportsCommandHandler" - _label = "R_emove and Sort" + _label = "R_emove and Sort" + _displayName = "Remove Unused and Sort (Usings)" /> </Extension> @@ -64,7 +78,7 @@ <Command id = "MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration" _label = "_Go to Declaration" shortcut = "F12" - macShortcut = "Meta|D"/> + macShortcut = "Meta|D F12"/> </Extension> @@ -246,12 +260,12 @@ <Command id = "MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.PrevUsage" defaultHandler = "MonoDevelop.CSharp.Highlighting.MoveToPrevUsageHandler" shortcut = "Ctrl|Shift|Up" - macShortcut = "Meta|Shift|Up" + macShortcut = "Control+Alt+Meta+Up" _label = "_Move to prev usage"/> <Command id = "MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.NextUsage" defaultHandler = "MonoDevelop.CSharp.Highlighting.MoveToNextUsageHandler" shortcut = "Ctrl|Shift|Down" - macShortcut = "Meta|Shift|Down" + macShortcut = "Control+Alt+Meta+Down" _label = "_Move to next usage"/> </Extension> @@ -291,6 +305,7 @@ <Extension path = "/MonoDevelop/SourceEditor2/ContextMenu/Editor"> <Condition id="FileType" mimeTypes="text/x-csharp"> + <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.QuickFix" insertafter="MonoDevelop.SourceEditor.SourceEditorCommands.MarkerOperations" insertbefore="MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator"/> <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.CurrentRefactoryOperations" insertafter="MonoDevelop.SourceEditor.SourceEditorCommands.MarkerOperations" insertbefore="MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator"/> <ItemSet id = "Navigate" _label = "Navigate"> @@ -305,12 +320,12 @@ <CommandItem id = "MonoDevelop.CSharp.Navigation.FindImplementingMembers"/> </ItemSet> - + <!-- <ItemSet id = "Organize Imports" _label = "Organize Usings" insertafter="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow"> <CommandItem id = "MonoDevelop.CSharp.Refactoring.RemoveUnusedImportsCommand"/> <CommandItem id = "MonoDevelop.CSharp.Refactoring.OrganizeImportsCommand"/> <CommandItem id = "MonoDevelop.CSharp.Refactoring.SortAndRemoveImportsCommand"/> - </ItemSet> + </ItemSet> --> </Condition> </Extension> diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs index 4b5db22b20..dc254ce2a5 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.ClassOutline/CSharpOutlineTextEditorExtension.cs @@ -228,8 +228,12 @@ namespace MonoDevelop.CSharp.ClassOutline Editor.CaretOffset = ((SyntaxTrivia)o).SpanStart; } - if (focusEditor) - Editor.GrabFocus (); + if (focusEditor) { + GLib.Timeout.Add (10, delegate { + Editor.GrabFocus (); + return false; + }); + } } static void OutlineTreeIconFunc (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs index 97af87855c..29779dcb78 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.CodeFixes/MoveTypeToFile/MoveTypeToFile.cs @@ -43,6 +43,7 @@ using MonoDevelop.Ide; using System.Collections.Generic; using MonoDevelop.Ide.StandardHeader; using ICSharpCode.NRefactory6.CSharp; +using Microsoft.CodeAnalysis.Text; namespace MonoDevelop.CSharp.CodeFixes.MoveTypeToFile { @@ -85,6 +86,8 @@ namespace MonoDevelop.CSharp.CodeFixes.MoveTypeToFile readonly BaseTypeDeclarationSyntax type; readonly SyntaxNode root; + bool generatePreview; + public MyCodeAction (Document document, string title, SyntaxNode root, BaseTypeDeclarationSyntax type) { this.root = root; @@ -101,8 +104,30 @@ namespace MonoDevelop.CSharp.CodeFixes.MoveTypeToFile } } - protected override Task<Document> GetChangedDocumentAsync (System.Threading.CancellationToken cancellationToken) + protected override Task<IEnumerable<CodeActionOperation>> ComputePreviewOperationsAsync (System.Threading.CancellationToken cancellationToken) + { + generatePreview = true; + var result = base.ComputePreviewOperationsAsync (cancellationToken); + generatePreview = false; + return result; + } + + protected override async Task<Document> GetChangedDocumentAsync (System.Threading.CancellationToken cancellationToken) { + if (generatePreview) { + var removeType = + root.DescendantNodesAndSelf (n => !(n is BaseTypeDeclarationSyntax)) + .OfType<BaseTypeDeclarationSyntax> () + .FirstOrDefault (t => t.SpanStart == type.SpanStart); + if (removeType == null) + return document; + + var st = await document.GetTextAsync ().ConfigureAwait (false); + var bounds = CalcTypeBounds (removeType); + + return document.WithText (st.WithChanges (new TextChange (new TextSpan (bounds.Offset, bounds.Length), ""))); + } + var correctFileName = GetCorrectFileName (document, type); if (IsSingleType (root)) { FileService.RenameFile (document.FilePath, correctFileName); @@ -110,9 +135,9 @@ namespace MonoDevelop.CSharp.CodeFixes.MoveTypeToFile if (doc.HasProject) { IdeApp.ProjectOperations.SaveAsync (doc.Project); } - return Task.FromResult (document); + return document; } - return Task.FromResult (CreateNewFile (type, correctFileName)); + return CreateNewFile (type, correctFileName); } Document CreateNewFile (BaseTypeDeclarationSyntax type, string correctFileName) diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs index ee31b80827..916754249b 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs @@ -729,7 +729,7 @@ namespace MonoDevelop.CSharp.Completion public async Task<MonoDevelop.Ide.CodeCompletion.ParameterHintingResult> InternalHandleParameterCompletionCommand (CodeCompletionContext completionContext, char completionChar, bool force, CancellationToken token = default(CancellationToken)) { var data = Editor; - if (!force && completionChar != '(' && completionChar != ',') + if (!force && completionChar != '(' && completionChar != '<' && completionChar != '[' && completionChar != ',') return null; if (Editor.EditMode != EditMode.Edit) return null; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs index b7527851e8..6bde826106 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/RoslynSymbolCompletionData.cs @@ -295,9 +295,8 @@ namespace MonoDevelop.CSharp.Completion } window.CompletionWidget.SetCompletionText (window.CodeCompletionContext, partialWord, insertionText); int offset = Editor.CaretOffset; - for (int i = skipChars - 1; i --> 0;) { - Editor.StartSession (new SkipCharSession (Editor.GetCharAt (offset))); - offset++; + for (int i = skipChars; i --> 0;) { + Editor.StartSession (new SkipCharSession (Editor.GetCharAt (offset + i))); } if (runParameterCompletionCommand && IdeApp.Workbench != null) { diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CompletionContextHandler.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CompletionContextHandler.cs index b12afc3665..6eeae9769a 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CompletionContextHandler.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/Completion/ContextHandler/CompletionContextHandler.cs @@ -101,7 +101,7 @@ namespace ICSharpCode.NRefactory6.CSharp.Completion internal protected static bool IsTriggerAfterSpaceOrStartOfWordCharacter(SourceText text, int characterPosition) { var ch = text[characterPosition]; - if (ch == ' ') { + if (ch == ' ' && characterPosition > 0) { ch = text[characterPosition - 1]; return !char.IsWhiteSpace (ch); } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs index 7e03af8a31..97301f397b 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Features/GenerateType/CSharpGenerateTypeService.cs @@ -65,6 +65,8 @@ namespace ICSharpCode.NRefactory6.CSharp.GenerateType var typeArgumentList = (TypeArgumentListSyntax)expression.Parent; var symbolInfo = semanticModel.GetSymbolInfo(typeArgumentList.Parent, cancellationToken); var symbol = symbolInfo.GetAnySymbol(); + if (symbol == null) + return false; if (symbol.IsConstructor()) { symbol = symbol.ContainingType; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs index 049c9906fd..f9be902386 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/OnTheFlyFormatter.cs @@ -98,7 +98,6 @@ namespace MonoDevelop.CSharp.Formatting var textPolicy = policyParent.Get<TextStylePolicy> (mimeTypeChain); optionSet = policy.CreateOptions (textPolicy); } - var doc = Formatter.FormatAsync (analysisDocument, span, optionSet).Result; var newTree = doc.GetSyntaxTreeAsync ().Result; var caretOffset = editor.CaretOffset; @@ -107,6 +106,8 @@ namespace MonoDevelop.CSharp.Formatting foreach (var change in newTree.GetChanges (syntaxTree)) { if (!exact && change.Span.Start + delta >= caretOffset) continue; + if (exact && !span.Contains (change.Span.Start)) + continue; var newText = change.NewText; editor.ReplaceText (delta + change.Span.Start, change.Span.Length, newText); delta = delta - change.Span.Length + newText.Length; diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs index f212a37b76..64ad7f28dd 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/RefactoryCommands.cs @@ -206,13 +206,13 @@ namespace MonoDevelop.CSharp.Refactoring var ext = doc.GetContent<CodeActionEditorExtension> (); - if (ext != null) { - var fixMenu = CreateFixMenu (doc.Editor, doc, semanticModel, ext.GetCurrentFixes ()); - if (fixMenu.CommandInfos.Count > 0) { - ainfo.Add (fixMenu, null); - added = true; - } - } + //if (ext != null) { + // var fixMenu = CreateFixMenu (doc.Editor, doc, semanticModel, ext.GetCurrentFixes ()); + // if (fixMenu.CommandInfos.Count > 0) { + // ainfo.Add (fixMenu, null); + // added = true; + // } + //} var ciset = new CommandInfoSet (); ciset.Text = GettextCatalog.GetString ("Refactor"); @@ -224,16 +224,16 @@ namespace MonoDevelop.CSharp.Refactoring added = true; } bool first = true; - if (ext != null) { - foreach (var fix in ext.GetCurrentFixes ().CodeRefactoringActions) { - if (added & first && ciset.CommandInfos.Count > 0) - ciset.CommandInfos.AddSeparator (); - var info2 = new CommandInfo (fix.CodeAction.Title); - ciset.CommandInfos.Add (info2, new Action (async () => await new CodeActionEditorExtension.ContextActionRunner (fix.CodeAction, doc.Editor, doc).Run ())); - added = true; - first = false; - } - } + //if (ext != null) { + // foreach (var fix in ext.GetCurrentFixes ().CodeRefactoringActions) { + // if (added & first && ciset.CommandInfos.Count > 0) + // ciset.CommandInfos.AddSeparator (); + // var info2 = new CommandInfo (fix.CodeAction.Title); + // ciset.CommandInfos.Add (info2, new Action (async () => await new CodeActionEditorExtension.ContextActionRunner (fix.CodeAction, doc.Editor, doc).Run ())); + // added = true; + // first = false; + // } + //} if (ciset.CommandInfos.Count > 0) { ainfo.Add (ciset, null); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.UnitTests/UnitTestTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.UnitTests/UnitTestTextEditorExtension.cs index ff091978dd..d96421d11e 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.UnitTests/UnitTestTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.UnitTests/UnitTestTextEditorExtension.cs @@ -148,7 +148,7 @@ namespace MonoDevelop.CSharp IUnitTestMarkers markers = null; foreach (var attr in method.GetAttributes ()) { var cname = attr.AttributeClass.GetFullName (); - markers = unitTestMarkers.FirstOrDefault (m => m.TestMethodAttributeMarker == cname); + markers = unitTestMarkers.FirstOrDefault (m => (m.TestMethodAttributeMarker == cname || m.TestCaseMethodAttributeMarker == cname)); if (markers != null) { if (test == null) { TagClass (parentClass, markers); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstAmbience.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstAmbience.cs index fe36dd3134..57bec0eab8 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstAmbience.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/AstAmbience.cs @@ -101,7 +101,11 @@ namespace MonoDevelop.CSharp } else { first = false; } - AppendEscaped (sb, param.ToString ()); + foreach (var mod in param.Modifiers) + sb.Append (mod + " "); + AppendEscaped (sb, StripTrivia(param.Type.ToString ())); + sb.Append (" "); + AppendEscaped (sb, param.Identifier.ToString ()); } } @@ -110,7 +114,18 @@ namespace MonoDevelop.CSharp // sb.Append (" "); sb.Append (")"); } - + + string StripTrivia (string str) + { + var result = new StringBuilder (); + foreach (char ch in str) { + if (char.IsWhiteSpace (ch)) + continue; + result.Append (ch); + } + return result.ToString (); + } + static void AppendEscaped (StringBuilder result, string text) { if (text == null) diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs index a89341c298..98ab40056f 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/SignatureMarkupCreator.cs @@ -77,9 +77,14 @@ namespace MonoDevelop.CSharp public SignatureMarkupCreator (DocumentContext ctx, int offset) { this.offset = offset; - this.colorStyle = SyntaxModeService.GetColorStyle (Ide.IdeApp.Preferences.ColorScheme); - if (!this.colorStyle.FitsIdeTheme (Ide.IdeApp.Preferences.UserInterfaceTheme)) - this.colorStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceTheme); + try { + this.colorStyle = SyntaxModeService.GetColorStyle (Ide.IdeApp.Preferences.ColorScheme); + if (!this.colorStyle.FitsIdeTheme (Ide.IdeApp.Preferences.UserInterfaceTheme)) + this.colorStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceTheme); + } catch (Exception e) { + LoggingService.LogError ("Error while getting the color style : " + Ide.IdeApp.Preferences.ColorScheme + " in ide theme : " + Ide.IdeApp.Preferences.UserInterfaceTheme, e); + this.colorStyle = SyntaxModeService.DefaultColorStyle; + } this.ctx = ctx; if (ctx != null) { this.options = ctx.GetOptionSet (); diff --git a/main/src/addins/MacPlatform/MacIntegrationCommands.cs b/main/src/addins/MacPlatform/MacIntegrationCommands.cs index 046fd91843..74f42bb874 100644 --- a/main/src/addins/MacPlatform/MacIntegrationCommands.cs +++ b/main/src/addins/MacPlatform/MacIntegrationCommands.cs @@ -26,6 +26,7 @@ using MonoDevelop.Ide; using MonoDevelop.Components.Commands; +using MonoDevelop.MacInterop; using AppKit; using System.Linq; @@ -94,4 +95,13 @@ namespace MonoDevelop.MacIntegration info.Enabled = NSWorkspace.SharedWorkspace.RunningApplications.Any (a => a.Hidden); } } + + class MacZoomWindowHandler : CommandHandler + { + protected override void Run () + { + NSWindow w = GtkQuartz.GetWindow (IdeApp.Workbench.RootWindow); + w.PerformZoom (w); + } + } } diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenu.cs b/main/src/addins/MacPlatform/MacMenu/MDMenu.cs index 2b9f8baa6b..7fd72c222d 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDMenu.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDMenu.cs @@ -52,6 +52,8 @@ namespace MonoDevelop.MacIntegration.MacMenu foreach (CommandEntry ce in ces) { if (ce.CommandId == Command.Separator) { AddItem (NSMenuItem.SeparatorItem); + if (!string.IsNullOrEmpty (ce.OverrideLabel)) + AddItem (new MDMenuHeaderItem (ce.OverrideLabel)); continue; } diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenuHeaderItem.cs b/main/src/addins/MacPlatform/MacMenu/MDMenuHeaderItem.cs new file mode 100644 index 0000000000..0fc249912d --- /dev/null +++ b/main/src/addins/MacPlatform/MacMenu/MDMenuHeaderItem.cs @@ -0,0 +1,45 @@ +// +// MDMenuHeaderItem.cs +// +// Author: +// Vsevolod Kukol <sevoku@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. +// +// 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 AppKit; + +namespace MonoDevelop.MacIntegration.MacMenu +{ + class MDMenuHeaderItem : NSMenuItem, IUpdatableMenuItem + { + public MDMenuHeaderItem (string text) + { + Title = text; + Enabled = false; + Hidden = false; + } + + public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) + { + MDMenu.ShowLastSeparator (ref lastSeparator); + } + } +} + diff --git a/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs b/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs index caa93f33ee..b124657f22 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDMenuItem.cs @@ -32,6 +32,8 @@ using System.Text; using Foundation; using ObjCRuntime; using System.Collections.Generic; +using MonoDevelop.Components; +using MonoDevelop.Ide.Navigation; namespace MonoDevelop.MacIntegration.MacMenu { @@ -91,7 +93,7 @@ namespace MonoDevelop.MacIntegration.MacMenu var info = manager.GetCommandInfo (ce.CommandId, new CommandTargetRoute (initialCommandTarget)); if (!isArrayItem) { - SetItemValues (this, info, ce.DisabledVisible); + SetItemValues (this, info, ce.DisabledVisible, ce.OverrideLabel); if (!Hidden) MDMenu.ShowLastSeparator (ref lastSeparator); return; @@ -128,6 +130,7 @@ namespace MonoDevelop.MacIntegration.MacMenu parent.InsertItem (n, index); else parent.AddItem (n); + index++; continue; } @@ -161,11 +164,9 @@ namespace MonoDevelop.MacIntegration.MacMenu public CommandInfo Info; } - void SetItemValues (NSMenuItem item, CommandInfo info, bool disabledVisible) + void SetItemValues (NSMenuItem item, CommandInfo info, bool disabledVisible, string overrideLabel = null) { - item.SetTitleWithMnemonic (GetCleanCommandText (info)); - if (!string.IsNullOrEmpty (info.Description) && item.ToolTip != info.Description) - item.ToolTip = info.Description; + item.SetTitleWithMnemonic (GetCleanCommandText (info, overrideLabel)); bool enabled = info.Enabled && (!IsGloballyDisabled || commandSource == CommandSource.ContextMenu); bool visible = info.Visible && (disabledVisible || info.Enabled); @@ -173,6 +174,47 @@ namespace MonoDevelop.MacIntegration.MacMenu item.Enabled = enabled; item.Hidden = !visible; + string fileName = null; + var doc = info.DataItem as Ide.Gui.Document; + if (doc != null) { + if (doc.IsFile) + fileName = doc.FileName; + else { + // Designer documents have no file bound to them, but the document name + // could be a valid path + var docName = doc.Name; + if (!string.IsNullOrEmpty (docName) && System.IO.Path.IsPathRooted (docName) && System.IO.File.Exists (docName)) + fileName = docName; + } + } else if (info.DataItem is NavigationHistoryItem) { + var navDoc = ((NavigationHistoryItem)info.DataItem).NavigationPoint as DocumentNavigationPoint; + if (navDoc != null) + fileName = navDoc.FileName; + } else { + var str = info.DataItem as string; + if (str != null && System.IO.Path.IsPathRooted (str) && System.IO.File.Exists (str)) + fileName = str; + } + + if (!String.IsNullOrWhiteSpace (fileName)) { + item.ToolTip = fileName; + Xwt.Drawing.Image icon = null; + if (!info.Icon.IsNull) + icon = Ide.ImageService.GetIcon (info.Icon, Gtk.IconSize.Menu); + if (icon == null) + icon = Ide.DesktopService.GetIconForFile (fileName, Gtk.IconSize.Menu); + if (icon != null) { + var scale = GtkWorkarounds.GetScaleFactor (Ide.IdeApp.Workbench.RootWindow); + + if (NSUserDefaults.StandardUserDefaults.StringForKey ("AppleInterfaceStyle") == "Dark") + icon = icon.WithStyles ("dark"); + else + icon = icon.WithStyles ("-dark"); + item.Image = icon.ToBitmap (scale).ToNSImage (); + item.Image.Template = true; + } + } + SetAccel (item, info.AccelKey); if (info.Checked) { @@ -236,6 +278,10 @@ namespace MonoDevelop.MacIntegration.MacMenu static string GetKeyEquivalent (Gdk.Key key) { + // Gdk.Keyval.ToUnicode returns NULL for TAB, fix it + if (key == Gdk.Key.Tab) + return "\t"; + char c = (char) Gdk.Keyval.ToUnicode ((uint) key); if (c != 0) return c.ToString (); @@ -244,13 +290,13 @@ namespace MonoDevelop.MacIntegration.MacMenu if (fk != 0) return ((char) fk).ToString (); - LoggingService.LogError ("Mac menu cannot display key '{0}", key); + LoggingService.LogError ("Mac menu cannot display key '{0}'", key); return ""; } - static string GetCleanCommandText (CommandInfo ci) + static string GetCleanCommandText (CommandInfo ci, string overrideLabel = null) { - string txt = ci.Text; + string txt = overrideLabel ?? ci.Text; if (txt == null) return ""; diff --git a/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs b/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs index d733881d2c..da6d084334 100644 --- a/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs +++ b/main/src/addins/MacPlatform/MacMenu/MDSubMenuItem.cs @@ -44,10 +44,11 @@ namespace MonoDevelop.MacIntegration.MacMenu public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { - if (ces.AutoHide) { - ((MDMenu)Submenu).UpdateCommands (); + ((MDMenu)Submenu).UpdateCommands (); + if (ces.AutoHide) Hidden = Submenu.ItemArray ().All (item => item.Hidden); - } + else + Enabled = Submenu.ItemArray ().Any (item => !item.Hidden); if (!Hidden) { MDMenu.ShowLastSeparator (ref lastSeparator); } diff --git a/main/src/addins/MacPlatform/MacPlatform.addin.xml b/main/src/addins/MacPlatform/MacPlatform.addin.xml index 75534803db..72a1fc3287 100644 --- a/main/src/addins/MacPlatform/MacPlatform.addin.xml +++ b/main/src/addins/MacPlatform/MacPlatform.addin.xml @@ -17,8 +17,12 @@ <Command id = "MonoDevelop.MacIntegration.MacIntegrationCommands.MinimizeWindow" defaultHandler = "MonoDevelop.MacIntegration.MacMinimizeWindowHandler" _label = "_Minimize" - _description = "Minimize the window" + _description = "Minimize the Window" macShortcut = "Meta|M" /> + <Command id = "MonoDevelop.MacIntegration.MacIntegrationCommands.ZoomWindow" + defaultHandler = "MonoDevelop.MacIntegration.MacZoomWindowHandler" + _label = "_Zoom" + _description = "Zoom the Window"/> <Command id = "MonoDevelop.MacIntegration.MacIntegrationCommands.HideWindow" defaultHandler = "MonoDevelop.MacIntegration.MacHideWindowHandler" _label = "_Hide Application" @@ -43,7 +47,9 @@ <Extension path = "/MonoDevelop/Ide/MainMenu/Window"> <Condition id = "Platform" value = "mac"> <CommandItem id = "MonoDevelop.MacIntegration.MacIntegrationCommands.MinimizeWindow" - insertbefore = "MonoDevelop.Ide.Commands.WindowCommands.NextWindow" /> + insertafter = "NxtPrvSeparator" /> + <CommandItem id = "MonoDevelop.MacIntegration.MacIntegrationCommands.ZoomWindow" /> + <SeparatorItem id = "winMinimizeSep" /> </Condition> </Extension> @@ -81,6 +87,6 @@ <StockIcon stockid = "device" resource = "device.png" size="Menu" /> <StockIcon stockid = "pause" resource = "pause.png" size="Menu" /> <StockIcon stockid = "project" resource = "project.png" size="Menu" /> - <StockIcon stockid = "stop" resource = "stop.png" size="Menu" /> + <StockIcon stockid = "status-stop" resource = "status-stop-16.png" size="Menu" /> </Extension> </ExtensionModel> diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index e15c510581..cc77cfa180 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -52,6 +52,7 @@ using MonoDevelop.MacIntegration.MacMenu; using MonoDevelop.Components.Extensions; using System.Runtime.InteropServices; using ObjCRuntime; +using System.Diagnostics; using Xwt.Mac; namespace MonoDevelop.MacIntegration @@ -142,6 +143,11 @@ namespace MonoDevelop.MacIntegration System.Reflection.Assembly.LoadFrom (Path.Combine (path, "Xwt.XamMac.dll")); var loaded = Xwt.Toolkit.Load (Xwt.ToolkitType.XamMac); + loaded.RegisterBackend<Xwt.Backends.IDialogBackend, ThemedMacDialogBackend> (); + loaded.RegisterBackend<Xwt.Backends.IWindowBackend, ThemedMacWindowBackend> (); + loaded.RegisterBackend<Xwt.Backends.IAlertDialogBackend, ThemedMacAlertDialogBackend> (); + + // We require Xwt.Mac to initialize MonoMac before we can execute any code using MonoMac timer.Trace ("Installing App Event Handlers"); GlobalSetup (); @@ -269,7 +275,7 @@ namespace MonoDevelop.MacIntegration //mac-ify these command names commandManager.GetCommand (EditCommands.MonodevelopPreferences).Text = GettextCatalog.GetString ("Preferences..."); - commandManager.GetCommand (EditCommands.DefaultPolicies).Text = GettextCatalog.GetString ("Custom Policies..."); + commandManager.GetCommand (EditCommands.DefaultPolicies).Text = GettextCatalog.GetString ("Policies..."); commandManager.GetCommand (HelpCommands.About).Text = GetAboutCommandText (); commandManager.GetCommand (MacIntegrationCommands.HideWindow).Text = GetHideWindowCommandText (); commandManager.GetCommand (ToolCommands.AddinManager).Text = GettextCatalog.GetString ("Add-ins..."); @@ -789,6 +795,18 @@ namespace MonoDevelop.MacIntegration return (int)(frame.Height - rect.Height); } + internal static int GetTitleBarHeight (NSWindow w) + { + int height = 0; + if (w.StyleMask.HasFlag (NSWindowStyle.Titled)) + height += GetTitleBarHeight (); + if (w.Toolbar != null) { + var rect = NSWindow.ContentRectFor (w.Frame, w.StyleMask); + height += (int)(rect.Height - w.ContentView.Frame.Height); + } + return height; + } + internal static NSImage LoadImage (string resource) { @@ -880,6 +898,7 @@ namespace MonoDevelop.MacIntegration return; // Not yet realized NSWindow w = GtkQuartz.GetWindow (window); + y += GetTitleBarHeight (w); var dr = FromDesktopRect (new Gdk.Rectangle (x, y, width, height)); var r = w.FrameRectFor (dr); w.SetFrame (r, true); @@ -913,5 +932,61 @@ namespace MonoDevelop.MacIntegration NSWorkspace.SharedWorkspace.ActivateFileViewer (selectFiles.Select ((f) => NSUrl.FromFilename (f)).ToArray ()); } } + + internal override void RestartIde (bool reopenWorkspace) + { + FilePath bundlePath = NSBundle.MainBundle.BundlePath; + + if (bundlePath.Extension != ".app") { + base.RestartIde (reopenWorkspace); + return; + } + + var reopen = reopenWorkspace && IdeApp.Workspace != null && IdeApp.Workspace.Items.Count > 0; + + var proc = new Process (); + + var path = bundlePath.Combine ("Contents", "MacOS"); + var psi = new ProcessStartInfo (path.Combine ("mdtool")) { + CreateNoWindow = true, + UseShellExecute = false, + WorkingDirectory = path, + Arguments = "--start-app-bundle", + }; + + var recentWorkspace = reopen ? DesktopService.RecentFiles.GetProjects ().FirstOrDefault ()?.FileName : string.Empty; + if (!string.IsNullOrEmpty (recentWorkspace)) + psi.Arguments += " " + recentWorkspace; + + proc.StartInfo = psi; + proc.Start (); + } + } + + public class ThemedMacWindowBackend : Xwt.Mac.WindowBackend + { + public override void InitializeBackend (object frontend, Xwt.Backends.ApplicationContext context) + { + base.InitializeBackend (frontend, context); + IdeTheme.ApplyTheme (this); + } + } + + public class ThemedMacDialogBackend : Xwt.Mac.DialogBackend + { + public override void InitializeBackend (object frontend, Xwt.Backends.ApplicationContext context) + { + base.InitializeBackend (frontend, context); + IdeTheme.ApplyTheme (this); + } + } + + public class ThemedMacAlertDialogBackend : Xwt.Mac.AlertDialogBackend + { + public override void Initialize (Xwt.Backends.ApplicationContext actx) + { + base.Initialize (actx); + IdeTheme.ApplyTheme (this.Window); + } } } diff --git a/main/src/addins/MacPlatform/MacPlatform.csproj b/main/src/addins/MacPlatform/MacPlatform.csproj index bb07bd8539..378b140fa3 100644 --- a/main/src/addins/MacPlatform/MacPlatform.csproj +++ b/main/src/addins/MacPlatform/MacPlatform.csproj @@ -122,6 +122,7 @@ <Compile Include="MacInterop\AppleEvents\Native.cs" /> <Compile Include="MacMenu\MDLinkMenuItem.cs" /> <Compile Include="MacMenu\MDMenu.cs" /> + <Compile Include="MacMenu\MDMenuHeaderItem.cs" /> <Compile Include="MacMenu\MDMenuItem.cs" /> <Compile Include="MacMenu\MDServicesMenuItem.cs" /> <Compile Include="MacMenu\MDSubMenuItem.cs" /> @@ -220,6 +221,30 @@ <EmbeddedResource Include="maintoolbarbg~dark%402x.png"> <LogicalName>maintoolbarbg~dark@2x.png</LogicalName> </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16.png"> + <LogicalName>status-stop-16.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16%402x.png"> + <LogicalName>status-stop-16@2x.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16~dark.png"> + <LogicalName>status-stop-16~dark.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16~dark%402x.png"> + <LogicalName>status-stop-16~dark@2x.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16~dark~hover.png"> + <LogicalName>status-stop-16~dark~hover.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16~dark~hover%402x.png"> + <LogicalName>status-stop-16~dark~hover@2x.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16~hover.png"> + <LogicalName>status-stop-16~hover.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\status-stop-16~hover%402x.png"> + <LogicalName>status-stop-16~hover@2x.png</LogicalName> + </EmbeddedResource> </ItemGroup> <ItemGroup> <Folder Include="Dialogs\" /> diff --git a/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs b/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs index dc51165f53..7e278b7f01 100644 --- a/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs +++ b/main/src/addins/MacPlatform/MainToolbar/SelectorView.cs @@ -1,4 +1,4 @@ -// SelectorView.cs +// SelectorView.cs // // // Author: @@ -553,6 +553,8 @@ namespace MonoDevelop.MacIntegration.MainToolbar set { activeRuntime = value; using (var mutableModel = value.GetMutableModel ()) { + if (RuntimeChanged != null) + RuntimeChanged (this, new HandledEventArgs ()); UpdatePathText (RuntimeIdx, mutableModel.FullDisplayString); OnSizeChanged (); } diff --git a/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs b/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs index 63e7943e77..81d408d7d1 100644 --- a/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs +++ b/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs @@ -39,6 +39,7 @@ using MonoDevelop.Ide; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.Ide.Tasks; using MonoDevelop.Components.Mac; +using System.Threading; namespace MonoDevelop.MacIntegration.MainToolbar { @@ -336,6 +337,34 @@ namespace MonoDevelop.MacIntegration.MainToolbar } } + class CancelButton : NSButton + { + readonly NSImage stopIcon = MultiResImage.CreateMultiResImage ("status-stop-16", string.Empty); + readonly NSImage stopIconHover = MultiResImage.CreateMultiResImage ("status-stop-16", "hover"); + + public CancelButton () + { + Image = stopIcon; + Hidden = true; + Bordered = false; + ImagePosition = NSCellImagePosition.ImageOnly; + SetButtonType (NSButtonType.MomentaryChange); + AddTrackingArea (new NSTrackingArea (CGRect.Empty, NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.ActiveAlways | NSTrackingAreaOptions.InVisibleRect, this, null)); + } + + public override void MouseEntered (NSEvent theEvent) + { + Image = stopIconHover; + base.MouseEntered (theEvent); + } + + public override void MouseExited (NSEvent theEvent) + { + Image = stopIcon; + base.MouseExited (theEvent); + } + } + [Register] class StatusBar : NSButton, MonoDevelop.Ide.StatusBar { @@ -358,6 +387,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar AnimatedIcon iconAnimation; IDisposable xwtAnimation; readonly BuildResultsView buildResults; + readonly CancelButton cancelButton; NSAttributedString GetStatusString (string text, NSColor color) { @@ -421,6 +451,11 @@ namespace MonoDevelop.MacIntegration.MainToolbar buildResults = new BuildResultsView (); buildResults.Hidden = true; + cancelButton = new CancelButton (); + cancelButton.Activated += (o, e) => { + cts?.Cancel (); + }; + ctxHandler = new StatusBarContextHandler (this); updateHandler = delegate { @@ -450,6 +485,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar TaskService.Errors.TasksRemoved += updateHandler; BrandingService.ApplicationNameChanged += ApplicationNameChanged; + AddSubview (cancelButton); AddSubview (buildResults); AddSubview (imageView); AddSubview (textField); @@ -497,22 +533,28 @@ namespace MonoDevelop.MacIntegration.MainToolbar base.Dispose (disposing); } + static void DrawSeparator (nfloat x, CGRect dirtyRect) + { + var sepRect = new CGRect (x - 6.5, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 4 : 3, 1, 16); + if (sepRect.IntersectsWith (dirtyRect)) { + NSColor.LightGray.SetFill (); + NSBezierPath.FillRect (sepRect); + } + } + public override void DrawRect (CGRect dirtyRect) { base.DrawRect (dirtyRect); - if (statusIcons.Count == 0 || buildResults.Hidden) { - return; - } + if (statusIcons.Count != 0 && !buildResults.Hidden) + DrawSeparator (LeftMostStatusItemX (), dirtyRect); - var x = LeftMostStatusItemX (); - var sepRect = new CGRect (x - 6.5, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 4 : 3, 1, 16); - if (!sepRect.IntersectsWith (dirtyRect)) { - return; - } + if (statusIcons.Count != 0 || !buildResults.Hidden) { + if (cancelButton.Hidden) + return; - NSColor.LightGray.SetFill (); - NSBezierPath.FillRect (sepRect); + DrawSeparator (LeftMostBuildResultX (), dirtyRect); + } } public override void ViewDidMoveToWindow () @@ -556,7 +598,15 @@ namespace MonoDevelop.MacIntegration.MainToolbar return statusIcons.Last ().Frame.X; } - nfloat DrawSeparatorIfNeeded (nfloat right) + nfloat LeftMostBuildResultX () + { + if (buildResults.Hidden) + return LeftMostStatusItemX (); + + return buildResults.Frame.X; + } + + nfloat DrawSeparatorIfNeededBuildResults (nfloat right) { NeedsDisplay = true; @@ -567,15 +617,35 @@ namespace MonoDevelop.MacIntegration.MainToolbar return right - 12; } + nfloat DrawSeparatorIfNeededCancelButton (nfloat right) + { + NeedsDisplay = true; + + if (!buildResults.Hidden) + return buildResults.Frame.X - 12; + + if (statusIcons.Count == 0) + return right; + + return right - 12; + } + IconId buildImageId; void PositionBuildResults (nfloat right) { - right = DrawSeparatorIfNeeded (right); + right = DrawSeparatorIfNeededBuildResults (right); right -= buildResults.Frame.Width; buildResults.SetFrameOrigin (new CGPoint (right, buildResults.Frame.Y)); } + void PositionCancelButton (nfloat right) + { + right = DrawSeparatorIfNeededCancelButton (right); + right -= cancelButton.Frame.Width; + cancelButton.SetFrameOrigin (new CGPoint (right, cancelButton.Frame.Y)); + } + internal void RepositionStatusIcons () { nfloat right = Frame.Width - 6; @@ -586,13 +656,17 @@ namespace MonoDevelop.MacIntegration.MainToolbar } PositionBuildResults (right); + PositionCancelButton (right); right -= 2; - if (!buildResults.Hidden) { // We have a build result layer. - textField.SetFrameSize (new CGSize (buildResults.Frame.X - 3 - textField.Frame.Left, Frame.Height)); - } else - textField.SetFrameSize (new CGSize (right - 3 - textField.Frame.Left, Frame.Height)); + if (!cancelButton.Hidden) { // We have a cancel button. + right = cancelButton.Frame.X; + } else if (!buildResults.Hidden) { // We have a build result layer. + right = buildResults.Frame.X; + } + + textField.SetFrameSize (new CGSize (right - 3 - textField.Frame.Left, Frame.Height)); } public StatusBarIcon ShowStatusIcon (Xwt.Drawing.Image pixbuf) @@ -912,6 +986,19 @@ namespace MonoDevelop.MacIntegration.MainToolbar } } + CancellationTokenSource cts; + public void SetCancellationTokenSource (CancellationTokenSource source) + { + cts = source; + + bool willHide = cts == null; + cancelButton.ToolTip = willHide ? string.Empty : GettextCatalog.GetString ("Cancel operation"); + if (cancelButton.Hidden != willHide) { + cancelButton.Hidden = willHide; + RepositionStatusIcons (); + } + } + void RepositionContents () { nfloat yOffset = 0f; @@ -923,6 +1010,7 @@ namespace MonoDevelop.MacIntegration.MainToolbar textField.Frame = new CGRect (imageView.Frame.Right, yOffset, Frame.Width - 16, Frame.Height); buildResults.Frame = new CGRect (buildResults.Frame.X, buildResults.Frame.Y, buildResults.Frame.Width, Frame.Height); + cancelButton.Frame = new CGRect (cancelButton.Frame.X, cancelButton.Frame.Y, 16, Frame.Height); RepositionStatusIcons (); progressView.Frame = new CGRect (0.5f, MacSystemInformation.OsVersion >= MacSystemInformation.ElCapitan ? 1f : 2f, Frame.Width - 2, Frame.Height - 2); diff --git a/main/src/addins/MacPlatform/icons/status-stop-16.png b/main/src/addins/MacPlatform/icons/status-stop-16.png Binary files differnew file mode 100644 index 0000000000..39d54d332f --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16@2x.png b/main/src/addins/MacPlatform/icons/status-stop-16@2x.png Binary files differnew file mode 100644 index 0000000000..09ac416b54 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16@2x.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16~dark.png b/main/src/addins/MacPlatform/icons/status-stop-16~dark.png Binary files differnew file mode 100644 index 0000000000..2694059347 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16~dark.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16~dark@2x.png b/main/src/addins/MacPlatform/icons/status-stop-16~dark@2x.png Binary files differnew file mode 100644 index 0000000000..a7fd64d271 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16~dark@2x.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16~dark~hover.png b/main/src/addins/MacPlatform/icons/status-stop-16~dark~hover.png Binary files differnew file mode 100644 index 0000000000..856dce2905 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16~dark~hover.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16~dark~hover@2x.png b/main/src/addins/MacPlatform/icons/status-stop-16~dark~hover@2x.png Binary files differnew file mode 100644 index 0000000000..0c5a12cbe4 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16~dark~hover@2x.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16~hover.png b/main/src/addins/MacPlatform/icons/status-stop-16~hover.png Binary files differnew file mode 100644 index 0000000000..d79fa76388 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16~hover.png diff --git a/main/src/addins/MacPlatform/icons/status-stop-16~hover@2x.png b/main/src/addins/MacPlatform/icons/status-stop-16~hover@2x.png Binary files differnew file mode 100644 index 0000000000..340f9c2c73 --- /dev/null +++ b/main/src/addins/MacPlatform/icons/status-stop-16~hover@2x.png diff --git a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.addin.xml b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.addin.xml index bac89c2f85..66cea4d74a 100644 --- a/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.addin.xml +++ b/main/src/addins/MonoDevelop.AssemblyBrowser/MonoDevelop.AssemblyBrowser.addin.xml @@ -12,7 +12,7 @@ <!-- Extensions --> - <Extension path = "/MonoDevelop/Ide/Commands"> + <Extension path = "/MonoDevelop/Ide/Commands/Tools"> <Command id = "MonoDevelop.AssemblyBrowser.ShowAssemblyBrowser" defaultHandler = "MonoDevelop.AssemblyBrowser.AssemblyBrowserHandler" _label = "_Assembly Browser" /> @@ -27,8 +27,8 @@ <CommandItem id = "MonoDevelop.Refactoring.RefactoryCommands.FindDerivedClasses" /> </Extension> - <Extension path = "/MonoDevelop/Ide/MainMenu/View"> - <CommandItem id = "MonoDevelop.AssemblyBrowser.ShowAssemblyBrowser" insertbefore="ViewSeparator3" /> + <Extension path = "/MonoDevelop/Ide/MainMenu/Tools"> + <CommandItem id = "MonoDevelop.AssemblyBrowser.ShowAssemblyBrowser" insertafter="ToolsSection" /> </Extension> <Extension path = "/MonoDevelop/AssemblyBrowser/EditorContextMenu"> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml index 20f6664f33..ae7922108d 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.addin.xml @@ -29,13 +29,13 @@ <ExtensionNode name="Type" /> </ExtensionPoint> <Extension path = "/MonoDevelop/Ide/Pads"> - <Category id="Debug" _name="Debug Windows"> - <Pad id = "MonoDevelop.Debugger.BreakpointPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-breakpoints" class = "MonoDevelop.Debugger.BreakpointPad" _label="Breakpoints" /> - <Pad id = "MonoDevelop.Debugger.LocalsPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-locals" class = "MonoDevelop.Debugger.LocalsPad" _label="Locals" /> - <Pad id = "MonoDevelop.Debugger.WatchPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-watch" class = "MonoDevelop.Debugger.WatchPad" _label="Watch" /> - <Pad id = "MonoDevelop.Debugger.ImmediatePad" defaultLayout="Debug" defaultPlacement = "MonoDevelop.Debugger.StackTracePad/Center Bottom" icon="md-view-debug-immediate" class = "MonoDevelop.Debugger.ImmediatePad" _label="Immediate" /> + <Category id="Debug" _name="Debug Pads"> + <Pad id = "MonoDevelop.Debugger.BreakpointPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-breakpoints" class = "MonoDevelop.Debugger.BreakpointPad" _label="Breakpoints" group="main"/> + <Pad id = "MonoDevelop.Debugger.LocalsPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-locals" class = "MonoDevelop.Debugger.LocalsPad" _label="Locals" group="main"/> + <Pad id = "MonoDevelop.Debugger.WatchPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-watch" class = "MonoDevelop.Debugger.WatchPad" _label="Watch" group="main"/> + <Pad id = "MonoDevelop.Debugger.ImmediatePad" defaultLayout="Debug" defaultPlacement = "MonoDevelop.Debugger.StackTracePad/Center Bottom" icon="md-view-debug-immediate" class = "MonoDevelop.Debugger.ImmediatePad" _label="Immediate"/> <Pad id = "MonoDevelop.Debugger.StackTracePad" defaultLayout="Debug" defaultPlacement = "MonoDevelop.Debugger.WatchPad/Right Bottom" icon="md-view-debug-call-stack" class = "MonoDevelop.Debugger.StackTracePad" _label="Call Stack" /> - <Pad id = "MonoDevelop.Debugger.ThreadsPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-threads" class = "MonoDevelop.Debugger.ThreadsPad" _label="Threads" /> + <Pad id = "MonoDevelop.Debugger.ThreadsPad" defaultLayout="Debug" defaultPlacement = "Bottom" icon="md-view-debug-threads" class = "MonoDevelop.Debugger.ThreadsPad" _label="Threads" group="main"/> </Category> </Extension> @@ -58,14 +58,15 @@ defaultHandler = "MonoDevelop.Debugger.DebugHandler" icon = "md-bug" shortcut = "F5" - macShortcut = "Meta|Return" + macShortcut = "Meta|Return F5" _description = "Start debugging" _label = "Start _Debugging" /> <Command id = "MonoDevelop.Debugger.DebugCommands.DebugEntry" defaultHandler = "MonoDevelop.Debugger.DebugEntryHandler" icon = "md-bug" _description = "Debug current project" - _label = "Start D_ebugging Item" /> + _label = "Start D_ebugging Item" + _displayName = "Start Debugging (Current Project)" /> </Extension> <Extension path = "/MonoDevelop/Ide/Commands"> @@ -85,7 +86,7 @@ shortcut = "Control|Break" _label = "Pause" _description = "Pause Execution" - macShortcut = "Alt|Meta|P" + macShortcut = "Alt|Meta|P Alt+Meta+F15" icon="md-pause-debug"/> <Command id = "MonoDevelop.Debugger.DebugCommands.Continue" defaultHandler = "MonoDevelop.Debugger.ContinueDebugHandler" @@ -97,21 +98,21 @@ _label = "Step Over" _description = "Step Over" shortcut = "F10" - macShortcut = "Shift|Meta|O" + macShortcut = "Shift|Meta|O F10" icon="md-step-over-debug"/> <Command id = "MonoDevelop.Debugger.DebugCommands.StepInto" defaultHandler = "MonoDevelop.Debugger.StepIntoHandler" _label = "Step Into" _description = "Step Into" shortcut = "F11" - macShortcut = "Shift|Meta|I" + macShortcut = "Shift|Meta|I Meta+F11" icon="md-step-into-debug" /> <Command id = "MonoDevelop.Debugger.DebugCommands.StepOut" defaultHandler = "MonoDevelop.Debugger.StepOutHandler" _label = "Step Out" _description = "Step Out" shortcut = "Shift|F11" - macShortcut = "Shift|Meta|U" + macShortcut = "Shift|Meta|U Shift+Meta+F11" icon="md-step-out-debug"/> <Command id = "MonoDevelop.Debugger.DebugCommands.NewBreakpoint" defaultHandler = "MonoDevelop.Debugger.NewBreakpointHandler" @@ -128,7 +129,8 @@ <Command id = "MonoDevelop.Debugger.DebugCommands.ShowBreakpoints" defaultHandler = "MonoDevelop.Debugger.ShowBreakpointsHandler" _label = "View Breakpoints" - icon = "md-view-debug-breakpoints" /> + icon = "md-view-debug-breakpoints" + macShortcut = "Alt+Meta+B" /> <Command id = "MonoDevelop.Debugger.DebugCommands.RemoveBreakpoint" defaultHandler = "MonoDevelop.Debugger.RemoveBreakpointHandler" _label = "Remove Breakpoint" /> @@ -140,13 +142,13 @@ icon = "md-breakpoint" defaultHandler = "MonoDevelop.Debugger.ToggleBreakpointHandler" shortcut = "F9" - macShortcut = "Meta|\" /> + macShortcut = "Meta|\ F9" /> <Command id = "MonoDevelop.Debugger.DebugCommands.EnableDisableBreakpoint" _label = "Enable/Disable Breakpoint" defaultHandler = "MonoDevelop.Debugger.EnableDisableBreakpointHandler" icon = "md-breakpoint-on-off" shortcut = "Control|F9" - macShortcut = "Alt|Meta|/" /> + macShortcut = "Alt|Meta|/ Meta+F9" /> <Command id = "MonoDevelop.Debugger.DebugCommands.DisableAllBreakpoints" _label = "Enable or Disable All Breakpoints" icon = "md-breakpoint-disable-all" @@ -154,7 +156,8 @@ <Command id = "MonoDevelop.Debugger.DebugCommands.ClearAllBreakpoints" defaultHandler = "MonoDevelop.Debugger.ClearAllBreakpointsHandler" icon = "md-clear" - _label = "Clear All Breakpoints" /> + _label = "Clear All Breakpoints" + macShortcut = "Shift+Meta+F9" /> <Command id = "MonoDevelop.Debugger.DebugCommands.ShowDisassembly" _label = "Show Disassembly" defaultHandler = "MonoDevelop.Debugger.ShowDisassemblyHandler" /> @@ -178,22 +181,21 @@ defaultHandler = "MonoDevelop.Debugger.RunToCursorHandler" _label = "Run To Cursor" _description = "Run To Cursor" - shortcut = "Control|F10" /> + shortcut = "Control|F10" + macShortcut = "Meta+F10" /> <Command id = "MonoDevelop.Debugger.DebugCommands.SetNextStatement" defaultHandler = "MonoDevelop.Debugger.SetNextStatementHandler" _label = "Set Next Statement" _description = "Set Next Statement" - shortcut = "Control|Shift|F10" /> + shortcut = "Control|Shift|F10" + macShortcut = "Shift+Meta+F10" /> <Command id = "MonoDevelop.Debugger.DebugCommands.ShowNextStatement" _label = "Show Next Statement" - defaultHandler = "MonoDevelop.Debugger.ShowNextStatementHandler" /> + defaultHandler = "MonoDevelop.Debugger.ShowNextStatementHandler" + macShortcut = "Alt+*" /> </Category> </Extension> - <Extension path = "/MonoDevelop/Ide/MainMenu/View"> - <CommandItem id = "MonoDevelop.Debugger.DebugCommands.ShowDisassembly" insertafter="MonoDevelop.Ide.Commands.ViewCommands.ViewList"/> - </Extension> - <Extension path = "/MonoDevelop/Ide/MainMenu/Run"> <CommandItem id = "MonoDevelop.Debugger.DebugCommands.Debug" insertafter="MonoDevelop.Ide.Commands.ProjectCommands.Run"/> <CommandItem id = "MonoDevelop.Debugger.DebugCommands.Pause" insertafter="MonoDevelop.Ide.Commands.ProjectCommands.Stop"/> @@ -217,6 +219,7 @@ <CommandItem id = "MonoDevelop.Debugger.DebugCommands.DisableAllBreakpoints" /> <CommandItem id = "MonoDevelop.Debugger.DebugCommands.ClearAllBreakpoints" /> <SeparatorItem id = "MonoDevelop.Debugger.ToolsSection" /> + <CommandItem id = "MonoDevelop.Debugger.DebugCommands.ShowDisassembly"/> <CommandItem id = "MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator" /> </Extension> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj index 127da92151..83cfe2bd20 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.csproj @@ -185,7 +185,6 @@ <Compile Include="MonoDevelop.Debugger\DebuggerConsoleView.cs" /> <Compile Include="MonoDevelop.Debugger.Visualizer\CStringVisualizer.cs" /> <Compile Include="MonoDevelop.Debugger.Visualizer\ValueVisualizer.cs" /> - <Compile Include="MonoDevelop.Debugger\InfoFrame.cs" /> <Compile Include="AddinInfo.cs" /> <Compile Include="MonoDevelop.Debugger\IDebuggerExpressionResolver.cs" /> <Compile Include="MonoDevelop.Debugger\DebuggerEngineBackend.cs" /> @@ -401,12 +400,6 @@ <EmbeddedResource Include="icons\lightning-16~dark~disabled%402x.png"> <LogicalName>lightning-16~dark~disabled@2x.png</LogicalName> </EmbeddedResource> - <EmbeddedResource Include="icons\exception-48.png"> - <LogicalName>exception-48.png</LogicalName> - </EmbeddedResource> - <EmbeddedResource Include="icons\exception-48%402x.png"> - <LogicalName>exception-48@2x.png</LogicalName> - </EmbeddedResource> <EmbeddedResource Include="icons\exception-48~dark.png"> <LogicalName>exception-48~dark.png</LogicalName> </EmbeddedResource> @@ -515,6 +508,24 @@ <EmbeddedResource Include="icons\stack-pointer-16%402x.png"> <LogicalName>stack-pointer-16@2x.png</LogicalName> </EmbeddedResource> + <EmbeddedResource Include="icons\toolbar-icon.png"> + <LogicalName>toolbar-icon.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\toolbar-icon%402x.png"> + <LogicalName>toolbar-icon@2x.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\exception-outline-16.png"> + <LogicalName>exception-outline-16.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\exception-outline-16%402x.png"> + <LogicalName>exception-outline-16@2x.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\exception-outline-16~dark.png"> + <LogicalName>exception-outline-16~dark.png</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="icons\exception-outline-16~dark%402x.png"> + <LogicalName>exception-outline-16~dark@2x.png</LogicalName> + </EmbeddedResource> <EmbeddedResource Include="icons\stack-pointer-16~dark.png"> <LogicalName>stack-pointer-16~dark.png</LogicalName> </EmbeddedResource> diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs index 9357df916a..07672051e2 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ExceptionCaughtDialog.cs @@ -40,30 +40,47 @@ using MonoDevelop.Ide.TextEditing; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.Editor.Extension; using MonoDevelop.Ide.Fonts; +using System.Collections.Generic; namespace MonoDevelop.Debugger { - class ExceptionCaughtDialog : Gtk.Dialog + class ExceptionCaughtDialog : Gtk.Window { - static readonly Xwt.Drawing.Image WarningIconPixbuf = Xwt.Drawing.Image.FromResource ("exception-48.png"); + VBox VBox; + static readonly Xwt.Drawing.Image WarningIconPixbuf = Xwt.Drawing.Image.FromResource ("toolbar-icon.png"); + static readonly Xwt.Drawing.Image WarningIconPixbufInner = Xwt.Drawing.Image.FromResource ("exception-outline-16.png"); + protected ObjectValueTreeView ExceptionValueTreeView { get; private set; } + protected TreeView StackTraceTreeView { get; private set; } + protected CheckButton OnlyShowMyCodeCheckbox { get; private set; } + protected Label ExceptionMessageLabel { get; private set; } + protected Label ExceptionTypeLabel { get; private set; } + readonly ExceptionCaughtMessage message; readonly ExceptionInfo exception; ExceptionInfo selected; bool destroyed; + VPanedThin paned; + Expander expanderProperties; + Expander expanderStacktrace; - protected enum ModelColumn { + protected enum ModelColumn + { StackFrame, Markup, IsUserCode } public ExceptionCaughtDialog (ExceptionInfo ex, ExceptionCaughtMessage msg) + : base (WindowType.Toplevel) { + this.Child = VBox = new VBox (); + VBox.Show (); + this.Name = "wizard_dialog"; this.ApplyTheme (); selected = exception = ex; message = msg; @@ -74,73 +91,134 @@ namespace MonoDevelop.Debugger exception.Changed += ExceptionChanged; } - Widget CreateExceptionInfoHeader () + Widget CreateExceptionHeader () { - ExceptionMessageLabel = new Label { UseMarkup = true, Selectable = true, Wrap = true, WidthRequest = 500, Xalign = 0.0f, Yalign = 0.0f }; - ExceptionTypeLabel = new Label { UseMarkup = true, Xalign = 0.0f }; + var icon = new ImageView (WarningIconPixbuf); + icon.Yalign = 0; - ExceptionMessageLabel.Show (); - ExceptionTypeLabel.Show (); + ExceptionTypeLabel = new Label { Xalign = 0.0f }; + ExceptionMessageLabel = new Label { Wrap = true, Xalign = 0.0f }; + ExceptionTypeLabel.ModifyFg (StateType.Normal, new Gdk.Color (255, 255, 255)); + ExceptionMessageLabel.ModifyFg (StateType.Normal, new Gdk.Color (255, 255, 255)); - var alignment = new Alignment (0.0f, 0.0f, 0.0f, 0.0f); - alignment.Child = ExceptionMessageLabel; - alignment.BorderWidth = 6; - alignment.Show (); + if (Platform.IsWindows) { + ExceptionTypeLabel.ModifyFont (Pango.FontDescription.FromString ("bold 19")); + ExceptionMessageLabel.ModifyFont (Pango.FontDescription.FromString ("10")); + } else { + ExceptionTypeLabel.ModifyFont (Pango.FontDescription.FromString ("21")); + ExceptionMessageLabel.ModifyFont (Pango.FontDescription.FromString ("12")); + } - var frame = new InfoFrame (alignment); - frame.Show (); + //Force rendering of background with EventBox + var eventBox = new EventBox (); + var hBox = new HBox (); + var leftVBox = new VBox (); + var rightVBox = new VBox (); - var vbox = new VBox (false, 12); - vbox.PackStart (ExceptionTypeLabel, false, true, 0); - vbox.PackStart (frame, true, true, 0); - vbox.Show (); + leftVBox.PackStart (icon, false, false, (uint)(Platform.IsWindows ? 5 : 0)); // as we change frame.BorderWidth below, we need to compensate - return vbox; - } + rightVBox.PackStart (ExceptionTypeLabel, false, false, (uint)(Platform.IsWindows ? 0 : 2)); + rightVBox.PackStart (ExceptionMessageLabel, true, true, (uint)(Platform.IsWindows ? 6 : 5)); - Widget CreateExceptionHeader () - { - var icon = new ImageView (WarningIconPixbuf); - icon.Show (); + hBox.PackStart (leftVBox, false, false, (uint)(Platform.IsWindows ? 5 : 0)); // as we change frame.BorderWidth below, we need to compensate + hBox.PackStart (rightVBox, true, true, (uint)(Platform.IsWindows ? 5 : 10)); - var hbox = new HBox (false, 12) { BorderWidth = 12 }; - hbox.PackStart (icon, false, true, 0); - hbox.PackStart (CreateExceptionInfoHeader (), true, true, 0); - hbox.Show (); + var frame = new Frame (); + frame.Add (hBox); + frame.BorderWidth = (uint)(Platform.IsWindows ? 5 : 10); // on Windows we need to have smaller border due to ExceptionTypeLabel vertical misalignment + frame.Shadow = ShadowType.None; + frame.ShadowType = ShadowType.None; - return hbox; + eventBox.Add (frame); + eventBox.ShowAll (); + eventBox.ModifyBg (StateType.Normal, new Gdk.Color (119, 130, 140)); + + return eventBox; } Widget CreateExceptionValueTreeView () { ExceptionValueTreeView = new ObjectValueTreeView (); ExceptionValueTreeView.Frame = DebuggingService.CurrentFrame; - ExceptionValueTreeView.ModifyBase (StateType.Normal, Styles.ExceptionCaughtDialog.TreeBackgroundColor.ToGdkColor ()); + ExceptionValueTreeView.ModifyBase (StateType.Normal, Styles.ExceptionCaughtDialog.ValueTreeBackgroundColor.ToGdkColor ()); ExceptionValueTreeView.AllowPopupMenu = false; ExceptionValueTreeView.AllowExpanding = true; ExceptionValueTreeView.AllowPinning = false; ExceptionValueTreeView.AllowEditing = false; ExceptionValueTreeView.AllowAdding = false; + ExceptionValueTreeView.RulesHint = true; + ExceptionValueTreeView.ModifyFont (Pango.FontDescription.FromString (Platform.IsWindows ? "9" : "11")); ExceptionValueTreeView.RulesHint = false; - ExceptionValueTreeView.Selection.Changed += ExceptionValueSelectionChanged; ExceptionValueTreeView.Show (); - var scrolled = new ScrolledWindow { HeightRequest = 180, HscrollbarPolicy = PolicyType.Automatic, VscrollbarPolicy = PolicyType.Automatic }; + var scrolled = new ScrolledWindow { + HeightRequest = 180, + HscrollbarPolicy = PolicyType.Automatic, + VscrollbarPolicy = PolicyType.Automatic + }; scrolled.ShadowType = ShadowType.None; scrolled.Add (ExceptionValueTreeView); scrolled.Show (); + var vbox = new VBox (); + expanderProperties = WrapInExpander (GettextCatalog.GetString ("Properties"), scrolled); + vbox.PackStart (new VBox (), false, false, 5); + vbox.PackStart (expanderProperties, true, true, 0); + vbox.ShowAll (); + return vbox; + } + + class ExpanderWithMinSize : Expander + { + public ExpanderWithMinSize (string label) : base (label) + { + } - return scrolled; + protected override void OnSizeRequested (ref Requisition requisition) + { + base.OnSizeRequested (ref requisition); + requisition.Height = 28; + } + } + + Expander WrapInExpander (string title, Widget widget) + { + var expander = new ExpanderWithMinSize ($"<b>{GLib.Markup.EscapeText (title)}</b>"); + expander.Name = "exception_dialog_expander"; + Gtk.Rc.ParseString (@"style ""exception-dialog-expander"" +{ + GtkExpander::expander-spacing = 10 +} +widget ""*.exception_dialog_expander"" style ""exception-dialog-expander"" +"); + expander.Child = widget; + expander.Spacing = 0; + expander.Show (); + expander.CanFocus = false; + expander.UseMarkup = true; + expander.Expanded = true; + expander.Activated += Expander_Activated; + expander.ModifyBg (StateType.Prelight, Ide.Gui.Styles.PrimaryBackgroundColor.ToGdkColor ()); + return expander; + } + + void Expander_Activated (object sender, EventArgs e) + { + if (expanderProperties.Expanded && expanderStacktrace.Expanded) + paned.PositionSet = false; + else if (expanderStacktrace.Expanded) + paned.Position = paned.MaxPosition; + else + paned.Position = paned.MinPosition; } static void StackFrameLayout (CellLayout layout, CellRenderer cr, TreeModel model, TreeIter iter) { - var frame = (ExceptionStackFrame) model.GetValue (iter, (int) ModelColumn.StackFrame); - var renderer = (StackFrameCellRenderer) cr; + var frame = (ExceptionStackFrame)model.GetValue (iter, (int)ModelColumn.StackFrame); + var renderer = (StackFrameCellRenderer)cr; - renderer.Markup = (string) model.GetValue (iter, (int) ModelColumn.Markup); + renderer.Markup = (string)model.GetValue (iter, (int)ModelColumn.Markup); renderer.Frame = frame; if (frame == null) { @@ -148,7 +226,7 @@ namespace MonoDevelop.Debugger return; } - renderer.IsUserCode = (bool) model.GetValue (iter, (int) ModelColumn.IsUserCode); + renderer.IsUserCode = (bool)model.GetValue (iter, (int)ModelColumn.IsUserCode); } Widget CreateStackTraceTreeView () @@ -159,28 +237,39 @@ namespace MonoDevelop.Debugger StackTraceTreeView.FixedHeightMode = false; StackTraceTreeView.HeadersVisible = false; StackTraceTreeView.ShowExpanders = false; - StackTraceTreeView.RulesHint = true; + StackTraceTreeView.RulesHint = false; StackTraceTreeView.Show (); var renderer = new StackFrameCellRenderer (StackTraceTreeView.PangoContext); - renderer.Width = DefaultWidth; - StackTraceTreeView.AppendColumn ("", renderer, (CellLayoutDataFunc) StackFrameLayout); + StackTraceTreeView.AppendColumn ("", renderer, (CellLayoutDataFunc)StackFrameLayout); - StackTraceTreeView.SizeAllocated += (o, args) => renderer.Width = args.Allocation.Width; StackTraceTreeView.RowActivated += StackFrameActivated; - var scrolled = new ScrolledWindow { HeightRequest = 180, HscrollbarPolicy = PolicyType.Automatic, VscrollbarPolicy = PolicyType.Automatic }; + var scrolled = new ScrolledWindow { + HeightRequest = 180, + HscrollbarPolicy = PolicyType.Never, + VscrollbarPolicy = PolicyType.Automatic + }; scrolled.ShadowType = ShadowType.None; scrolled.Add (StackTraceTreeView); scrolled.Show (); + var vbox = new VBox (); + vbox.PackStart (CreateSeparator (), false, true, 0); + vbox.PackStart (scrolled, true, true, 0); + vbox.Show (); - return scrolled; + var vbox2 = new VBox (); + expanderStacktrace = WrapInExpander (GettextCatalog.GetString ("Stacktrace"), vbox); + vbox2.PackStart (new VBox (), false, false, 5); + vbox2.PackStart (expanderStacktrace, true, true, 0); + vbox2.ShowAll (); + return vbox2; } Widget CreateButtonBox () { - var buttons = new HButtonBox { Layout = ButtonBoxStyle.End, Spacing = 12 }; + var buttons = new HButtonBox { Layout = ButtonBoxStyle.End, Spacing = 18 }; var copy = new Button (Stock.Copy); copy.Clicked += CopyClicked; @@ -207,29 +296,55 @@ namespace MonoDevelop.Debugger return separator; } + bool HasInnerException () + { + return exception.InnerException != null; + } + + bool hadInnerException; + void Build () { Title = GettextCatalog.GetString ("Exception Caught"); + DefaultWidth = 500; DefaultHeight = 500; - DefaultWidth = 600; - VBox.Spacing = 0; - + HeightRequest = 350; + WidthRequest = 350; + VBox.Foreach (VBox.Remove); VBox.PackStart (CreateExceptionHeader (), false, true, 0); - - var paned = new VPaned (); - paned.Add1 (CreateExceptionValueTreeView ()); - paned.Add2 (CreateStackTraceTreeView ()); + paned = new VPanedThin (); + paned.GrabAreaSize = 10; + paned.Pack1 (CreateStackTraceTreeView (), true, false); + paned.Pack2 (CreateExceptionValueTreeView (), true, false); paned.Show (); - var vbox = new VBox (false, 0); - vbox.PackStart (CreateSeparator (), false, true, 0); + var whiteBackground = new EventBox (); + whiteBackground.Show (); + whiteBackground.ModifyBg (StateType.Normal, Ide.Gui.Styles.PrimaryBackgroundColor.ToGdkColor ()); + whiteBackground.Add (vbox); + hadInnerException = HasInnerException (); + if (hadInnerException) { + vbox.PackStart (new VBox (), false, false, 6); + vbox.PackStart (CreateInnerExceptionMessage (), false, true, 0); + vbox.ShowAll (); + } vbox.PackStart (paned, true, true, 0); - vbox.PackStart (CreateSeparator (), false, true, 0); vbox.Show (); - VBox.PackStart (vbox, true, true, 0); - - var actionArea = new HBox (false, 12) { BorderWidth = 6 }; + if (hadInnerException) { + var box = new HBox (); + box.PackStart (CreateInnerExceptionsTree (), false, false, 0); + box.PackStart (whiteBackground, true, true, 0); + box.Show (); + VBox.PackStart (box, true, true, 0); + DefaultWidth = 900; + DefaultHeight = 700; + WidthRequest = 550; + HeightRequest = 450; + } else { + VBox.PackStart (whiteBackground, true, true, 0); + } + var actionArea = new HBox (false, 0) { BorderWidth = 14 }; OnlyShowMyCodeCheckbox = new CheckButton (GettextCatalog.GetString ("_Only show my code.")); OnlyShowMyCodeCheckbox.Toggled += OnlyShowMyCodeToggled; @@ -241,55 +356,129 @@ namespace MonoDevelop.Debugger actionArea.PackStart (alignment, true, true, 0); actionArea.PackStart (CreateButtonBox (), false, true, 0); - actionArea.Show (); + actionArea.PackStart (new VBox (), false, true, 3); // dummy just to take extra 6px at end to make it 20pixels + actionArea.ShowAll (); VBox.PackStart (actionArea, false, true, 0); - ActionArea.Hide (); } - bool TryGetExceptionInfo (TreePath path, out ExceptionInfo ex) - { - var model = (TreeStore) ExceptionValueTreeView.Model; - TreeIter iter, parent; + Label InnerExceptionTypeLabel; + Label InnerExceptionMessageLabel; - ex = exception; + Widget CreateInnerExceptionMessage () + { + var hboxMain = new HBox (); + var vbox = new VBox (); + var hbox = new HBox (); - if (!model.GetIter (out iter, path)) - return false; + var icon = new ImageView (WarningIconPixbufInner); + icon.Yalign = 0; + hbox.PackStart (icon, false, false, 0); - var value = (ObjectValue) model.GetValue (iter, ObjectValueTreeView.ObjectColumn); - if (value.Name != "InnerException") - return false; + InnerExceptionTypeLabel = new Label (); + InnerExceptionTypeLabel.UseMarkup = true; + InnerExceptionTypeLabel.Xalign = 0; + hbox.PackStart (InnerExceptionTypeLabel, false, true, 4); - int depth = 0; - while (model.IterParent (out parent, iter)) { - iter = parent; - depth++; - } + InnerExceptionMessageLabel = new Label (); + InnerExceptionMessageLabel.Wrap = true; + InnerExceptionMessageLabel.Xalign = 0; + InnerExceptionMessageLabel.ModifyFont (Pango.FontDescription.FromString (Platform.IsWindows ? "9" : "11")); + vbox.PackStart (hbox, false, true, 0); + vbox.PackStart (InnerExceptionMessageLabel, true, true, 10); + hboxMain.PackStart (vbox, true, true, 10); + hboxMain.ShowAll (); + return hboxMain; + } - while (ex != null) { - if (depth == 0) - return true; + TreeStore InnerExceptionsStore; - ex = ex.InnerException; - depth--; + class InnerExceptionsTree : TreeView + { + public InnerExceptionsTree () + { + Events |= Gdk.EventMask.PointerMotionMask; } - return false; + protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt) + { + TreePath path; + //We want effect that when user has mouse button pressed and is moving over tree to autoselect exception + if (evnt.State == Gdk.ModifierType.Button1Mask && GetPathAtPos ((int)evnt.X, (int)evnt.Y, out path)) { + Selection.SelectPath (path); + } + return base.OnMotionNotifyEvent (evnt); + } } - void ExceptionValueSelectionChanged (object sender, EventArgs e) + InnerExceptionsTree InnerExceptionsTreeView; + + Dictionary<ExceptionInfo, ExceptionInfo> ReverseInnerExceptions = new Dictionary<ExceptionInfo, ExceptionInfo> (); + + Widget CreateInnerExceptionsTree () { - var selectedRows = ExceptionValueTreeView.Selection.GetSelectedRows (); - ExceptionInfo ex; + InnerExceptionsTreeView = new InnerExceptionsTree (); + InnerExceptionsTreeView.ModifyBase (StateType.Normal, Styles.ExceptionCaughtDialog.TreeBackgroundColor.ToGdkColor ()); // background + InnerExceptionsTreeView.ModifyBase (StateType.Selected, Styles.ExceptionCaughtDialog.TreeSelectedBackgroundColor.ToGdkColor ()); // selected + InnerExceptionsTreeView.HeadersVisible = false; + InnerExceptionsStore = new TreeStore (typeof (ExceptionInfo)); + + FillInnerExceptionsStore (InnerExceptionsStore, exception); + InnerExceptionsTreeView.AppendColumn ("Exception", new CellRendererInnerException (), new TreeCellDataFunc ((tree_column, cell, tree_model, iter) => { + var c = (CellRendererInnerException)cell; + c.Text = ((ExceptionInfo)tree_model.GetValue (iter, 0)).Type; + })); + InnerExceptionsTreeView.ShowExpanders = false; + InnerExceptionsTreeView.LevelIndentation = 10; + InnerExceptionsTreeView.Model = InnerExceptionsStore; + InnerExceptionsTreeView.ExpandAll (); + InnerExceptionsTreeView.Selection.Changed += (sender, e) => { + TreeIter selectedIter; + if (InnerExceptionsTreeView.Selection.GetSelected (out selectedIter)) { + UpdateSelectedException ((ExceptionInfo)InnerExceptionsTreeView.Model.GetValue (selectedIter, 0)); + } + }; + var eventBox = new EventBox (); + eventBox.ModifyBg (StateType.Normal, Styles.ExceptionCaughtDialog.TreeBackgroundColor.ToGdkColor ()); // top and bottom padders + var vbox = new VBox (); + vbox.PackStart (InnerExceptionsTreeView, true, true, 12); + eventBox.Add (vbox); + eventBox.ShowAll (); + return eventBox; + } - if (selectedRows.Length > 0 && TryGetExceptionInfo (selectedRows[0], out ex)) { - ShowStackTrace (ex); - selected = ex; - } else if (selected != exception) { - ShowStackTrace (exception); - selected = exception; + void FillInnerExceptionsStore (TreeStore store, ExceptionInfo exception, TreeIter parentIter = default (TreeIter)) + { + TreeIter iter; + if (parentIter.Equals (TreeIter.Zero)) { + iter = store.AppendValues (exception); + ReverseInnerExceptions [exception] = null; + } else { + ReverseInnerExceptions [exception] = (ExceptionInfo)store.GetValue (parentIter, 0); + iter = store.AppendValues (parentIter, exception); } + var updateInnerExceptions = new System.Action (() => { + if (!InnerExceptionsStore.IterHasChild (iter)) { + var innerExceptions = exception.InnerExceptions; + if (innerExceptions != null && innerExceptions.Count > 0) { + foreach (var inner in innerExceptions) { + FillInnerExceptionsStore (store, inner, iter); + } + } else { + var inner = exception.InnerException; + if (inner != null) + FillInnerExceptionsStore (store, inner, iter); + } + } + }); + exception.Changed += delegate { + Application.Invoke (delegate { + InnerExceptionsStore.EmitRowChanged (InnerExceptionsStore.GetPath (iter), iter); + updateInnerExceptions (); + InnerExceptionsTreeView.ExpandRow (InnerExceptionsStore.GetPath (iter), true); + }); + }; + updateInnerExceptions (); } void StackFrameActivated (object o, RowActivatedArgs args) @@ -300,7 +489,7 @@ namespace MonoDevelop.Debugger if (!model.GetIter (out iter, args.Path)) return; - var frame = (ExceptionStackFrame) model.GetValue (iter, (int) ModelColumn.StackFrame); + var frame = (ExceptionStackFrame)model.GetValue (iter, (int)ModelColumn.StackFrame); if (frame != null && !string.IsNullOrEmpty (frame.File) && File.Exists (frame.File)) { try { @@ -318,34 +507,50 @@ namespace MonoDevelop.Debugger return IdeApp.Workspace.GetProjectsContainingFile (frame.File).Any (); } - void ShowStackTrace (ExceptionInfo ex) + void UpdateSelectedException (ExceptionInfo ex) { - var model = (ListStore) StackTraceTreeView.Model; + selected = ex; + var model = (ListStore)StackTraceTreeView.Model; bool external = false; model.Clear (); - - foreach (var frame in ex.StackTrace) { - bool isUserCode = IsUserCode (frame); - - if (OnlyShowMyCodeCheckbox.Active && !isUserCode) { - if (!external) { - var str = "<b>" + GettextCatalog.GetString ("[External Code]") + "</b>"; - model.AppendValues (null, str, false); - external = true; + var parentException = ex; + while (parentException != null) { + foreach (var frame in parentException.StackTrace) { + bool isUserCode = IsUserCode (frame); + + if (OnlyShowMyCodeCheckbox.Active && !isUserCode) { + if (!external) { + var str = "<b>" + GettextCatalog.GetString ("[External Code]") + "</b>"; + model.AppendValues (null, str, false); + external = true; + } + + continue; } - continue; + model.AppendValues (frame, null, isUserCode); + external = false; } - - model.AppendValues (frame, null, isUserCode); - external = false; + if (!ReverseInnerExceptions.TryGetValue (parentException, out parentException)) + parentException = null; + } + ExceptionValueTreeView.ClearAll (); + if (!ex.IsEvaluating && ex.Instance != null) { + var opts = DebuggingService.GetUserOptions ().EvaluationOptions.Clone (); + opts.FlattenHierarchy = true; + ExceptionValueTreeView.AddValues (ex.Instance.GetAllChildren (opts)); } if (ex.StackIsEvaluating) { var str = GettextCatalog.GetString ("Loading..."); model.AppendValues (null, str, false); } + + if (InnerExceptionTypeLabel != null) { + InnerExceptionTypeLabel.Markup = "<b>" + GLib.Markup.EscapeText (ex.Type) + "</b>"; + InnerExceptionMessageLabel.Text = ex.Message; + } } void UpdateDisplay () @@ -353,29 +558,24 @@ namespace MonoDevelop.Debugger if (destroyed) return; - ExceptionValueTreeView.ClearValues (); - - ExceptionTypeLabel.Markup = GettextCatalog.GetString ("A <b>{0}</b> was thrown.", exception.Type); - ExceptionMessageLabel.Markup = "<small>" + (exception.Message ?? string.Empty) + "</small>"; - - if (!exception.IsEvaluating && exception.Instance != null) { - ExceptionValueTreeView.AddValue (exception.Instance); - ExceptionValueTreeView.ExpandRow (new TreePath ("0"), false); - } + ExceptionTypeLabel.Text = exception.Type; + ExceptionMessageLabel.Text = exception.Message ?? string.Empty; - ShowStackTrace (exception); + UpdateSelectedException (exception); } void ExceptionChanged (object sender, EventArgs e) { Application.Invoke (delegate { + if (hadInnerException != HasInnerException ()) + Build (); UpdateDisplay (); }); } void OnlyShowMyCodeToggled (object sender, EventArgs e) { - ShowStackTrace (selected); + UpdateSelectedException (selected); } void CloseClicked (object sender, EventArgs e) @@ -406,138 +606,149 @@ namespace MonoDevelop.Debugger exception.Changed -= ExceptionChanged; base.OnDestroyed (); } + + class CellRendererInnerException : CellRenderer + { + public string Text { get; set; } + + Pango.FontDescription font = Pango.FontDescription.FromString (Platform.IsWindows ? "9" : "11"); + + public override void GetSize (Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height) + { + using (var layout = new Pango.Layout (widget.PangoContext)) { + layout.FontDescription = font; + Pango.Rectangle ink, logical; + layout.SetMarkup ("<b>" + Text + "</b>"); + layout.GetPixelExtents (out ink, out logical); + width = logical.Width + 10; + height = logical.Height + 2; + + x_offset = 0; + y_offset = 0; + } + } + + protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) + { + using (var cr = Gdk.CairoHelper.Create (window)) { + cr.Rectangle (background_area.X, background_area.Y, background_area.Width, background_area.Height); + + using (var layout = new Pango.Layout (widget.PangoContext)) { + layout.FontDescription = font; + + if ((flags & CellRendererState.Selected) != 0) { + cr.SetSourceRGB (Styles.ExceptionCaughtDialog.TreeSelectedBackgroundColor.Red, + Styles.ExceptionCaughtDialog.TreeSelectedBackgroundColor.Green, + Styles.ExceptionCaughtDialog.TreeSelectedBackgroundColor.Blue); // selected + cr.Fill (); + cr.SetSourceRGB (Styles.ExceptionCaughtDialog.TreeSelectedTextColor.Red, + Styles.ExceptionCaughtDialog.TreeSelectedTextColor.Green, + Styles.ExceptionCaughtDialog.TreeSelectedTextColor.Blue); + } else { + cr.SetSourceRGB (Styles.ExceptionCaughtDialog.TreeBackgroundColor.Red, + Styles.ExceptionCaughtDialog.TreeBackgroundColor.Green, + Styles.ExceptionCaughtDialog.TreeBackgroundColor.Blue); // background + cr.Fill (); + cr.SetSourceRGB (Styles.ExceptionCaughtDialog.TreeTextColor.Red, + Styles.ExceptionCaughtDialog.TreeTextColor.Green, + Styles.ExceptionCaughtDialog.TreeTextColor.Blue); + } + + layout.SetMarkup (Text); + cr.Translate (cell_area.X + 10, cell_area.Y + 1); + cr.ShowLayout (layout); + } + } + } + } } class StackFrameCellRenderer : CellRenderer { - static readonly Pango.FontDescription LineNumberFont = FontService.MonospaceFont.CopyModified (Ide.Gui.Styles.FontScale11); - const int RoundedRectangleRadius = 2; - const int RoundedRectangleHeight = 14; - const int RoundedRectangleWidth = 28; const int Padding = 6; public readonly Pango.Context Context; public ExceptionStackFrame Frame; public bool IsUserCode; public string Markup; + Pango.FontDescription font = Pango.FontDescription.FromString (Platform.IsWindows ? "9" : "11"); public StackFrameCellRenderer (Pango.Context ctx) { Context = ctx; } - int MaxMarkupWidth { - get { - if (Width < 0) - return Width; + string GetMethodMarkup (bool selected) + { + if (Markup != null) + return $"<span foreground='{Styles.ExceptionCaughtDialog.ExternalCodeTextColor.ToHexString (false)}'>{Markup}</span>"; + var methodText = Frame.DisplayText; + var endOfMethodName = methodText.IndexOf ('('); + var methodName = methodText.Remove (endOfMethodName).Trim (); + var endOfParameters = methodText.IndexOf (')') + 1; + var parameters = methodText.Substring (endOfMethodName, endOfParameters - endOfMethodName).Trim (); + + var markup = $"<b>{GLib.Markup.EscapeText (methodName)}</b> {GLib.Markup.EscapeText (parameters)}"; + + if (selected) + markup = $"<span foreground='#FFFFFF'>{markup}</span>"; + else { + var textColor = IsUserCode ? Ide.Gui.Styles.BaseForegroundColor.ToHexString (false) : Styles.ExceptionCaughtDialog.ExternalCodeTextColor.ToHexString (false); + markup = $"<span foreground='{textColor}'>{markup}</span>"; + } + + return markup; + } - return Width - (Padding + RoundedRectangleWidth + Padding + Padding + Padding); + string GetFileMarkup (bool selected) + { + if (Frame == null || string.IsNullOrEmpty (Frame.File)) { + return ""; + } + + var markup = string.Format ("<span foreground='{0}'>{1}", selected ? "#FFFFFF" : Styles.ExceptionCaughtDialog.LineNumberTextColor.ToHexString (false), GLib.Markup.EscapeText (Path.GetFileName (Frame.File))); + if (Frame.Line > 0) { + markup += ":" + Frame.Line; + if (Frame.Column > 0) + markup += "," + Frame.Column; } + markup += "</span>"; + return markup; } public override void GetSize (Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height) { using (var layout = new Pango.Layout (Context)) { Pango.Rectangle ink, logical; - - layout.Width = (int) (MaxMarkupWidth * Pango.Scale.PangoScale); - layout.SetMarkup (GetMarkup (false, widget)); - + layout.FontDescription = font; + layout.SetMarkup (GetMethodMarkup (false)); layout.GetPixelExtents (out ink, out logical); - width = Padding + RoundedRectangleWidth + Padding + Padding + logical.Width + Padding; - height = Padding + Math.Max (RoundedRectangleHeight, logical.Height) + Padding; - + height = logical.Height; + width = 0; x_offset = 0; y_offset = 0; } } - void RenderLineNumberIcon (Widget widget, Cairo.Context cr, Gdk.Rectangle cell_area, int markupHeight, int yOffset) - { - if (Frame == null) - return; - - cr.Save (); - - #if CENTER_ROUNDED_RECTANGLE - cr.Translate (cell_area.X + Padding, (cell_area.Y + (cell_area.Height - RoundedRectangleHeight) / 2.0)); - #else - cr.Translate (cell_area.X + Padding, cell_area.Y + Padding + yOffset); - #endif - - cr.Antialias = Cairo.Antialias.Subpixel; - - cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); - cr.Clip (); - - if (IsUserCode) - cr.SetSourceColor (Styles.ExceptionCaughtDialog.LineNumberInUserCodeBackgroundColor.ToCairoColor ()); // 230, 152, 223 - else - cr.SetSourceColor (Styles.ExceptionCaughtDialog.LineNumberBackgroundColor.ToCairoColor ()); // 197, 197, 197 - - cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius); - cr.Fill (); - - var lineNumber = !string.IsNullOrEmpty (Frame.File) ? Frame.Line : -1; - - using (var layout = PangoUtil.CreateLayout (widget, lineNumber != -1 ? lineNumber.ToString () : "???")) { - layout.Alignment = Pango.Alignment.Left; - layout.FontDescription = LineNumberFont; - - int width, height; - layout.GetPixelSize (out width, out height); - - double y_offset = (RoundedRectangleHeight - height) / 2.0; - double x_offset = (RoundedRectangleWidth - width) / 2.0; - - cr.SetSourceColor (Styles.ExceptionCaughtDialog.LineNumberTextColor.ToCairoColor ()); - cr.Translate (x_offset, y_offset); - cr.ShowLayout (layout); - } - - cr.Restore (); - } - - string GetMarkup (bool selected, Gtk.Widget parent) - { - string text_color = selected ? parent.Style.Text (StateType.Selected).GetHex () : parent.Style.Text (StateType.Normal).GetHex (); - - if (Markup != null) - return "<span foreground='" + text_color + "'>" + Markup + "</span>"; - - var markup = string.Format ("<span foreground='{0}'><b>{1}</b></span>", text_color, GLib.Markup.EscapeText (Frame.DisplayText)); - - if (!string.IsNullOrEmpty (Frame.File)) { - markup += string.Format ("<span size='4096'>\n\n</span><span size='small' foreground='{0}'>{1}", text_color, GLib.Markup.EscapeText (Frame.File)); - if (Frame.Line > 0) { - markup += ":" + Frame.Line; - if (Frame.Column > 0) - markup += "," + Frame.Column; - } - markup += "</span>"; - } - - return markup; - } - protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) { using (var cr = Gdk.CairoHelper.Create (window)) { + Pango.Rectangle ink, logical; using (var layout = new Pango.Layout (Context)) { - Pango.Rectangle ink, logical; - - layout.Width = (int) (MaxMarkupWidth * Pango.Scale.PangoScale); - layout.SetMarkup (GetMarkup ((flags & CellRendererState.Selected) != 0, widget)); - + layout.FontDescription = font; + layout.SetMarkup (GetFileMarkup ((flags & CellRendererState.Selected) != 0)); layout.GetPixelExtents (out ink, out logical); + var width = widget.Allocation.Width; + cr.Translate (width - logical.Width - 10, cell_area.Y); + cr.ShowLayout (layout); - RenderLineNumberIcon (widget, cr, cell_area, logical.Height, ink.Y); - - cr.Rectangle (expose_area.X, expose_area.Y, expose_area.Width, expose_area.Height); - cr.Clip (); + cr.IdentityMatrix (); - cr.Translate (cell_area.X + Padding + RoundedRectangleWidth + Padding + Padding, cell_area.Y + Padding); + layout.SetMarkup (GetMethodMarkup ((flags & CellRendererState.Selected) != 0)); + layout.Width = (int)((width - logical.Width - 35) * Pango.Scale.PangoScale); + layout.Ellipsize = Pango.EllipsizeMode.Middle; + cr.Translate (cell_area.X + 10, cell_area.Y); cr.ShowLayout (layout); } } @@ -559,11 +770,13 @@ namespace MonoDevelop.Debugger } public FilePath File { - get; private set; + get; + private set; } public int Line { - get; set; + get; + set; } public bool IsMinimized { @@ -573,15 +786,28 @@ namespace MonoDevelop.Debugger public void ShowDialog () { if (dialog == null) { - using (dialog = new ExceptionCaughtDialog (ex, this)) - MessageService.ShowCustomDialog (dialog, IdeApp.Workbench.RootWindow); + dialog = new ExceptionCaughtDialog (ex, this); + IdeApp.CommandService.RegisterTopWindow (dialog); + dialog.TransientFor = IdeApp.Workbench.RootWindow; + dialog.Show (); + MessageService.PlaceDialog (dialog, IdeApp.Workbench.RootWindow); + dialog.Destroyed += Dialog_Destroyed;; + } + } + + void Dialog_Destroyed (object sender, EventArgs e) + { + if (dialog != null) { + dialog.Destroyed -= Dialog_Destroyed; dialog = null; } } + public void ShowButton () { if (dialog != null) { + dialog.Destroyed -= Dialog_Destroyed; dialog.Destroy (); dialog = null; } @@ -599,6 +825,7 @@ namespace MonoDevelop.Debugger public void ShowMiniButton () { if (dialog != null) { + dialog.Destroyed -= Dialog_Destroyed; dialog.Destroy (); dialog = null; } @@ -639,13 +866,14 @@ namespace MonoDevelop.Debugger public event EventHandler Closed; } - class ExceptionCaughtButton: TopLevelWidgetExtension + class ExceptionCaughtButton : TopLevelWidgetExtension { readonly Xwt.Drawing.Image closeSelOverImage; readonly Xwt.Drawing.Image closeSelImage; readonly ExceptionCaughtMessage dlg; readonly ExceptionInfo exception; Label messageLabel; + Label typeLabel; public ExceptionCaughtButton (ExceptionInfo val, ExceptionCaughtMessage dlg, FilePath file, int line) { @@ -674,10 +902,10 @@ namespace MonoDevelop.Debugger vb.PackStart (image, false, false, 0); box.PackStart (vb, false, false, 0); vb = new VBox (false, 6); - vb.PackStart (new Label { - Markup = GettextCatalog.GetString ("<b>{0}</b> has been thrown", exception.Type), + typeLabel = new Label { Xalign = 0 - }); + }; + vb.PackStart (typeLabel); messageLabel = new Label { Xalign = 0, NoShowAll = true @@ -686,7 +914,7 @@ namespace MonoDevelop.Debugger var detailsBtn = new Xwt.LinkLabel (GettextCatalog.GetString ("Show Details")); var hh = new HBox (); - detailsBtn.NavigateToUrl += (o,e) => dlg.ShowDialog (); + detailsBtn.NavigateToUrl += (o, e) => dlg.ShowDialog (); hh.PackStart (detailsBtn.ToGtkWidget (), false, false, 0); vb.PackStart (hh, false, false, 0); @@ -731,10 +959,16 @@ namespace MonoDevelop.Debugger } else { messageLabel.Hide (); } + if (!string.IsNullOrEmpty (exception.Type)) { + typeLabel.Show (); + typeLabel.Markup = GettextCatalog.GetString ("<b>{0}</b> has been thrown", GLib.Markup.EscapeText (exception.Type)); + } else { + typeLabel.Hide (); + } } } - class ExceptionCaughtMiniButton: TopLevelWidgetExtension + class ExceptionCaughtMiniButton : TopLevelWidgetExtension { readonly ExceptionCaughtMessage dlg; @@ -758,7 +992,7 @@ namespace MonoDevelop.Debugger box.VisibleWindow = false; var icon = Xwt.Drawing.Image.FromResource ("lightning-16.png"); box.Add (new Xwt.ImageView (icon).ToGtkWidget ()); - box.ButtonPressEvent += (o,e) => dlg.ShowButton (); + box.ButtonPressEvent += (o, e) => dlg.ShowButton (); var eb = new PopoverWidget (); eb.Theme.Padding = 2; eb.ShowArrow = true; @@ -770,13 +1004,13 @@ namespace MonoDevelop.Debugger } } - class ExceptionCaughtTextEditorExtension: TextEditorExtension + class ExceptionCaughtTextEditorExtension : TextEditorExtension { public override bool KeyPress (KeyDescriptor descriptor) { if (descriptor.SpecialKey == SpecialKey.Escape && DebuggingService.ExceptionCaughtMessage != null && - !DebuggingService.ExceptionCaughtMessage.IsMinimized && - DebuggingService.ExceptionCaughtMessage.File.CanonicalPath == new FilePath(DocumentContext.Name).CanonicalPath) { + !DebuggingService.ExceptionCaughtMessage.IsMinimized && + DebuggingService.ExceptionCaughtMessage.File.CanonicalPath == new FilePath (DocumentContext.Name).CanonicalPath) { DebuggingService.ExceptionCaughtMessage.ShowMiniButton (); return true; diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/InfoFrame.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/InfoFrame.cs deleted file mode 100644 index 882f54980b..0000000000 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/InfoFrame.cs +++ /dev/null @@ -1,64 +0,0 @@ -//
-// InfoFrame.cs
-//
-// Author:
-// Jeffrey Stedfast <jeff@xamarin.com>
-//
-// Copyright (c) 2013 Xamarin Inc.
-//
-// 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 Gtk; -using MonoDevelop.Components;
-
-namespace MonoDevelop.Debugger -{ - [System.ComponentModel.ToolboxItem (true)] - class InfoFrame : Frame - { - public InfoFrame () - { - Shadow = ShadowType.None; - } - - public InfoFrame (Widget child) : this () - { - Child = child; - } - - protected override bool OnExposeEvent (Gdk.EventExpose evnt) - { - using (Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow)) { - cr.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height); - cr.ClipPreserve (); - - cr.SetSourceColor (Styles.ExceptionCaughtDialog.InfoFrameBackgroundColor.ToCairoColor ()); - cr.FillPreserve (); - - cr.SetSourceColor (Styles.ExceptionCaughtDialog.InfoFrameBorderColor.ToCairoColor ()); - cr.LineWidth = 2; - cr.Stroke (); - } - - return base.OnExposeEvent (evnt); - } - } -} diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs index 1ce1c29eba..d0f5786ddb 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/ObjectValueTreeView.cs @@ -272,10 +272,10 @@ namespace MonoDevelop.Debugger int YOffset = (cell_area.Height - h) / 2; if (((ObjectValueTreeView)widget).CompactView && !Platform.IsWindows) YOffset += 1; - window.DrawLayoutWithColors (widget.Style.TextGC (StateType.Normal), - cell_area.X + (cell_area.Height - TopBottomPadding * 2 + 1) / 2 + xpad, - cell_area.Y + YOffset, - layout, Styles.ObjectValueTreeValuesButtonText.ToGdkColor(), Styles.ObjectValueTreeValuesButtonBackground.ToGdkColor()); + cr.SetSourceColor (Styles.ObjectValueTreeValuesButtonText.ToCairoColor ()); + cr.MoveTo (cell_area.X + (cell_area.Height - TopBottomPadding * 2 + 1) / 2 + xpad, + cell_area.Y + YOffset); + cr.ShowLayout (layout); } } } diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Styles.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Styles.cs index c1c386b493..8186949e7a 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Styles.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/Styles.cs @@ -46,11 +46,12 @@ namespace MonoDevelop.Debugger public class ExceptionCaughtDialogStyle { public Color TreeBackgroundColor { get; internal set; } - public Color InfoFrameBackgroundColor { get; internal set; } - public Color InfoFrameBorderColor { get; internal set; } - public Color LineNumberBackgroundColor { get; internal set; } - public Color LineNumberInUserCodeBackgroundColor { get; internal set; } + public Color TreeTextColor { get; internal set; } public Color LineNumberTextColor { get; internal set; } + public Color ExternalCodeTextColor { get; internal set; } + public Color TreeSelectedBackgroundColor { get; internal set; } + public Color TreeSelectedTextColor { get; internal set; } + public Color ValueTreeBackgroundColor { get; internal set; } } static Styles () @@ -62,6 +63,11 @@ namespace MonoDevelop.Debugger public static void LoadStyles () { ExceptionCaughtDialog = new ExceptionCaughtDialogStyle (); + ExceptionCaughtDialog.TreeBackgroundColor = Ide.Gui.Styles.BrowserPadBackground; + ExceptionCaughtDialog.TreeTextColor = Ide.Gui.Styles.BaseForegroundColor; + ExceptionCaughtDialog.TreeSelectedBackgroundColor = Ide.Gui.Styles.BaseSelectionBackgroundColor; + ExceptionCaughtDialog.TreeSelectedTextColor = Ide.Gui.Styles.BaseSelectionTextColor; + ExceptionCaughtDialog.ValueTreeBackgroundColor = Ide.Gui.Styles.PadBackground; if (IdeApp.Preferences.UserInterfaceTheme == Theme.Light) { ObjectValueTreeValuesButtonBackground = Color.FromName ("#e9f2fc"); @@ -70,11 +76,8 @@ namespace MonoDevelop.Debugger ObjectValueTreeValueDisabledText = Color.FromName ("#7f7f7f"); ObjectValueTreeValueModifiedText = Color.FromName ("#1FAECE"); - ExceptionCaughtDialog.InfoFrameBackgroundColor = Color.FromName ("#fbefce"); - ExceptionCaughtDialog.InfoFrameBorderColor = Color.FromName ("#f0e4c2"); - ExceptionCaughtDialog.LineNumberBackgroundColor = Color.FromName ("#c4c4c4"); - ExceptionCaughtDialog.LineNumberInUserCodeBackgroundColor = Color.FromName ("#e599de"); - ExceptionCaughtDialog.LineNumberTextColor = Color.FromName ("#ffffff"); + ExceptionCaughtDialog.LineNumberTextColor = Color.FromName ("#BBBBBB"); + ExceptionCaughtDialog.ExternalCodeTextColor = Color.FromName ("#BBBBBB"); } else { ObjectValueTreeValuesButtonBackground = Color.FromName ("#7c8695"); ObjectValueTreeValuesButtonText = Color.FromName ("#cbe5ff"); @@ -82,11 +85,8 @@ namespace MonoDevelop.Debugger ObjectValueTreeValueDisabledText = Color.FromName ("#5a5a5a"); ObjectValueTreeValueModifiedText = Color.FromName ("#4FCAE6"); - ExceptionCaughtDialog.InfoFrameBackgroundColor = Color.FromName ("#675831"); - ExceptionCaughtDialog.InfoFrameBorderColor = Color.FromName ("#7a6a3d"); - ExceptionCaughtDialog.LineNumberBackgroundColor = Color.FromName ("#c4c4c4"); - ExceptionCaughtDialog.LineNumberInUserCodeBackgroundColor = Color.FromName ("#e599de"); - ExceptionCaughtDialog.LineNumberTextColor = Color.FromName ("#222222"); + ExceptionCaughtDialog.LineNumberTextColor = Color.FromName ("#888888"); + ExceptionCaughtDialog.ExternalCodeTextColor = Color.FromName ("#888888"); } // Shared @@ -96,8 +96,6 @@ namespace MonoDevelop.Debugger PreviewVisualizerBackgroundColor = Ide.Gui.Styles.PopoverWindow.DefaultBackgroundColor; PreviewVisualizerTextColor = Ide.Gui.Styles.PopoverWindow.DefaultTextColor; PreviewVisualizerHeaderTextColor = Ide.Gui.Styles.PopoverWindow.DefaultTextColor; - - ExceptionCaughtDialog.TreeBackgroundColor = Ide.Gui.Styles.PrimaryBackgroundColor; } } } diff --git a/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16.png b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16.png Binary files differnew file mode 100644 index 0000000000..684db7eeba --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16.png diff --git a/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16@2x.png b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16@2x.png Binary files differnew file mode 100644 index 0000000000..cb91f054c9 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16@2x.png diff --git a/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16~dark.png b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16~dark.png Binary files differnew file mode 100644 index 0000000000..b7602f3a76 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16~dark.png diff --git a/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16~dark@2x.png b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16~dark@2x.png Binary files differnew file mode 100644 index 0000000000..660fbc5e61 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/icons/exception-outline-16~dark@2x.png diff --git a/main/src/addins/MonoDevelop.Debugger/icons/toolbar-icon.png b/main/src/addins/MonoDevelop.Debugger/icons/toolbar-icon.png Binary files differnew file mode 100644 index 0000000000..de457dabea --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/icons/toolbar-icon.png diff --git a/main/src/addins/MonoDevelop.Debugger/icons/toolbar-icon@2x.png b/main/src/addins/MonoDevelop.Debugger/icons/toolbar-icon@2x.png Binary files differnew file mode 100644 index 0000000000..02371299b1 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/icons/toolbar-icon@2x.png diff --git a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml index da0c3b2c3f..79e44b12f0 100644 --- a/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml +++ b/main/src/addins/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.addin.xml @@ -41,6 +41,7 @@ class = "MonoDevelop.DesignerSupport.ToolboxPad" _label="Toolbox" icon = "md-toolbox-pad" + group = "Designer" defaultLayout="*" defaultPlacement="Right" defaultStatus="AutoHide" @@ -49,6 +50,7 @@ class = "MonoDevelop.DesignerSupport.PropertyPad" _label="Properties" icon = "md-properties-pad" + group = "Designer" defaultLayout="*" defaultPlacement="MonoDevelop.DesignerSupport.ToolboxPad/bottom; right" defaultStatus="AutoHide" @@ -57,6 +59,7 @@ class = "MonoDevelop.DesignerSupport.DocumentOutlinePad" _label="Document Outline" icon="md-pad-document-outline" + group = "Designer" defaultLayout="*" defaultPlacement="MonoDevelop.DesignerSupport.PropertyPad/center; bottom" defaultStatus="AutoHide" @@ -93,15 +96,18 @@ </Extension> <Extension path = "/MonoDevelop/Ide/Commands"> + <Category _name = "Designer" id = "Designer"> <Command id = "MonoDevelop.DesignerSupport.Commands.SelectItems" defaultHandler = "MonoDevelop.DesignerSupport.SelectItemsCommandHandler" - _label = "Add Items..." /> + _label = "Add Items..." + _displayName = "Add Toolbox Items..." /> <Command id = "MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles" _label = "Switch between related files " _description = "Switch between related files, such as CodeBehind, headers, etc." defaultHandler="MonoDevelop.DesignerSupport.SwitchBetweenRelatedFilesCommand" shortcut="Control|Alt|Up" macShortcut="Control|Meta|Up" /> + </Category> </Extension> <Extension path="/MonoDevelop/Ide/ContextMenu/DocumentTab"> diff --git a/main/src/addins/MonoDevelop.DocFood/DocFood.addin.xml b/main/src/addins/MonoDevelop.DocFood/DocFood.addin.xml index 7178a45275..3d202c480a 100644 --- a/main/src/addins/MonoDevelop.DocFood/DocFood.addin.xml +++ b/main/src/addins/MonoDevelop.DocFood/DocFood.addin.xml @@ -10,7 +10,8 @@ _label = "Document this" /> --> <Command id = "MonoDevelop.DocFood.Commands.DocumentBuffer" defaultHandler = "MonoDevelop.DocFood.DocumentBufferHandler" - _label = "Document Buffer" /> + _label = "Documentation _Comments" + _displayName = "Insert Documentation Comments" /> </Extension> @@ -19,7 +20,7 @@ </Extension> - <Extension path = "/MonoDevelop/Ide/MainMenu/Edit"> + <Extension path = "/MonoDevelop/Ide/MainMenu/Edit/Insert"> <!-- <CommandItem id="MonoDevelop.DocFood.Commands.DocumentThis" /> --> <CommandItem id="MonoDevelop.DocFood.Commands.DocumentBuffer" insertafter = "MonoDevelop.Ide.Commands.EditCommands.InsertStandardHeader"/> </Extension> diff --git a/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml b/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml index c96b5172ae..7402d5ba8c 100644 --- a/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml +++ b/main/src/addins/MonoDevelop.DocFood/DocFood.config.xml @@ -321,16 +321,16 @@ <Section name="remarks" override="true">Call ${Member} when you are finished using the ${DeclaringType}. The ${Member} method leaves the ${DeclaringType} in an unusable state. After calling ${Member}, you must release all references to the ${DeclaringType} so the garbage collector can reclaim the memory that the ${DeclaringType} was occupying.</Section> </Case> - <Case name = "Equals" paramCount="1" returns="System.Boolean"> + <Case name = "Equals" paramCount="1" returns="bool"> <Section name="summary" override="true">Determines whether the specified ${Parameter0.Type} is equal to the current ${DeclaringType}.</Section> <Section name="param0" override="true">The ${Parameter0.Type} to compare with the current ${DeclaringType}.</Section> <Section name="returns" override="true">${True} if the specified ${Parameter0.Type} is equal to the current ${DeclaringType}; otherwise, ${False}.</Section> </Case> - <Case name = "GetHashCode" paramCount="0" returns="System.Int32"> + <Case name = "GetHashCode" paramCount="0" returns="int"> <Section name="summary" override="true">Serves as a hash function for a ${DeclaringType} object.</Section> <Section name="returns" override="true">A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a hash table.</Section> </Case> - <Case name = "ToString" paramCount="0" returns="System.String"> + <Case name = "ToString" paramCount="0" returns="string"> <Section name="summary" override="true">Returns a ${ReturnType} that represents the current ${DeclaringType}.</Section> <Section name="returns" override="true">A ${ReturnType} that represents the current ${DeclaringType}.</Section> </Case> @@ -340,7 +340,7 @@ <If paramCount="1"> <Section name="param0">The command-line arguments.</Section> </If> - <If returns="System.Int32"> + <If returns="int"> <Section name="returns">The exit code that is given to the operating system after the program ends.</Section> </If> </Case> @@ -354,7 +354,7 @@ </Case> <Case endsWith="At,Between"> <Section name="summary">${Sentence} ${ParameterList}.</Section> - <IfNot returns="System.Void"> + <IfNot returns="void"> <Section name="returns">The ${ReturnType}.</Section> </IfNot> </Case> @@ -366,11 +366,11 @@ <Section name="summary">${Sentence}.</Section> </IfNot> <Switch> - <Case returns="System.Boolean"> + <Case returns="bool"> <Section name="returns">${True}, if ${AllWordsExceptFirst} was ${FirstAsVerbPastParticiple}, ${False} otherwise.</Section> </Case> <Default> - <IfNot returns="System.Void"> + <IfNot returns="void"> <Section name="returns">The ${AllWordsExceptFirst}.</Section> </IfNot> </Default> @@ -459,7 +459,7 @@ </Default> </Switch> </Case> - <Case returns="System.Boolean"> + <Case returns="bool"> <If wordCount="1"> <Section name="summary">${AccessText} a value indicating whether this ${DeclaringType} is ${AllWords}.</Section> <Section name="value">${True} if ${AllWords}; otherwise, ${False}.</Section> @@ -478,7 +478,7 @@ <Case type="parameter"> <Switch> - <Case returns="System.Boolean"> + <Case returns="bool"> <Section name="param">If set to ${True} ${AllWords}.</Section> </Case> <Case endsWith="EventArgs"> diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml index 3132051581..4c42bffbb9 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.addin.xml @@ -57,7 +57,7 @@ </Extension> <Extension path = "/MonoDevelop/Ide/Commands"> - <Category _name = "Gtk# Designer" id = "GtkCore"> + <Category _name = "Designer (Gtk#)" id = "GtkCore"> <Command id = "MonoDevelop.GtkCore.GtkCommands.AddNewDialog" icon = "md-gtkcore-dialog" _label = "New Dialog..." /> @@ -75,7 +75,7 @@ <Command id = "MonoDevelop.GtkCore.GtkCommands.EditIcons" _label = "Edit Project Icons..." /> <Command id = "MonoDevelop.GtkCore.GtkCommands.GtkSettings" - _label = "GTK# support settings..." /> + _label = "GTK# Support Settings..." /> </Category> </Extension> diff --git a/main/src/addins/MonoDevelop.PackageManagement/AddinInfo.cs b/main/src/addins/MonoDevelop.PackageManagement/AddinInfo.cs index 6b768fe71c..e5fe7e2d31 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/AddinInfo.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/AddinInfo.cs @@ -9,7 +9,7 @@ using Mono.Addins.Description; Category = "IDE extensions")]
[assembly:AddinName ("NuGet Package Management")]
-[assembly:AddinDescription ("Provides support for adding and maintaining NuGet packages in your project. Uses NuGet 2.8.7")]
+[assembly:AddinDescription ("Provides support for adding and maintaining NuGet packages in your project.")]
[assembly:AddinDependency ("Core", MonoDevelop.BuildInfo.Version)]
[assembly:AddinDependency ("Ide", MonoDevelop.BuildInfo.Version)]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs b/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs index 57b9b48471..77a9a55cea 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/AssemblyInfo.cs @@ -7,9 +7,6 @@ using System.Runtime.CompilerServices; [assembly: AssemblyDescription("NuGet addin for MonoDevelop")]
[assembly: AssemblyVersion ("1.0")]
[assembly: AssemblyCopyright ("MIT X11")]
-[assembly: InternalsVisibleTo ("MonoDevelop.MonoDroid")]
[assembly: InternalsVisibleTo ("MonoDevelop.PackageManagement.Cmdlets")]
[assembly: InternalsVisibleTo ("MonoDevelop.PackageManagement.Extensions")]
[assembly: InternalsVisibleTo ("MonoDevelop.PackageManagement.Tests")]
-[assembly: InternalsVisibleTo ("Xamarin.Ide")]
-[assembly: InternalsVisibleTo ("Xamarin.Ide.Insights")]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ManagePackagesHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ManagePackagesHandler.cs deleted file mode 100644 index a5a36004f2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ManagePackagesHandler.cs +++ /dev/null @@ -1,50 +0,0 @@ -//
-// ManagePackagesHandler.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement.Commands
-{
- internal class ManagePackagesHandler : PackagesCommandHandler
- {
- protected override void Run ()
- {
- try {
- var viewModels = new PackageManagementViewModels ();
- IPackageManagementEvents packageEvents = PackageManagementServices.PackageManagementEvents;
- using (var dialog = new ManagePackagesDialog (viewModels.ManagePackagesViewModel, packageEvents))
- MessageService.ShowCustomDialog (dialog);
- } catch (Exception ex) {
- LoggingService.LogInternalError (ex);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageManagementStartupHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageManagementStartupHandler.cs index d7c72eabcd..601713a65f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageManagementStartupHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageManagementStartupHandler.cs @@ -26,6 +26,7 @@ using System;
using System.Linq;
+using System.Threading.Tasks;
using MonoDevelop.Components.Commands;
using MonoDevelop.Core;
using MonoDevelop.Ide;
@@ -37,26 +38,23 @@ namespace MonoDevelop.PackageManagement.Commands {
protected override void Run ()
{
+ ClearUpdatedPackages ();
IdeApp.Workspace.SolutionLoaded += SolutionLoaded;
IdeApp.Workspace.SolutionUnloaded += SolutionUnloaded;
IdeApp.Workspace.ItemUnloading += WorkspaceItemUnloading;
+ IdeApp.Workspace.LastWorkspaceItemClosed += LastWorkspaceItemClosed;
}
- void SolutionLoaded (object sender, SolutionEventArgs e)
+ async void SolutionLoaded (object sender, SolutionEventArgs e)
{
- ClearUpdatedPackagesInSolution ();
-
- if (ShouldRestorePackages) {
- RestoreAndCheckForUpdates (e.Solution);
- } else if (ShouldCheckForUpdates && AnyProjectHasPackages (e.Solution)) {
- // Use background dispatch even though the check is not done on the
- // background dispatcher thread so that the solution load completes before
- // the check for updates starts. Otherwise the check for updates finishes
- // before the solution loads and the status bar never reports that
- // package updates were being checked.
- PackageManagementBackgroundDispatcher.Dispatch (() => {
- CheckForUpdates ();
- });
+ try {
+ if (ShouldRestorePackages) {
+ await RestoreAndCheckForUpdates (e.Solution);
+ } else if (ShouldCheckForUpdates && AnyProjectHasPackages (e.Solution)) {
+ CheckForUpdates (e.Solution);
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("PackageManagementStartupHandler error", ex);
}
}
@@ -68,29 +66,40 @@ namespace MonoDevelop.PackageManagement.Commands get { return PackageManagementServices.Options.IsCheckForPackageUpdatesOnOpeningSolutionEnabled; }
}
- void ClearUpdatedPackagesInSolution ()
+ void ClearUpdatedPackagesInSolution (Solution solution)
{
- PackageManagementServices.UpdatedPackagesInSolution.Clear ();
+ PackageManagementServices.UpdatedPackagesInWorkspace.Clear (new SolutionProxy (solution));
+ }
+
+ void ClearUpdatedPackages ()
+ {
+ PackageManagementServices.UpdatedPackagesInWorkspace.Clear ();
}
void SolutionUnloaded (object sender, SolutionEventArgs e)
{
- ClearUpdatedPackagesInSolution ();
+ ClearUpdatedPackagesInSolution (e.Solution);
+ }
+
+ void LastWorkspaceItemClosed (object sender, EventArgs e)
+ {
+ ClearUpdatedPackages ();
}
- void RestoreAndCheckForUpdates (Solution solution)
+ async Task RestoreAndCheckForUpdates (Solution solution)
{
bool checkUpdatesAfterRestore = ShouldCheckForUpdates && AnyProjectHasPackages (solution);
- var packageManagementSolution = new PackageManagementSolution (new PackageManagementSolutionProjectService (solution));
- var restorer = new PackageRestorer (packageManagementSolution);
- PackageManagementBackgroundDispatcher.Dispatch (() => {
- restorer.Restore ();
- if (checkUpdatesAfterRestore && !restorer.RestoreFailed) {
- CheckForUpdates ();
- }
- restorer = null;
- });
+ var action = new RestoreAndCheckForUpdatesAction (solution) {
+ CheckForUpdatesAfterRestore = checkUpdatesAfterRestore
+ };
+ bool packagesToRestore = await action.HasMissingPackages ();
+ if (packagesToRestore) {
+ ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage ();
+ PackageManagementServices.BackgroundPackageActionRunner.Run (message, action);
+ } else if (checkUpdatesAfterRestore) {
+ CheckForUpdates (solution);
+ }
}
bool AnyProjectHasPackages (Solution solution)
@@ -100,10 +109,15 @@ namespace MonoDevelop.PackageManagement.Commands .Any ();
}
- void CheckForUpdates ()
+ void CheckForUpdates (Solution solution)
+ {
+ CheckForUpdates (new SolutionProxy (solution));
+ }
+
+ void CheckForUpdates (ISolution solution)
{
try {
- PackageManagementServices.UpdatedPackagesInSolution.CheckForUpdates ();
+ PackageManagementServices.UpdatedPackagesInWorkspace.CheckForUpdates (solution);
} catch (Exception ex) {
LoggingService.LogError ("Check for NuGet package updates error.", ex);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageReferenceNodeCommandHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageReferenceNodeCommandHandler.cs index 1b95ecafc6..aaa7c92eb5 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageReferenceNodeCommandHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackageReferenceNodeCommandHandler.cs @@ -51,23 +51,25 @@ namespace MonoDevelop.PackageManagement.Commands void RemovePackage (PackageReferenceNode packageReferenceNode, ProgressMonitorStatusMessage progressMessage)
{
- IPackageManagementProject project = PackageManagementServices.Solution.GetProject (packageReferenceNode.Project);
- UninstallPackageAction action = project.CreateUninstallPackageAction ();
- action.Package = project.FindPackage (packageReferenceNode.Id);
-
- if (action.Package != null) {
- PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, action);
- } else {
- ShowMissingPackageError (progressMessage, packageReferenceNode);
+ IPackageAction action = CreateUninstallPackageAction (packageReferenceNode);
+ PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, action);
+ } +
+ IPackageAction CreateUninstallPackageAction (PackageReferenceNode packageReferenceNode) + { + var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (packageReferenceNode.Project.ParentSolution);
+ if (packageReferenceNode.NeedsRestoreBeforeUninstall ()) {
+ return new RestoreAndUninstallNuGetPackageAction (solutionManager, packageReferenceNode.Project) {
+ PackageId = packageReferenceNode.Id,
+ Version = packageReferenceNode.Version
+ };
}
- }
- void ShowMissingPackageError (ProgressMonitorStatusMessage progressMessage, PackageReferenceNode packageReferenceNode)
- {
- string message = GettextCatalog.GetString ("Unable to find package {0} {1} to remove it from the project. Please restore the package first.", packageReferenceNode.Id, packageReferenceNode.Version);
- PackageManagementServices.BackgroundPackageActionRunner.ShowError (progressMessage, message);
+ return new UninstallNuGetPackageAction (solutionManager, packageReferenceNode.Project) {
+ PackageId = packageReferenceNode.Id
+ };
}
-
+ [CommandUpdateHandler (EditCommands.Delete)]
public void UpdateRemoveItem (CommandInfo info)
{
@@ -86,23 +88,21 @@ namespace MonoDevelop.PackageManagement.Commands var packageReferenceNode = (PackageReferenceNode)CurrentNode.DataItem;
try {
- IPackageManagementProject project = PackageManagementServices.Solution.GetProject (packageReferenceNode.Project);
- ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingSinglePackageMessage (packageReferenceNode.Id, project);
- UpdatePackageAction action = project.CreateUpdatePackageAction ();
- action.PackageId = packageReferenceNode.Id;
- action.AllowPrereleaseVersions = !packageReferenceNode.IsReleaseVersion ();
-
- IPackageManagementSolution solution = GetPackageManagementSolution ();
- RestoreBeforeUpdateAction.Restore (solution, project, () => {
- UpdatePackage (progressMessage, action);
- });
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (packageReferenceNode.Project.ParentSolution);
+ var action = new UpdateNuGetPackageAction (solutionManager, packageReferenceNode.Project) {
+ PackageId = packageReferenceNode.Id,
+ IncludePrerelease = !packageReferenceNode.IsReleaseVersion ()
+ };
+
+ ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingSinglePackageMessage (packageReferenceNode.Id, packageReferenceNode.Project);
+ UpdatePackage (progressMessage, action);
} catch (Exception ex) {
ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingSinglePackageMessage (packageReferenceNode.Id);
PackageManagementServices.BackgroundPackageActionRunner.ShowError (progressMessage, ex);
}
}
- void UpdatePackage (ProgressMonitorStatusMessage progressMessage, UpdatePackageAction action)
+ void UpdatePackage (ProgressMonitorStatusMessage progressMessage, IPackageAction action)
{
try {
PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, action);
@@ -142,15 +142,6 @@ namespace MonoDevelop.PackageManagement.Commands }
return IdeApp.ProjectOperations.CurrentSelectedSolution;
}
-
- IPackageManagementSolution GetPackageManagementSolution ()
- {
- Solution solution = GetSelectedSolution ();
- if (solution != null) {
- return new PackageManagementSolution (new PackageManagementSolutionProjectService (solution));
- }
- return null;
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesCommandHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesCommandHandler.cs index ae58f73082..ae891a4a54 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesCommandHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesCommandHandler.cs @@ -90,7 +90,7 @@ namespace MonoDevelop.PackageManagement.Commands return false;
}
- Solution GetSelectedSolution ()
+ protected Solution GetSelectedSolution ()
{
DotNetProject project = GetSelectedDotNetProject ();
if (project != null) {
@@ -98,14 +98,5 @@ namespace MonoDevelop.PackageManagement.Commands }
return IdeApp.ProjectOperations.CurrentSelectedSolution;
}
-
- protected IPackageManagementSolution GetPackageManagementSolution ()
- {
- Solution solution = GetSelectedSolution ();
- if (solution != null) {
- return new PackageManagementSolution (new PackageManagementSolutionProjectService (solution));
- }
- return null;
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesFolderNodeCommands.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesFolderNodeCommands.cs new file mode 100644 index 0000000000..4ce6b3e156 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/PackagesFolderNodeCommands.cs @@ -0,0 +1,34 @@ +//
+// PackagesFolderNodeCommands.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Commands
+{
+ internal enum PackagesFolderNodeCommands
+ {
+ ReinstallAllPackagesInProject
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ProjectPackagesFolderNodeCommandHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ProjectPackagesFolderNodeCommandHandler.cs index 5113aa6e27..b0b0a7b585 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ProjectPackagesFolderNodeCommandHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ProjectPackagesFolderNodeCommandHandler.cs @@ -25,7 +25,12 @@ // THE SOFTWARE.
using System;
+using System.Collections.Generic;
+using System.Linq;
+using MonoDevelop.Components.Commands;
using MonoDevelop.Ide.Gui.Components;
+using MonoDevelop.PackageManagement.NodeBuilders;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement.Commands
{
@@ -36,6 +41,62 @@ namespace MonoDevelop.PackageManagement.Commands var runner = new AddPackagesDialogRunner ();
runner.Run ();
}
+
+ [CommandUpdateHandler (PackagesFolderNodeCommands.ReinstallAllPackagesInProject)]
+ void UpdateReinstallPackages (CommandInfo info)
+ {
+ var packagesFolderNode = (ProjectPackagesFolderNode)CurrentNode.DataItem;
+ info.Visible = packagesFolderNode.AnyPackageReferencesRequiringReinstallation ();
+ }
+
+ [CommandHandler (PackagesFolderNodeCommands.ReinstallAllPackagesInProject)]
+ public void ReinstallPackages ()
+ {
+ try {
+ var packagesFolderNode = (ProjectPackagesFolderNode)CurrentNode.DataItem;
+ List<ReinstallNuGetPackageAction> reinstallActions = CreateReinstallActions (packagesFolderNode).ToList ();
+ ProgressMonitorStatusMessage progressMessage = CreateProgressMessage (reinstallActions);
+ PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, reinstallActions);
+ } catch (Exception ex) {
+ ShowStatusBarError (ex);
+ }
+ }
+
+ IEnumerable<ReinstallNuGetPackageAction> CreateReinstallActions (ProjectPackagesFolderNode packagesFolderNode)
+ {
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (packagesFolderNode.Project.ParentSolution);
+
+ return packagesFolderNode.GetPackageReferencesNodes ()
+ .Select (packageReferenceNode => CreateReinstallPackageAction (packageReferenceNode, solutionManager));
+ }
+
+ ReinstallNuGetPackageAction CreateReinstallPackageAction (
+ PackageReferenceNode packageReference,
+ IMonoDevelopSolutionManager solutionManager)
+ {
+ var action = new ReinstallNuGetPackageAction (
+ packageReference.Project,
+ solutionManager);
+
+ action.PackageId = packageReference.Id;
+ action.Version = packageReference.Version;
+
+ return action;
+ }
+
+ ProgressMonitorStatusMessage CreateProgressMessage (IEnumerable<ReinstallNuGetPackageAction> actions)
+ {
+ if (actions.Count () == 1) {
+ return ProgressMonitorStatusMessageFactory.CreateRetargetingSinglePackageMessage (actions.First ().PackageId);
+ }
+ return ProgressMonitorStatusMessageFactory.CreateRetargetingPackagesInProjectMessage (actions.Count ());
+ }
+
+ void ShowStatusBarError (Exception ex)
+ {
+ ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRetargetingPackagesInProjectMessage ();
+ PackageManagementServices.BackgroundPackageActionRunner.ShowError (message, ex);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ReinstallAllPackagesInProjectHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ReinstallAllPackagesInProjectHandler.cs deleted file mode 100644 index 8a3e452544..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/ReinstallAllPackagesInProjectHandler.cs +++ /dev/null @@ -1,98 +0,0 @@ -//
-// ReinstallAllPackagesInProjectHandler.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.PackageManagement.NodeBuilders;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Commands
-{
- internal class ReinstallAllPackagesInProjectHandler : PackagesCommandHandler
- {
- protected override void Run ()
- {
- try {
- IPackageManagementProject project = PackageManagementServices.Solution.GetActiveProject ();
- List<ReinstallPackageAction> reinstallActions = CreateReinstallActions (project).ToList ();
- ProgressMonitorStatusMessage progressMessage = CreateProgressMessage (reinstallActions);
- PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, reinstallActions);
- } catch (Exception ex) {
- ShowStatusBarError (ex);
- }
- }
-
- IEnumerable<ReinstallPackageAction> CreateReinstallActions (IPackageManagementProject project)
- {
- var packageReferenceFile = new ProjectPackageReferenceFile (project.DotNetProject);
- return packageReferenceFile.GetPackageReferences ()
- .Select (packageReference => CreateReinstallPackageAction (project, packageReference));
- }
-
- ReinstallPackageAction CreateReinstallPackageAction (IPackageManagementProject project, PackageReference packageReference)
- {
- ReinstallPackageAction action = project.CreateReinstallPackageAction ();
- action.PackageId = packageReference.Id;
- action.PackageVersion = packageReference.Version;
-
- return action;
- }
-
- ProgressMonitorStatusMessage CreateProgressMessage (IEnumerable<ReinstallPackageAction> actions)
- {
- if (actions.Count () == 1) {
- return ProgressMonitorStatusMessageFactory.CreateRetargetingSinglePackageMessage (actions.First ().PackageId);
- }
- return ProgressMonitorStatusMessageFactory.CreateRetargetingPackagesInProjectMessage (actions.Count ());
- }
-
- void ShowStatusBarError (Exception ex)
- {
- ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRetargetingPackagesInProjectMessage ();
- PackageManagementServices.BackgroundPackageActionRunner.ShowError (message, ex);
- }
-
- protected override void Update (CommandInfo info)
- {
- info.Visible = SelectedDotNetProjectHasPackagesRequiringReinstall ();
- }
-
- bool SelectedDotNetProjectHasPackagesRequiringReinstall ()
- {
- DotNetProject project = GetSelectedDotNetProject ();
- if (project == null)
- return false;
-
- var packageReferenceFile = new ProjectPackageReferenceFile (project);
- return packageReferenceFile.AnyPackagesToBeReinstalled ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesHandler.cs index 8d34126269..038d16a8a0 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesHandler.cs @@ -26,6 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
using MonoDevelop.Components.Commands;
namespace MonoDevelop.PackageManagement.Commands
@@ -34,16 +35,24 @@ namespace MonoDevelop.PackageManagement.Commands {
protected override void Run ()
{
- var runner = new PackageRestoreRunner (GetPackageManagementSolution ());
- PackageManagementBackgroundDispatcher.Dispatch (() => {
- runner.Run ();
- runner = null;
- });
+ try {
+ ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage ();
+ var action = new RestoreNuGetPackagesAction (GetSelectedSolution ());
+ PackageManagementServices.BackgroundPackageActionRunner.Run (message, action);
+ } catch (Exception ex) {
+ ShowStatusBarError (ex);
+ }
}
protected override void Update (CommandInfo info)
{
info.Enabled = SelectedDotNetProjectOrSolutionHasPackages ();
}
+
+ void ShowStatusBarError (Exception ex)
+ {
+ ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage ();
+ PackageManagementServices.BackgroundPackageActionRunner.ShowError (message, ex);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesInProjectHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesInProjectHandler.cs index 3f2fc07199..fc30d9ddda 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesInProjectHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/RestorePackagesInProjectHandler.cs @@ -24,8 +24,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+using System;
using MonoDevelop.Components.Commands;
using MonoDevelop.Projects;
+using NuGet.ProjectManagement.Projects;
namespace MonoDevelop.PackageManagement.Commands
{
@@ -33,31 +35,37 @@ namespace MonoDevelop.PackageManagement.Commands {
protected override void Run ()
{
- IDotNetProject project = GetSelectedProject ();
- if (project == null)
- return;
+ try {
+ ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInProjectMessage ();
+ IPackageAction action = CreateRestorePackagesAction (GetSelectedDotNetProject ());
+ PackageManagementServices.BackgroundPackageActionRunner.Run (message, action);
+ } catch (Exception ex) {
+ ShowStatusBarError (ex);
+ }
+ }
- ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInProjectMessage ();
- var runner = new PackageRestoreRunner (GetPackageManagementSolution ());
- PackageManagementBackgroundDispatcher.Dispatch (() => {
- runner.Run (project, progressMessage);
- runner = null;
- project = null;
- });
+ protected override void Update (CommandInfo info)
+ {
+ info.Enabled = SelectedDotNetProjectHasPackages ();
}
- IDotNetProject GetSelectedProject ()
+ IPackageAction CreateRestorePackagesAction (DotNetProject project)
{
- DotNetProject project = GetSelectedDotNetProject ();
- if (project != null) {
- return new DotNetProjectProxy (project);
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution);
+ var nugetProject = solutionManager.GetNuGetProject (new DotNetProjectProxy (project));
+
+ var buildIntegratedProject = nugetProject as BuildIntegratedNuGetProject;
+ if (buildIntegratedProject != null) {
+ return new RestoreNuGetPackagesInNuGetIntegratedProject (project, buildIntegratedProject, solutionManager);
}
- return null;
+
+ return new RestoreNuGetPackagesInProjectAction (project, nugetProject, solutionManager);
}
- protected override void Update (CommandInfo info)
+ void ShowStatusBarError (Exception ex)
{
- info.Enabled = SelectedDotNetProjectOrSolutionHasPackages ();
+ ProgressMonitorStatusMessage message = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInProjectMessage ();
+ PackageManagementServices.BackgroundPackageActionRunner.ShowError (message, ex);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs index d56cabf8a7..4244eac709 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInProjectHandler.cs @@ -25,12 +25,7 @@ // THE SOFTWARE. using System;
-using System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Ide;
-using MonoDevelop.Core; +using MonoDevelop.Components.Commands; namespace MonoDevelop.PackageManagement.Commands
{
@@ -39,34 +34,20 @@ namespace MonoDevelop.PackageManagement.Commands protected override void Run ()
{
try { - IPackageManagementSolution solution = GetPackageManagementSolution ();
- IPackageManagementProject project = PackageManagementServices.Solution.GetActiveProject ();
- RestoreBeforeUpdateAction.Restore (solution, project, () => {
- Runtime.RunInMainThread (() => Update (project)).Wait ();
- });
+ Update ();
} catch (Exception ex) {
ShowStatusBarError (ex);
}
- }
-
- void Update (IPackageManagementProject project)
- {
- try {
- var updateAllPackages = new UpdateAllPackagesInProject (project);
- List<UpdatePackageAction> updateActions = updateAllPackages.CreateActions ().ToList ();
- ProgressMonitorStatusMessage progressMessage = CreateProgressMessage (updateActions, project);
- PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, updateActions);
- } catch (Exception ex) {
- ShowStatusBarError (ex);
- }
- }
-
- ProgressMonitorStatusMessage CreateProgressMessage (List<UpdatePackageAction> updateActions, IPackageManagementProject project)
- {
- if (updateActions.Count == 1) {
- return ProgressMonitorStatusMessageFactory.CreateUpdatingSinglePackageMessage (updateActions.First ().PackageId, project);
- }
- return ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInProjectMessage (updateActions.Count, project);
+ } + + void Update () + { + var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (GetSelectedSolution ()); + var project = GetSelectedDotNetProject (); + var action = new UpdateAllNuGetPackagesInProjectAction (solutionManager, project); + + var progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInProjectMessage (new DotNetProjectProxy (project)); + PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, action); }
void ShowStatusBarError (Exception ex)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs index 710470aff6..5d3b941620 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Commands/UpdateAllPackagesInSolutionHandler.cs @@ -27,8 +27,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using MonoDevelop.Components.Commands;
-using MonoDevelop.Core; +using MonoDevelop.Components.Commands; namespace MonoDevelop.PackageManagement.Commands
{
@@ -37,35 +36,20 @@ namespace MonoDevelop.PackageManagement.Commands protected override void Run ()
{
try { - IPackageManagementSolution solution = GetPackageManagementSolution ();
- UpdateAllPackagesInSolution updateAllPackages = CreateUpdateAllPackagesInSolution (solution);
- ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage (updateAllPackages.Projects);
- RestoreBeforeUpdateAction.Restore (solution, updateAllPackages.Projects, () => {
- Runtime.RunInMainThread (() => {
- Update (updateAllPackages, progressMessage);
- }).Wait ();
- });
+ Update ();
} catch (Exception ex) {
ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage ();
PackageManagementServices.BackgroundPackageActionRunner.ShowError (progressMessage, ex);
}
- }
-
- void Update (UpdateAllPackagesInSolution updateAllPackages, ProgressMonitorStatusMessage progressMessage)
- {
- try {
- List<UpdatePackageAction> updateActions = updateAllPackages.CreateActions ().ToList ();
- PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, updateActions);
- } catch (Exception ex) {
- PackageManagementServices.BackgroundPackageActionRunner.ShowError (progressMessage, ex);
- }
- }
-
- UpdateAllPackagesInSolution CreateUpdateAllPackagesInSolution (IPackageManagementSolution solution)
- {
- return new UpdateAllPackagesInSolution (
- solution,
- PackageManagementServices.PackageRepositoryCache.CreateAggregateRepository ());
+ } + + void Update () + { + var updateAllPackages = new UpdateAllNuGetPackagesInSolution (GetSelectedSolution ()); + List<IPackageAction> updateActions = updateAllPackages.CreateActions ().ToList (); + + ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateUpdatingPackagesInSolutionMessage (updateAllPackages.GetProjects ()); + PackageManagementServices.BackgroundPackageActionRunner.Run (progressMessage, updateActions); }
protected override void Update (CommandInfo info)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.UI.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.UI.cs index 31dab786d6..b845a39d11 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.UI.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.UI.cs @@ -38,6 +38,7 @@ namespace MonoDevelop.PackageManagement PasswordEntry packageSourcePasswordTextEntry;
DialogButton addPackageSourceButton;
DialogButton savePackageSourceButton;
+ Button browseButton;
void Build ()
{
@@ -66,13 +67,18 @@ namespace MonoDevelop.PackageManagement mainVBox.PackStart (packageSourceUrlHBox);
var packageSourceUrlLabel = new Label ();
- packageSourceUrlLabel.Text = GettextCatalog.GetString ("URL");
+ packageSourceUrlLabel.Text = GettextCatalog.GetString ("Location");
packageSourceUrlLabel.TextAlignment = Alignment.End;
packageSourceUrlLabel.WidthRequest = labelWidth;
packageSourceUrlHBox.PackStart (packageSourceUrlLabel);
packageSourceUrlTextEntry = new TextEntry ();
- packageSourceUrlHBox.PackEnd (packageSourceUrlTextEntry, true);
+ packageSourceUrlTextEntry.PlaceholderText = GettextCatalog.GetString ("URL or folder");
+ packageSourceUrlHBox.PackStart (packageSourceUrlTextEntry, true);
+
+ browseButton = new Button ();
+ browseButton.Label = GettextCatalog.GetString ("_Browse...");
+ packageSourceUrlHBox.PackStart (browseButton);
// Package source username.
var packageSourceUserNameHBox = new HBox ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.cs index a101cc2b88..4bec748745 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackageSourceDialog.cs @@ -25,7 +25,6 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Core;
namespace MonoDevelop.PackageManagement
@@ -33,6 +32,7 @@ namespace MonoDevelop.PackageManagement internal partial class AddPackageSourceDialog
{
RegisteredPackageSourcesViewModel viewModel;
+ bool ignoreChanges;
public AddPackageSourceDialog (RegisteredPackageSourcesViewModel viewModel)
{
@@ -42,6 +42,7 @@ namespace MonoDevelop.PackageManagement addPackageSourceButton.Clicked += AddPackageSourceButtonClicked;
savePackageSourceButton.Clicked += SavePackageSourceButtonClicked;
+ browseButton.Clicked += BrowseButtonClicked;
packageSourceNameTextEntry.Changed += PackageSourceNameTextBoxChanged;
packageSourceNameTextEntry.Activated += TextEntryActivated;
@@ -85,12 +86,18 @@ namespace MonoDevelop.PackageManagement void PackageSourceNameTextBoxChanged (object sender, EventArgs e)
{
+ if (ignoreChanges)
+ return;
+
viewModel.NewPackageSourceName = packageSourceNameTextEntry.Text;
UpdateAddPackageSourceButton ();
}
void PackageSourceUrlTextBoxChanged (object sender, EventArgs e)
{
+ if (ignoreChanges)
+ return;
+
viewModel.NewPackageSourceUrl = packageSourceUrlTextEntry.Text;
UpdateAddPackageSourceButton ();
}
@@ -133,6 +140,24 @@ namespace MonoDevelop.PackageManagement Close ();
}
}
+
+ void BrowseButtonClicked (object sender, EventArgs e)
+ {
+ if (viewModel.BrowsePackageFolder ()) {
+ UpdateAfterFolderSelected ();
+ }
+ }
+
+ void UpdateAfterFolderSelected ()
+ {
+ ignoreChanges = true;
+
+ packageSourceNameTextEntry.Text = viewModel.NewPackageSourceName;
+ packageSourceUrlTextEntry.Text = viewModel.NewPackageSourceUrl;
+ UpdateAddPackageSourceButton ();
+
+ ignoreChanges = false;
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.UI.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.UI.cs index 912ed31c8c..8900fcd2bf 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.UI.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.UI.cs @@ -41,7 +41,6 @@ namespace MonoDevelop.PackageManagement ListView packagesListView;
VBox packageInfoVBox;
Label packageNameLabel;
- Label packageVersionLabel;
LinkLabel packageIdLink;
Label packageDescription;
Label packageAuthor;
@@ -50,6 +49,7 @@ namespace MonoDevelop.PackageManagement LinkLabel packageLicenseLink;
LinkLabel packageProjectPageLink;
Label packageDependenciesList;
+ HBox packageDependenciesHBox;
HBox packageDependenciesListHBox;
Label packageDependenciesNoneLabel;
CheckBox showPrereleaseCheckBox;
@@ -60,6 +60,8 @@ namespace MonoDevelop.PackageManagement Label errorMessageLabel;
Label loadingSpinnerLabel;
FrameBox noPackagesFoundFrame;
+ ComboBox packageVersionComboBox;
+ HBox packageVersionsHBox;
int packageInfoFontSize = 11;
void Build ()
@@ -79,6 +81,7 @@ namespace MonoDevelop.PackageManagement topHBox.Margin = new WidgetSpacing (8, 5, 6, 5);
packageSourceComboBox = new ComboBox ();
+ packageSourceComboBox.Name = "packageSourceComboBox";
packageSourceComboBox.MinWidth = 200;
topHBox.PackStart (packageSourceComboBox);
@@ -182,7 +185,6 @@ namespace MonoDevelop.PackageManagement packageInfoScrollViewFrame.BorderWidth = new WidgetSpacing (1, 0, 0, 0);
packageInfoScrollViewFrame.BorderColor = Styles.LineBorderColor;
packageInfoScrollViewFrame.Content = packageInfoScrollView;
- middleHBox.PackEnd (packageInfoScrollViewFrame);
// Package name and version.
var packageNameHBox = new HBox ();
@@ -194,11 +196,6 @@ namespace MonoDevelop.PackageManagement packageNameLabel.Font = packageInfoSmallFont;
packageNameHBox.PackStart (packageNameLabel, true);
- packageVersionLabel = new Label ();
- packageVersionLabel.TextAlignment = Alignment.End;
- packageVersionLabel.Font = packageInfoSmallFont;
- packageNameHBox.PackEnd (packageVersionLabel);
-
// Package description.
packageDescription = new Label ();
packageDescription.Wrap = WrapMode.Word;
@@ -297,7 +294,7 @@ namespace MonoDevelop.PackageManagement packageProjectPageHBox.PackEnd (packageProjectPageLink);
// Package dependencies
- var packageDependenciesHBox = new HBox ();
+ packageDependenciesHBox = new HBox ();
packageInfoVBox.PackStart (packageDependenciesHBox);
var packageDependenciesLabel = new Label ();
@@ -321,6 +318,28 @@ namespace MonoDevelop.PackageManagement packageDependenciesList.Font = packageInfoSmallFont;
packageDependenciesListHBox.PackStart (packageDependenciesList, true);
+ // Package versions.
+ packageVersionsHBox = new HBox ();
+ packageVersionsHBox.Visible = false;
+ packageVersionsHBox.BackgroundColor = Styles.PackageInfoBackgroundColor;
+ packageVersionsHBox.Margin = new WidgetSpacing (15, 0, 15, 12);
+ var packageVersionsLabel = new Label ();
+ packageVersionsLabel.Font = packageInfoSmallFont;
+ packageVersionsLabel.Markup = Catalog.GetString ("<b>Version</b>");
+ packageVersionsHBox.PackStart (packageVersionsLabel);
+
+ packageVersionComboBox = new ComboBox ();
+ packageVersionComboBox.Name = "packageVersionComboBox";
+ packageVersionsHBox.Spacing = 15;
+ packageVersionsHBox.PackStart (packageVersionComboBox, true, true);
+
+ var packageInfoAndVersionsVBox = new VBox ();
+ packageInfoAndVersionsVBox.Margin = new WidgetSpacing ();
+ packageInfoAndVersionsVBox.BackgroundColor = Styles.PackageInfoBackgroundColor;
+ packageInfoAndVersionsVBox.PackStart (packageInfoScrollViewFrame, true, true);
+ packageInfoAndVersionsVBox.PackStart (packageVersionsHBox, false, false);
+ middleHBox.PackEnd (packageInfoAndVersionsVBox);
+
// Bottom part of dialog:
// Show pre-release packages and Close/Add to Project buttons.
var bottomHBox = new HBox ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs index b8b239eaeb..f4609d9f98 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialog.cs @@ -26,18 +26,15 @@ using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
-using MonoDevelop.PackageManagement;
using Mono.Unix;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using MonoDevelop.Projects;
-using NuGet;
+using NuGet.Versioning;
using Xwt;
using Xwt.Drawing;
-using Xwt.Formats;
using PropertyChangedEventArgs = System.ComponentModel.PropertyChangedEventArgs;
namespace MonoDevelop.PackageManagement
@@ -45,12 +42,10 @@ namespace MonoDevelop.PackageManagement internal partial class AddPackagesDialog
{
IBackgroundPackageActionRunner backgroundActionRunner;
- IRecentPackageRepository recentPackageRepository;
- ManagePackagesViewModel parentViewModel;
- PackagesViewModel viewModel;
- List<PackageSource> packageSources;
+ AllPackagesViewModel viewModel;
+ List<SourceRepositoryViewModel> packageSources;
DataField<bool> packageHasBackgroundColorField = new DataField<bool> ();
- DataField<PackageViewModel> packageViewModelField = new DataField<PackageViewModel> ();
+ DataField<PackageSearchResultViewModel> packageViewModelField = new DataField<PackageSearchResultViewModel> ();
DataField<Image> packageImageField = new DataField<Image> ();
DataField<double> packageCheckBoxAlphaField = new DataField<double> ();
const double packageCheckBoxSemiTransarentAlpha = 0.6;
@@ -58,31 +53,32 @@ namespace MonoDevelop.PackageManagement PackageCellView packageCellView;
TimeSpan searchDelayTimeSpan = TimeSpan.FromMilliseconds (500);
IDisposable searchTimer;
- PackageSource dummyPackageSourceRepresentingConfigureSettingsItem =
- new PackageSource ("", Catalog.GetString ("Configure Sources..."));
+ SourceRepositoryViewModel dummyPackageSourceRepresentingConfigureSettingsItem =
+ new SourceRepositoryViewModel (Catalog.GetString ("Configure Sources..."));
ImageLoader imageLoader = new ImageLoader ();
bool loadingMessageVisible;
+ bool ignorePackageVersionChanges;
const string IncludePrereleaseUserPreferenceName = "NuGet.AddPackagesDialog.IncludePrerelease";
+ TimeSpan populatePackageVersionsDelayTimeSpan = TimeSpan.FromMilliseconds (500);
+ int packageVersionsAddedCount;
+ IDisposable populatePackageVersionsTimer;
+ const int MaxVersionsToPopulate = 100;
- public AddPackagesDialog (ManagePackagesViewModel parentViewModel, string initialSearch = null)
+ public AddPackagesDialog (AllPackagesViewModel viewModel, string initialSearch = null)
: this (
- parentViewModel,
+ viewModel,
initialSearch,
- PackageManagementServices.BackgroundPackageActionRunner,
- PackageManagementServices.RecentPackageRepository)
+ PackageManagementServices.BackgroundPackageActionRunner)
{
}
public AddPackagesDialog (
- ManagePackagesViewModel parentViewModel,
+ AllPackagesViewModel viewModel,
string initialSearch,
- IBackgroundPackageActionRunner backgroundActionRunner,
- IRecentPackageRepository recentPackageRepository)
+ IBackgroundPackageActionRunner backgroundActionRunner)
{
- this.parentViewModel = parentViewModel;
- this.viewModel = parentViewModel.AvailablePackagesViewModel;
+ this.viewModel = viewModel;
this.backgroundActionRunner = backgroundActionRunner;
- this.recentPackageRepository = recentPackageRepository;
Build ();
@@ -98,6 +94,7 @@ namespace MonoDevelop.PackageManagement this.addPackagesButton.Clicked += AddPackagesButtonClicked;
this.packageSearchEntry.Changed += PackageSearchEntryChanged;
this.packageSearchEntry.Activated += PackageSearchEntryActivated;
+ this.packageVersionComboBox.SelectionChanged += PackageVersionChanged;
imageLoader.Loaded += ImageLoaded;
}
@@ -108,12 +105,13 @@ namespace MonoDevelop.PackageManagement imageLoader.Loaded -= ImageLoaded;
imageLoader.Dispose ();
+ RemoveSelectedPackagePropertyChangedEventHandler ();
viewModel.PropertyChanged -= ViewModelPropertyChanged;
- parentViewModel.Dispose ();
+ viewModel.Dispose ();
DisposeExistingTimer ();
+ DisposePopulatePackageVersionsTimer ();
packageStore.Clear ();
viewModel = null;
- parentViewModel = null;
base.Dispose (disposing);
}
@@ -222,7 +220,6 @@ namespace MonoDevelop.PackageManagement void LoadViewModel (string initialSearch)
{
- viewModel.ClearPackagesOnPaging = false;
viewModel.SearchTerms = initialSearch;
viewModel.IncludePrerelease = GetIncludePrereleaseUserPreference ();
@@ -242,9 +239,18 @@ namespace MonoDevelop.PackageManagement void ClearSelectedPackageInformation ()
{
this.packageInfoVBox.Visible = false;
+ this.packageVersionsHBox.Visible = false;
}
- List<PackageSource> PackageSources {
+ void RemoveSelectedPackagePropertyChangedEventHandler ()
+ {
+ if (viewModel.SelectedPackage != null) {
+ viewModel.SelectedPackage.PropertyChanged -= SelectedPackageViewModelChanged;
+ viewModel.SelectedPackage = null;
+ }
+ }
+
+ List<SourceRepositoryViewModel> PackageSources {
get {
if (packageSources == null) {
packageSources = viewModel.PackageSources.ToList ();
@@ -255,7 +261,7 @@ namespace MonoDevelop.PackageManagement void PopulatePackageSources ()
{
- foreach (PackageSource packageSource in PackageSources) {
+ foreach (SourceRepositoryViewModel packageSource in PackageSources) {
AddPackageSourceToComboBox (packageSource);
}
@@ -264,22 +270,14 @@ namespace MonoDevelop.PackageManagement packageSourceComboBox.SelectedItem = viewModel.SelectedPackageSource;
}
- void AddPackageSourceToComboBox (PackageSource packageSource)
- {
- packageSourceComboBox.Items.Add (packageSource, GetPackageSourceName (packageSource));
- }
-
- string GetPackageSourceName (PackageSource packageSource)
+ void AddPackageSourceToComboBox (SourceRepositoryViewModel packageSource)
{
- if (packageSource.IsAggregate ()) {
- return Catalog.GetString ("All Sources");
- }
- return packageSource.Name;
+ packageSourceComboBox.Items.Add (packageSource, packageSource.Name);
}
void PackageSourceChanged (object sender, EventArgs e)
{
- var selectedPackageSource = (PackageSource)packageSourceComboBox.SelectedItem;
+ var selectedPackageSource = (SourceRepositoryViewModel)packageSourceComboBox.SelectedItem;
if (selectedPackageSource == dummyPackageSourceRepresentingConfigureSettingsItem) {
ShowPreferencesForPackageSources = true;
Close ();
@@ -300,16 +298,19 @@ namespace MonoDevelop.PackageManagement void ShowSelectedPackage ()
{
- PackageViewModel packageViewModel = GetSelectedPackageViewModel ();
+ RemoveSelectedPackagePropertyChangedEventHandler ();
+
+ PackageSearchResultViewModel packageViewModel = GetSelectedPackageViewModel ();
if (packageViewModel != null) {
ShowPackageInformation (packageViewModel);
} else {
ClearSelectedPackageInformation ();
}
+ viewModel.SelectedPackage = packageViewModel;
UpdateAddPackagesButton ();
}
- PackageViewModel GetSelectedPackageViewModel ()
+ PackageSearchResultViewModel GetSelectedPackageViewModel ()
{
if (packagesListView.SelectedRow != -1) {
return packageStore.GetValue (packagesListView.SelectedRow, packageViewModelField);
@@ -317,11 +318,10 @@ namespace MonoDevelop.PackageManagement return null;
}
- void ShowPackageInformation (PackageViewModel packageViewModel)
+ void ShowPackageInformation (PackageSearchResultViewModel packageViewModel)
{
this.packageNameLabel.Markup = packageViewModel.GetNameMarkup ();
- this.packageVersionLabel.Text = packageViewModel.Version.ToString ();
- this.packageAuthor.Text = packageViewModel.GetAuthors ();
+ this.packageAuthor.Text = packageViewModel.Author;
this.packagePublishedDate.Text = packageViewModel.GetLastPublishedDisplayText ();
this.packageDownloads.Text = packageViewModel.GetDownloadCountDisplayText ();
this.packageDescription.Text = packageViewModel.Description;
@@ -330,13 +330,18 @@ namespace MonoDevelop.PackageManagement ShowUri (this.packageIdLink, packageViewModel.GalleryUrl, packageViewModel.Id);
ShowUri (this.packageProjectPageLink, packageViewModel.ProjectUrl);
ShowUri (this.packageLicenseLink, packageViewModel.LicenseUrl);
- this.packageDependenciesListHBox.Visible = packageViewModel.HasDependencies;
- this.packageDependenciesNoneLabel.Visible = !packageViewModel.HasDependencies;
- this.packageDependenciesList.Text = packageViewModel.GetPackageDependenciesDisplayText ();
+
+ PopulatePackageDependencies (packageViewModel);
+
+ PopulatePackageVersions (packageViewModel);
this.packageInfoVBox.Visible = true;
- }
+ this.packageVersionsHBox.Visible = true;
+ packageViewModel.PropertyChanged += SelectedPackageViewModelChanged;
+ viewModel.LoadPackageMetadata (packageViewModel);
+ }
+ void ShowUri (LinkLabel linkLabel, Uri uri, string label)
{
linkLabel.Text = label;
@@ -393,6 +398,7 @@ namespace MonoDevelop.PackageManagement UpdatePackageListViewSelectionColor ();
ShowLoadingMessage ();
ShrinkImageCache ();
+ DisposePopulatePackageVersionsTimer ();
}
void ResetPackagesListViewScroll ()
@@ -422,7 +428,7 @@ namespace MonoDevelop.PackageManagement bool packagesListViewWasEmpty = (packageStore.RowCount == 0);
for (int row = packageStore.RowCount; row < viewModel.PackageViewModels.Count; ++row) {
- PackageViewModel packageViewModel = viewModel.PackageViewModels [row];
+ PackageSearchResultViewModel packageViewModel = viewModel.PackageViewModels [row];
AppendPackageToListView (packageViewModel);
LoadPackageImage (row, packageViewModel);
}
@@ -436,7 +442,7 @@ namespace MonoDevelop.PackageManagement }
}
- void AppendPackageToListView (PackageViewModel packageViewModel)
+ void AppendPackageToListView (PackageSearchResultViewModel packageViewModel)
{
int row = packageStore.AddRow ();
packageStore.SetValue (row, packageHasBackgroundColorField, IsOddRow (row));
@@ -444,23 +450,13 @@ namespace MonoDevelop.PackageManagement packageStore.SetValue (row, packageViewModelField, packageViewModel);
}
- void LoadPackageImage (int row, PackageViewModel packageViewModel)
+ void LoadPackageImage (int row, PackageSearchResultViewModel packageViewModel)
{
if (packageViewModel.HasIconUrl) {
- // Workaround: Image loading is incorrectly being done on GUI thread
- // since the wrong synchronization context seems to be used. So
- // here we switch to a background thread and then back to the GUI thread.
- Task.Run (() => LoadImage (packageViewModel.IconUrl, row));
+ imageLoader.LoadFrom (packageViewModel.IconUrl, row);
}
}
- void LoadImage (Uri iconUrl, int row)
- {
- // Put it back on the GUI thread so the correct synchronization context
- // is used. The image loading will be done on a background thread.
- Runtime.RunInMainThread (() => imageLoader.LoadFrom (iconUrl, row));
- }
-
bool IsOddRow (int row)
{
return (row % 2) == 0;
@@ -487,7 +483,7 @@ namespace MonoDevelop.PackageManagement bool IsValidRowAndUrl (int row, Uri uri)
{
if (row < packageStore.RowCount) {
- PackageViewModel packageViewModel = packageStore.GetValue (row, packageViewModelField);
+ PackageSearchResultViewModel packageViewModel = packageStore.GetValue (row, packageViewModelField);
if (packageViewModel != null) {
return uri == packageViewModel.IconUrl;
}
@@ -509,24 +505,17 @@ namespace MonoDevelop.PackageManagement void InstallPackages (List<IPackageAction> packageActions)
{
if (packageActions.Count > 0) {
- AddRecentPackages (packageActions);
-
ProgressMonitorStatusMessage progressMessage = GetProgressMonitorStatusMessages (packageActions);
backgroundActionRunner.Run (progressMessage, packageActions);
- Close ();
- }
- }
- void AddRecentPackages (List<IPackageAction> packageActions)
- {
- foreach (InstallPackageAction action in packageActions.OfType<InstallPackageAction> ()) {
- recentPackageRepository.AddPackage (action.Package);
+ viewModel.OnInstallingSelectedPackages ();
+ Close ();
}
}
List<IPackageAction> CreateInstallPackageActionsForSelectedPackages ()
{
- List<PackageViewModel> packageViewModels = GetSelectedPackageViewModels ();
+ List<PackageSearchResultViewModel> packageViewModels = GetSelectedPackageViewModels ();
if (packageViewModels.Count > 0) {
return CreateInstallPackageActions (packageViewModels);
}
@@ -536,7 +525,7 @@ namespace MonoDevelop.PackageManagement ProgressMonitorStatusMessage GetProgressMonitorStatusMessages (List<IPackageAction> packageActions)
{
if (packageActions.Count == 1) {
- string packageId = packageActions.OfType<ProcessPackageAction> ().First ().Package.Id;
+ string packageId = packageActions.OfType<INuGetPackageAction> ().First ().PackageId;
if (OlderPackageInstalledThanPackageSelected ()) {
return ProgressMonitorStatusMessageFactory.CreateUpdatingSinglePackageMessage (packageId);
}
@@ -545,23 +534,23 @@ namespace MonoDevelop.PackageManagement return ProgressMonitorStatusMessageFactory.CreateInstallingMultiplePackagesMessage (packageActions.Count);
}
- List<PackageViewModel> GetSelectedPackageViewModels ()
+ List<PackageSearchResultViewModel> GetSelectedPackageViewModels ()
{
- List<PackageViewModel> packageViewModels = viewModel.CheckedPackageViewModels.ToList ();
+ List<PackageSearchResultViewModel> packageViewModels = viewModel.CheckedPackageViewModels.ToList ();
if (packageViewModels.Count > 0) {
return packageViewModels;
}
- PackageViewModel selectedPackageViewModel = GetSelectedPackageViewModel ();
+ PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel ();
if (selectedPackageViewModel != null) {
packageViewModels.Add (selectedPackageViewModel);
}
return packageViewModels;
}
- List<IPackageAction> CreateInstallPackageActions (IEnumerable<PackageViewModel> packageViewModels)
+ List<IPackageAction> CreateInstallPackageActions (IEnumerable<PackageSearchResultViewModel> packageViewModels)
{
- return packageViewModels.Select (viewModel => viewModel.CreateInstallPackageAction ()).ToList ();
+ return packageViewModels.Select (packageViewModel => viewModel.CreateInstallPackageAction (packageViewModel)).ToList ();
}
void PackageSearchEntryChanged (object sender, EventArgs e)
@@ -588,7 +577,7 @@ namespace MonoDevelop.PackageManagement bool Search ()
{
viewModel.SearchTerms = this.packageSearchEntry.Text;
- viewModel.SearchCommand.Execute (null);
+ viewModel.Search ();
return false;
}
@@ -598,16 +587,17 @@ namespace MonoDevelop.PackageManagement if (PackagesCheckedCount > 0) {
AddPackagesButtonClicked (sender, e);
} else {
- PackageViewModel packageViewModel = packageStore.GetValue (e.RowIndex, packageViewModelField);
+ PackageSearchResultViewModel packageViewModel = packageStore.GetValue (e.RowIndex, packageViewModelField);
InstallPackage (packageViewModel);
}
}
- void InstallPackage (PackageViewModel packageViewModel)
+ void InstallPackage (PackageSearchResultViewModel packageViewModel)
{
try {
if (packageViewModel != null) {
- List<IPackageAction> packageActions = CreateInstallPackageActions (new PackageViewModel [] { packageViewModel });
+ List<IPackageAction> packageActions = CreateInstallPackageActions (
+ new PackageSearchResultViewModel [] { packageViewModel });
InstallPackages (packageActions);
}
} catch (Exception ex) {
@@ -624,7 +614,7 @@ namespace MonoDevelop.PackageManagement if (PackagesCheckedCount > 0) {
AddPackagesButtonClicked (sender, e);
} else {
- PackageViewModel selectedPackageViewModel = GetSelectedPackageViewModel ();
+ PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel ();
InstallPackage (selectedPackageViewModel);
}
}
@@ -660,13 +650,22 @@ namespace MonoDevelop.PackageManagement void UpdateAddPackagesButton ()
{
- string label = Catalog.GetPluralString ("Add Package", "Add Packages", PackagesCheckedCount);
+ string label = Catalog.GetPluralString ("Add Package", "Add Packages", GetPackagesCountForAddPackagesButtonLabel ());
if (PackagesCheckedCount <= 1 && OlderPackageInstalledThanPackageSelected ()) {
label = Catalog.GetString ("Update Package");
}
+ addPackagesButton.Label = label;
addPackagesButton.Sensitive = IsAddPackagesButtonEnabled ();
}
+ int GetPackagesCountForAddPackagesButtonLabel ()
+ {
+ if (PackagesCheckedCount > 1)
+ return PackagesCheckedCount;
+
+ return 1;
+ }
+
void UpdatePackageListViewSelectionColor ()
{
packageCellView.UseStrongSelectionColor = (PackagesCheckedCount == 0);
@@ -689,7 +688,7 @@ namespace MonoDevelop.PackageManagement return false;
}
- PackageViewModel selectedPackageViewModel = GetSelectedPackageViewModel ();
+ PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel ();
if (selectedPackageViewModel != null) {
return selectedPackageViewModel.IsOlderPackageInstalled ();
}
@@ -709,5 +708,113 @@ namespace MonoDevelop.PackageManagement int PackagesCheckedCount {
get { return viewModel.CheckedPackageViewModels.Count; }
}
+
+ void SelectedPackageViewModelChanged (object sender, PropertyChangedEventArgs e)
+ {
+ try {
+ if (e.PropertyName == "Versions") {
+ PopulatePackageVersions (viewModel.SelectedPackage);
+ } else {
+ packagePublishedDate.Text = viewModel.SelectedPackage.GetLastPublishedDisplayText ();
+ PopulatePackageDependencies (viewModel.SelectedPackage);
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("Error loading package versions.", ex);
+ }
+ }
+
+ void PopulatePackageVersions (PackageSearchResultViewModel packageViewModel)
+ {
+ DisposePopulatePackageVersionsTimer ();
+
+ ignorePackageVersionChanges = true;
+ try {
+ packageVersionComboBox.Items.Clear ();
+ if (packageViewModel.Versions.Any ()) {
+ int count = 0;
+ foreach (NuGetVersion version in packageViewModel.Versions) {
+ count++;
+ if (count > MaxVersionsToPopulate) {
+ packageVersionsAddedCount = count - 1;
+ if (version >= packageViewModel.SelectedVersion) {
+ AddPackageVersionToComboBox (packageViewModel.SelectedVersion);
+ }
+ PopulatePackageVersionsAfterDelay ();
+ break;
+ }
+ AddPackageVersionToComboBox (version);
+ }
+ } else {
+ AddPackageVersionToComboBox (packageViewModel.Version);
+ }
+ packageVersionComboBox.SelectedItem = packageViewModel.SelectedVersion;
+ } finally {
+ ignorePackageVersionChanges = false;
+ }
+ }
+
+ void AddPackageVersionToComboBox (NuGetVersion version)
+ {
+ packageVersionComboBox.Items.Add (version, version.ToString ());
+ }
+
+ void PackageVersionChanged (object sender, EventArgs e)
+ {
+ if (ignorePackageVersionChanges || viewModel.SelectedPackage == null)
+ return;
+
+ viewModel.SelectedPackage.SelectedVersion = (NuGetVersion)packageVersionComboBox.SelectedItem;
+ UpdateAddPackagesButton ();
+ }
+
+ void PopulatePackageDependencies (PackageSearchResultViewModel packageViewModel)
+ {
+ if (packageViewModel.IsDependencyInformationAvailable) {
+ this.packageDependenciesHBox.Visible = true;
+ this.packageDependenciesListHBox.Visible = packageViewModel.HasDependencies;
+ this.packageDependenciesNoneLabel.Visible = !packageViewModel.HasDependencies;
+ this.packageDependenciesList.Text = packageViewModel.GetPackageDependenciesDisplayText ();
+ } else {
+ this.packageDependenciesHBox.Visible = false;
+ this.packageDependenciesListHBox.Visible = false;
+ this.packageDependenciesNoneLabel.Visible = false;
+ this.packageDependenciesList.Text = String.Empty;
+ }
+ }
+
+ void PopulatePackageVersionsAfterDelay ()
+ {
+ populatePackageVersionsTimer = Application.TimeoutInvoke (populatePackageVersionsDelayTimeSpan, PopulateMorePackageVersions);
+ }
+
+ void DisposePopulatePackageVersionsTimer ()
+ {
+ if (populatePackageVersionsTimer != null) {
+ populatePackageVersionsTimer.Dispose ();
+ populatePackageVersionsTimer = null;
+ }
+ }
+
+ bool PopulateMorePackageVersions ()
+ {
+ PackageSearchResultViewModel packageViewModel = viewModel?.SelectedPackage;
+ if (populatePackageVersionsTimer == null || packageViewModel == null) {
+ return false;
+ }
+
+ int count = 0;
+ foreach (NuGetVersion version in packageViewModel.Versions.Skip (packageVersionsAddedCount)) {
+ count++;
+
+ if (count > MaxVersionsToPopulate) {
+ packageVersionsAddedCount += count - 1;
+ return true;
+ }
+
+ AddPackageVersionToComboBox (version);
+ }
+
+ return false;
+ }
}
}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialogRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialogRunner.cs index 2c17e14bd9..f2626ffde6 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialogRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AddPackagesDialogRunner.cs @@ -25,19 +25,18 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Ide;
-using Xwt;
using MonoDevelop.Core;
namespace MonoDevelop.PackageManagement
{
internal class AddPackagesDialogRunner
{
+ static RecentNuGetPackagesRepository recentPackagesRepository = new RecentNuGetPackagesRepository ();
+
public void Run (string initialSearch = null)
{
try {
-
bool configurePackageSources = false;
do {
using (AddPackagesDialog dialog = CreateDialog (initialSearch)) {
@@ -57,9 +56,9 @@ namespace MonoDevelop.PackageManagement AddPackagesDialog CreateDialog (string initialSearch)
{
- var viewModels = new PackageManagementViewModels ();
+ var viewModel = AllPackagesViewModel.Create (recentPackagesRepository);
return new AddPackagesDialog (
- viewModels.ManagePackagesViewModel,
+ viewModel,
initialSearch);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/HyperlinkWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/HyperlinkWidget.cs deleted file mode 100644 index 43aede9353..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/HyperlinkWidget.cs +++ /dev/null @@ -1,78 +0,0 @@ -//
-// HyperlinkWidget.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 Gtk;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.PackageManagement
-{
- [System.ComponentModel.ToolboxItem(true)]
- internal partial class HyperlinkWidget : Gtk.Bin
- {
- LinkButton linkButton;
-
- public HyperlinkWidget (string uri, string label)
- {
- this.Build ();
- AddLinkButton (uri, label);
- }
-
- public HyperlinkWidget ()
- {
- this.Build ();
- AddLinkButton ();
- }
-
- void AddLinkButton (string uri = "", string label = "")
- {
- linkButton = new LinkButton (uri, label);
- linkButton.Relief = ReliefStyle.None;
- linkButton.CanFocus = false;
- linkButton.SetAlignment (0, 0);
- linkButton.Clicked += LinkButtonClicked;
- this.Add (linkButton);
- }
-
- void LinkButtonClicked (object sender, EventArgs e)
- {
- DesktopService.ShowUrl (linkButton.Uri);
- }
-
- public string Uri {
- get { return linkButton.Uri; }
- set { linkButton.Uri = value; }
- }
-
- public string Label {
- get { return linkButton.Label; }
- set { linkButton.Label = value; }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/LicenseAcceptanceDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/LicenseAcceptanceDialog.cs index e3ea8887c2..7f67ef1062 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/LicenseAcceptanceDialog.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/LicenseAcceptanceDialog.cs @@ -77,7 +77,7 @@ namespace MonoDevelop.PackageManagement return String.Format (
"<span weight='bold'>{0}</span>\t{1}\n<a href='{2}'>{3}</a>",
package.Id,
- package.GetAuthors (),
+ package.Author,
package.LicenseUrl,
GettextCatalog.GetString ("View License")
);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs deleted file mode 100644 index bc692b9745..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs +++ /dev/null @@ -1,134 +0,0 @@ -//
-// ManagePackagesDialog.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 Gtk;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement
-{
- internal partial class ManagePackagesDialog : Gtk.Dialog
- {
- ManagePackagesViewModel viewModel;
- IPackageManagementEvents packageManagementEvents;
- string messagesExpanderDefaultLabel;
-
- public ManagePackagesDialog (ManagePackagesViewModel viewModel, IPackageManagementEvents packageManagementEvents)
- {
- this.Build ();
- this.messagesExpanderDefaultLabel = messagesExpander.Label;
-
- this.viewModel = viewModel;
- this.packageManagementEvents = packageManagementEvents;
- AddPackageManagementEventHandlers ();
- LoadViewModels ();
- }
-
- void AddPackageManagementEventHandlers ()
- {
- packageManagementEvents.PackageOperationMessageLogged += PackageOperationMessageLogged;
- packageManagementEvents.PackageOperationError += PackageOperationError;
- packageManagementEvents.PackageOperationsStarting += PackageOperationsStarting;
- }
-
- void RemovePackageManagementEventHandlers ()
- {
- packageManagementEvents.PackageOperationMessageLogged -= PackageOperationMessageLogged;
- packageManagementEvents.PackageOperationError -= PackageOperationError;
- packageManagementEvents.PackageOperationsStarting -= PackageOperationsStarting;
- }
-
- void PackageOperationMessageLogged (object sender, PackageOperationMessageLoggedEventArgs e)
- {
- AppendMessage (e.Message.ToString ());
- }
-
- void PackageOperationError (object sender, PackageOperationExceptionEventArgs e)
- {
- messagesExpander.Label = e.Exception.Message;
- ResizeMessagesExpanderLabelWidthToFullDialogWidth ();
- AppendMessage (e.Exception.Message);
- }
-
- void PackageOperationsStarting (object sender, EventArgs e)
- {
- ResetMessageExpanderLabelWidthToDefault ();
- messagesExpander.Label = messagesExpanderDefaultLabel;
- }
-
- void AppendMessage (string message)
- {
- TextIter end = this.messagesTextView.Buffer.EndIter;
- this.messagesTextView.Buffer.Insert (ref end, message + "\n");
- }
-
- void LoadViewModels ()
- {
- this.Title = viewModel.Title;
-
- this.availablePackagesWidget.LoadViewModel (viewModel.AvailablePackagesViewModel);
- this.installedPackagesWidget.LoadViewModel (viewModel.InstalledPackagesViewModel);
- this.UpdatedPackagesWidget.LoadViewModel (viewModel.UpdatedPackagesViewModel);
- this.recentPackagesWidget.LoadViewModel (viewModel.RecentPackagesViewModel);
- }
-
- public override void Destroy ()
- {
- viewModel.Dispose ();
- RemovePackageManagementEventHandlers ();
- base.Destroy ();
- }
-
- void MessagesExpanderActivated (object sender, EventArgs e)
- {
- var child = this.VBox [this.messagesExpander] as Box.BoxChild;
- child.Expand = this.messagesExpander.Expanded;
- }
-
- void ResetMessageExpanderLabelWidthToDefault ()
- {
- messagesExpander.LabelWidget.WidthRequest = 0;
- }
-
- void ResizeMessagesExpanderLabelWidthToFullDialogWidth ()
- {
- var label = messagesExpander.LabelWidget as Label;
- label.WidthRequest = GetDialogWidth () - 30;
- label.Wrap = true;
- }
-
- int GetDialogWidth ()
- {
- int width;
- int height;
- GetSize (out width, out height);
- return width;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellView.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellView.cs index cb16c4ae39..765fa46a29 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellView.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellView.cs @@ -55,7 +55,7 @@ namespace MonoDevelop.PackageManagement }
}
- public IDataField<PackageViewModel> PackageField { get; set; }
+ public IDataField<PackageSearchResultViewModel> PackageField { get; set; }
public IDataField<Image> ImageField { get; set; }
public IDataField<bool> HasBackgroundColorField { get; set; }
public IDataField<double> CheckBoxAlphaField { get; set; }
@@ -72,7 +72,7 @@ namespace MonoDevelop.PackageManagement protected override void OnDraw (Context ctx, Rectangle cellArea)
{
- PackageViewModel packageViewModel = GetValue (PackageField);
+ PackageSearchResultViewModel packageViewModel = GetValue (PackageField);
if (packageViewModel == null) {
return;
}
@@ -161,7 +161,7 @@ namespace MonoDevelop.PackageManagement ctx.Fill ();
}
- void DrawCheckBox (Context ctx, PackageViewModel packageViewModel, Rectangle cellArea)
+ void DrawCheckBox (Context ctx, PackageSearchResultViewModel packageViewModel, Rectangle cellArea)
{
CreateCheckboxImages ();
@@ -285,7 +285,7 @@ namespace MonoDevelop.PackageManagement protected override void OnButtonPressed (ButtonEventArgs args)
{
- PackageViewModel packageViewModel = GetValue (PackageField);
+ PackageSearchResultViewModel packageViewModel = GetValue (PackageField);
if (packageViewModel == null) {
base.OnButtonPressed (args);
return;
@@ -300,7 +300,7 @@ namespace MonoDevelop.PackageManagement }
}
- void OnPackageChecked (PackageViewModel packageViewModel)
+ void OnPackageChecked (PackageSearchResultViewModel packageViewModel)
{
if (PackageChecked != null) {
PackageChecked (this, new PackageCellViewEventArgs (packageViewModel));
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellViewEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellViewEventArgs.cs index 32b9d14bef..20e7920ec9 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellViewEventArgs.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageCellViewEventArgs.cs @@ -25,18 +25,17 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
namespace MonoDevelop.PackageManagement
{
internal class PackageCellViewEventArgs : EventArgs
{
- public PackageCellViewEventArgs (PackageViewModel packageViewModel)
+ public PackageCellViewEventArgs (PackageSearchResultViewModel packageViewModel)
{
PackageViewModel = packageViewModel;
}
- public PackageViewModel PackageViewModel { get; private set; }
+ public PackageSearchResultViewModel PackageViewModel { get; private set; }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageLicenseWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageLicenseWidget.cs deleted file mode 100644 index 709e6c8314..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageLicenseWidget.cs +++ /dev/null @@ -1,58 +0,0 @@ -//
-// PackageLicenseWidget.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- [System.ComponentModel.ToolboxItem(true)]
- internal partial class PackageLicenseWidget : Gtk.Bin
- {
- public PackageLicenseWidget (PackageLicenseViewModel viewModel)
- {
- this.Build ();
- this.DisplayPackage (viewModel);
- }
-
- void DisplayPackage (PackageLicenseViewModel viewModel)
- {
- this.packageIdLabel.Markup = GetPackageIdMarkup (viewModel.Id);
- this.packageSummaryTextView.Buffer.Text = viewModel.Summary;
- this.licenseHyperlinkWidget.Uri = viewModel.LicenseUrl.ToString ();
- }
-
- string GetPackageIdMarkup (string id)
- {
- string format = "<span weight='bold'>{0}</span>";
- return MarkupString.Format (format, id);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsPanel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsPanel.cs index ac5c61c5f2..72e922cd6b 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsPanel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsPanel.cs @@ -26,9 +26,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using MonoDevelop.Components; -using MonoDevelop.PackageManagement; using MonoDevelop.Ide.Gui.Dialogs;
namespace MonoDevelop.PackageManagement.Gui
@@ -39,8 +37,7 @@ namespace MonoDevelop.PackageManagement.Gui public override Control CreatePanelWidget()
{
- var viewModels = new PackageManagementViewModels ();
- optionsViewModel = viewModels.PackageManagementOptionsViewModel;
+ optionsViewModel = new PackageManagementOptionsViewModel ();
return new PackageManagementOptionsWidget (optionsViewModel);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsWidget.cs index 521df0f699..8c7ffed1d3 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsWidget.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageManagementOptionsWidget.cs @@ -27,7 +27,6 @@ //
using System;
-using MonoDevelop.PackageManagement;
namespace MonoDevelop.PackageManagement
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourceCellRenderer.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourceCellRenderer.cs index b66eb067eb..69f35df07f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourceCellRenderer.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourceCellRenderer.cs @@ -109,7 +109,7 @@ namespace MonoDevelop.PackageManagement return MarkupString.Format (
"<b>{0}</b>\n<span foreground='{2}'>{1}</span>",
PackageSourceViewModel.Name,
- PackageSourceViewModel.SourceUrl,
+ PackageSourceViewModel.Source,
Ide.Gui.Styles.ColorGetHex (flags.HasFlag (CellRendererState.Selected) ? Styles.PackageSourceUrlSelectedTextColor : Styles.PackageSourceUrlTextColor));
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourcesOptionsPanel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourcesOptionsPanel.cs index 22f60668a9..9db8c9aaf3 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourcesOptionsPanel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackageSourcesOptionsPanel.cs @@ -30,8 +30,7 @@ using System; using System.Linq;
using System.IO;
using System.Security.Cryptography;
-using MonoDevelop.Components; -using MonoDevelop.PackageManagement;
+using MonoDevelop.Components;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using MonoDevelop.Ide.Gui.Dialogs;
@@ -40,15 +39,17 @@ namespace MonoDevelop.PackageManagement.Gui {
internal class PackageSourcesOptionsPanel : OptionsPanel
{
- PackageManagementViewModels viewModels;
+ RegisteredPackageSourcesViewModel viewModel;
PackageSourcesWidget packageSourcesWidget;
public override Control CreatePanelWidget()
{
- viewModels = new PackageManagementViewModels ();
- viewModels.RegisteredPackageSourcesViewModel.Load ();
+ var settings = SettingsLoader.LoadDefaultSettings (reportError: true);
+ var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider (settings);
+ viewModel = new RegisteredPackageSourcesViewModel (repositoryProvider);
+ viewModel.Load ();
- packageSourcesWidget = new PackageSourcesWidget (viewModels.RegisteredPackageSourcesViewModel);
+ packageSourcesWidget = new PackageSourcesWidget (viewModel);
return packageSourcesWidget;
}
@@ -92,8 +93,7 @@ namespace MonoDevelop.PackageManagement.Gui bool AnyPasswordsToBeEncrypted ()
{
- return viewModels
- .RegisteredPackageSourcesViewModel
+ return viewModel
.PackageSourceViewModels
.Any (packageSource => packageSource.HasPassword ());
}
@@ -125,11 +125,12 @@ namespace MonoDevelop.PackageManagement.Gui {
try {
if (packageSourcesWidget.HasPackageSourcesOrderChanged) {
- viewModels.RegisteredPackageSourcesViewModel.Save (
+ viewModel.Save (
packageSourcesWidget.GetOrderedPackageSources ());
} else {
- viewModels.RegisteredPackageSourcesViewModel.Save ();
+ viewModel.Save ();
}
+ PackageManagementServices.Workspace.ReloadSettings ();
} catch (Exception ex) {
LoggingService.LogError ("Unable to save NuGet.config changes", ex);
MessageService.ShowError (
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackagesWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackagesWidget.cs deleted file mode 100644 index 6412603bd3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PackagesWidget.cs +++ /dev/null @@ -1,325 +0,0 @@ -//
-// ManagePackagesDialog.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-
-using Gdk;
-using Gtk;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- [System.ComponentModel.ToolboxItem(true)]
- internal partial class PackagesWidget : Gtk.Bin
- {
- PackagesViewModel viewModel;
- List<PackageSource> packageSources;
- ListStore packageStore;
- CellRendererText treeViewColumnTextRenderer;
- const int PackageViewModelColumn = 2;
-
- public PackagesWidget ()
- {
- this.Build ();
- this.InitializeTreeView ();
- }
-
- void InitializeTreeView ()
- {
- packageStore = new ListStore (typeof (Pixbuf), typeof (string), typeof(PackageViewModel));
- packagesTreeView.Model = packageStore;
- packagesTreeView.AppendColumn (CreateTreeViewColumn ());
- packagesTreeView.Selection.Changed += PackagesTreeViewSelectionChanged;
- includePrereleaseCheckButton.Clicked += IncludePrereleaseCheckButtonClicked;
-
- AddSearchingMessageToTreeView ();
- }
-
- TreeViewColumn CreateTreeViewColumn ()
- {
- var column = new TreeViewColumn ();
-
- var iconRenderer = new CellRendererPixbuf ();
- column.PackStart (iconRenderer, false);
- column.AddAttribute (iconRenderer, "pixbuf", column: 0);
-
- treeViewColumnTextRenderer = new CellRendererText ();
- treeViewColumnTextRenderer.WrapMode = Pango.WrapMode.Word;
- treeViewColumnTextRenderer.WrapWidth = 250;
-
- column.PackStart (treeViewColumnTextRenderer, true);
- column.AddAttribute (treeViewColumnTextRenderer, "markup", column: 1);
-
- return column;
- }
-
- void AddSearchingMessageToTreeView ()
- {
- packageStore.AppendValues (
- ImageService.GetImage (Gtk.Stock.Info, IconSize.LargeToolbar),
- Mono.Unix.Catalog.GetString ("Searching..."),
- null);
- }
-
- void PackagesTreeViewSelectionChanged (object sender, EventArgs e)
- {
- ShowSelectedPackage ();
- }
-
- void IncludePrereleaseCheckButtonClicked (object sender, EventArgs e)
- {
- viewModel.IncludePrerelease = !viewModel.IncludePrerelease;
- }
-
- public void LoadViewModel (PackagesViewModel viewModel)
- {
- this.viewModel = viewModel;
-
- this.includePrereleaseCheckButton.Visible = viewModel.ShowPrerelease;
-
- this.packageSearchHBox.Visible = viewModel.IsSearchable;
- ClearSelectedPackageInformation ();
- PopulatePackageSources ();
- viewModel.PropertyChanged += ViewModelPropertyChanged;
-
- this.pagedResultsWidget.LoadPackagesViewModel (viewModel);
- this.pagedResultsHBox.Visible = viewModel.IsPaged;
-
- this.updateAllPackagesButtonBox.Visible = viewModel.IsUpdateAllPackagesEnabled;
- }
-
- List<PackageSource> PackageSources {
- get {
- if (packageSources == null) {
- packageSources = viewModel.PackageSources.ToList ();
- }
- return packageSources;
- }
- }
-
- void PopulatePackageSources ()
- {
- this.packageSourceComboBox.Visible = viewModel.ShowPackageSources;
- if (viewModel.ShowPackageSources) {
- for (int index = 0; index < PackageSources.Count; ++index) {
- PackageSource packageSource = PackageSources [index];
- this.packageSourceComboBox.InsertText (index, packageSource.Name);
- }
-
- this.packageSourceComboBox.Active = GetSelectedPackageSourceIndexFromViewModel ();
- }
- }
-
- int GetSelectedPackageSourceIndexFromViewModel ()
- {
- if (viewModel.SelectedPackageSource == null) {
- return -1;
- }
-
- return PackageSources.IndexOf (viewModel.SelectedPackageSource);
- }
-
- void PackageSourceChanged (object sender, EventArgs e)
- {
- viewModel.SelectedPackageSource = GetSelectedPackageSource ();
- }
-
- PackageSource GetSelectedPackageSource ()
- {
- if (this.packageSourceComboBox.Active == -1) {
- return null;
- }
-
- return PackageSources [this.packageSourceComboBox.Active];
- }
-
- void SearchButtonClicked (object sender, EventArgs e)
- {
- Search ();
- }
-
- void Search ()
- {
- viewModel.SearchTerms = this.packageSearchEntry.Text;
- viewModel.SearchCommand.Execute (null);
- }
-
- void ShowSelectedPackage ()
- {
- PackageViewModel packageViewModel = GetSelectedPackageViewModel ();
- if (packageViewModel != null) {
- ShowPackageInformation (packageViewModel);
- } else {
- ClearSelectedPackageInformation ();
- }
- }
-
- PackageViewModel GetSelectedPackageViewModel ()
- {
- TreeIter item;
- if (packagesTreeView.Selection.GetSelected (out item)) {
- return packageStore.GetValue (item, PackageViewModelColumn) as PackageViewModel;
- }
- return null;
- }
-
- void ShowPackageInformation (PackageViewModel packageViewModel)
- {
- this.packageVersionTextBox.Text = packageViewModel.Version.ToString ();
- this.packageCreatedByTextBox.Text = packageViewModel.GetAuthors ();
- this.packageLastUpdatedTextBox.Text = packageViewModel.GetLastPublishedDisplayText ();
- this.packageDownloadsTextBox.Text = packageViewModel.GetDownloadCountDisplayText ();
- this.packageDescriptionTextView.Buffer.Text = packageViewModel.Description;
- this.packageIdTextBox.Text = packageViewModel.Id;
- this.packageIdTextBox.Visible = packageViewModel.HasNoGalleryUrl;
- ShowUri (this.packageIdButton, packageViewModel.GalleryUrl, packageViewModel.Id);
- ShowUri (this.moreInformationButton, packageViewModel.ProjectUrl);
- ShowUri (this.viewLicenseTermsButton, packageViewModel.LicenseUrl);
- this.packageDependenciesListHBox.Visible = packageViewModel.HasDependencies;
- this.packageDependenciesNoneLabel.Visible = !packageViewModel.HasDependencies;
- this.packageDependenciesListLabel.Text = packageViewModel.GetPackageDependenciesDisplayText ();
-
- EnablePackageActionButtons (packageViewModel);
-
- this.packageInfoFrameVBox.Visible = true;
- this.managePackageButtonBox.Visible = true;
- }
-
- void ClearSelectedPackageInformation ()
- {
- this.packageInfoFrameVBox.Visible = false;
- this.managePackageButtonBox.Visible = false;
- }
-
- void ShowUri (HyperlinkWidget hyperlinkWidget, Uri uri, string label)
- {
- hyperlinkWidget.Label = label;
- ShowUri (hyperlinkWidget, uri);
- }
-
- void ShowUri (HyperlinkWidget hyperlinkWidget, Uri uri)
- {
- if (uri == null) {
- hyperlinkWidget.Visible = false;
- } else {
- hyperlinkWidget.Visible = true;
- hyperlinkWidget.Uri = uri.ToString ();
- }
- }
-
- void EnablePackageActionButtons (PackageViewModel packageViewModel)
- {
- this.addPackageButton.Visible = !packageViewModel.IsManaged;
- this.removePackageButton.Visible = !packageViewModel.IsManaged;
- this.managePackageButton.Visible = packageViewModel.IsManaged;
-
- this.addPackageButton.Sensitive = !packageViewModel.IsAdded;
- this.removePackageButton.Sensitive = packageViewModel.IsAdded;
- }
-
- void ViewModelPropertyChanged (object sender, PropertyChangedEventArgs e)
- {
- this.packageStore.Clear ();
-
- if (viewModel.HasError) {
- AddErrorToTreeView ();
- }
-
- if (viewModel.IsReadingPackages) {
- AddSearchingMessageToTreeView ();
- }
-
- foreach (PackageViewModel packageViewModel in viewModel.PackageViewModels) {
- AppendPackageToTreeView (packageViewModel);
- }
-
- this.pagedResultsHBox.Visible = viewModel.IsPaged;
- this.updateAllPackagesButtonBox.Visible = viewModel.IsUpdateAllPackagesEnabled;
- }
-
- void AddErrorToTreeView ()
- {
- packageStore.AppendValues (
- ImageService.GetImage (Gtk.Stock.DialogError, IconSize.LargeToolbar),
- viewModel.ErrorMessage,
- null);
- }
-
- void PackageSearchEntryActivated (object sender, EventArgs e)
- {
- Search ();
- }
-
- void AppendPackageToTreeView (PackageViewModel packageViewModel)
- {
- packageStore.AppendValues (
- ImageService.GetImage ("md-nuget-package", IconSize.Dnd),
- packageViewModel.GetDisplayTextMarkup (),
- packageViewModel);
- }
-
- void OnAddPackageButtonClicked (object sender, EventArgs e)
- {
- PackageViewModel packageViewModel = GetSelectedPackageViewModel ();
- packageViewModel.AddPackage ();
- EnablePackageActionButtons (packageViewModel);
- }
-
- void RemovePackageButtonClicked (object sender, EventArgs e)
- {
- PackageViewModel packageViewModel = GetSelectedPackageViewModel ();
- packageViewModel.RemovePackage ();
- EnablePackageActionButtons (packageViewModel);
- }
-
- void ManagePackagesButtonClicked (object sender, EventArgs e)
- {
- PackageViewModel packageViewModel = GetSelectedPackageViewModel ();
- packageViewModel.ManagePackage ();
- }
-
- void UpdateAllPackagesButtonClicked (object sender, EventArgs e)
- {
- viewModel.UpdateAllPackagesCommand.Execute (null);
- }
-
- protected override void OnDestroyed ()
- {
- if (viewModel != null) {
- viewModel.PropertyChanged -= ViewModelPropertyChanged;
- }
- base.OnDestroyed ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PagedResultsWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PagedResultsWidget.cs deleted file mode 100644 index ed5c2a3677..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/PagedResultsWidget.cs +++ /dev/null @@ -1,136 +0,0 @@ -//
-// PagedResultsWidget.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using Gtk;
-using MonoDevelop.PackageManagement;
-using System.ComponentModel;
-
-namespace MonoDevelop.PackageManagement
-{
- [System.ComponentModel.ToolboxItem(true)]
- internal partial class PagedResultsWidget : Gtk.Bin
- {
- PackagesViewModel viewModel;
- List<Button> buttons;
-
- public PagedResultsWidget ()
- {
- this.Build ();
- AddButtons ();
- }
-
- void AddButtons ()
- {
- buttons = new List<Button> ();
- buttons.AddRange (new [] {
- firstButton,
- secondButton,
- thirdButton,
- fourthButton,
- fifthButton
- });
- }
-
- public void LoadPackagesViewModel (PackagesViewModel viewModel)
- {
- this.viewModel = viewModel;
- this.viewModel.PropertyChanged += ViewModelPropertyChanged;
- }
-
- void ViewModelPropertyChanged (object sender, PropertyChangedEventArgs e)
- {
- UpdatePages ();
- }
-
- void UpdatePages ()
- {
- if (viewModel.IsPaged) {
- this.backButton.Visible = viewModel.HasPreviousPage;
- this.forwardButton.Visible = viewModel.HasNextPage;
- UpdateButtonPageNumbers ();
- }
- }
-
- void UpdateButtonPageNumbers ()
- {
- for (int index = 0; index < buttons.Count; ++index) {
- Button button = buttons [index];
- if (index < viewModel.Pages.Count) {
- Page page = viewModel.Pages [index];
- SetButtonPageNumber (button, page);
- } else {
- button.Visible = false;
- }
- }
- }
-
- void SetButtonPageNumber (Button button, Page page)
- {
- if (page.IsSelected) {
- string markup = String.Format ("<b>{0}</b>", page.Number);
- SetButtonText (button, markup);
- } else {
- SetButtonText (button, page.Number.ToString ());
- }
- }
-
- void SetButtonText (Button button, string markup)
- {
- Label label = (Label) button.Child;
- label.Markup = markup;
- }
-
- protected void BackButtonClicked (object sender, EventArgs e)
- {
- viewModel.ShowPreviousPage ();
- }
-
- protected void ForwardButtonClicked (object sender, EventArgs e)
- {
- viewModel.ShowNextPage ();
- }
-
- protected void PageButtonClicked (object sender, EventArgs e)
- {
- Button button = (Button) sender;
- int index = buttons.IndexOf (button);
- viewModel.ShowPage (viewModel.Pages [index].Number);
- }
-
- protected override void OnDestroyed ()
- {
- if (viewModel != null) {
- viewModel.PropertyChanged -= ViewModelPropertyChanged;
- }
- base.OnDestroyed ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/SelectProjectsDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/SelectProjectsDialog.cs deleted file mode 100644 index 7a22f46a72..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/SelectProjectsDialog.cs +++ /dev/null @@ -1,122 +0,0 @@ -//
-// SelectProjectsDialog.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using Gtk;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement
-{
- internal partial class SelectProjectsDialog : Gtk.Dialog
- {
- SelectProjectsViewModel viewModel;
- ListStore projectsStore;
- const int SelectedCheckBoxColumn = 0;
- const int SelectedProjectNameColumn = 1;
- const int SelectedProjectColumn = 2;
-
- public SelectProjectsDialog (SelectProjectsViewModel viewModel)
- {
- this.Build ();
- this.viewModel = viewModel;
- InitializeTreeView ();
- AddProjectsToTreeView ();
- }
-
- void InitializeTreeView ()
- {
- projectsStore = new ListStore (typeof (bool), typeof (string), typeof (IPackageManagementSelectedProject));
- projectsTreeView.Model = projectsStore;
- projectsTreeView.AppendColumn (CreateTreeViewColumn ());
- projectsTreeView.Selection.Changed += ProjectsTreeViewSelectionChanged;
- }
-
- TreeViewColumn CreateTreeViewColumn ()
- {
- var column = new TreeViewColumn ();
-
- var checkBoxRenderer = new CellRendererToggle ();
- checkBoxRenderer.Toggled += SelectedProjectCheckBoxToggled;
- column.PackStart (checkBoxRenderer, false);
- column.AddAttribute (checkBoxRenderer, "active", SelectedCheckBoxColumn);
-
- var textRenderer = new CellRendererText ();
- column.PackStart (textRenderer, true);
- column.AddAttribute (textRenderer, "markup", SelectedProjectNameColumn);
-
- return column;
- }
-
- void ProjectsTreeViewSelectionChanged (object sender, EventArgs e)
- {
- TreeIter iter;
- if (projectsTreeView.Selection.GetSelected (out iter)) {
- var project = projectsStore.GetValue (iter, SelectedProjectColumn) as IPackageManagementSelectedProject;
- if (!project.IsEnabled) {
- projectsTreeView.Selection.UnselectIter (iter);
- }
- }
- }
-
- void SelectedProjectCheckBoxToggled (object o, ToggledArgs args)
- {
- TreeIter iter;
- projectsStore.GetIterFromString (out iter, args.Path);
- var project = projectsStore.GetValue (iter, SelectedProjectColumn) as IPackageManagementSelectedProject;
- if (project.IsEnabled) {
- project.IsSelected = !project.IsSelected;
- projectsStore.SetValue (iter, SelectedCheckBoxColumn, project.IsSelected);
- }
- }
-
- void AddProjectsToTreeView ()
- {
- foreach (IPackageManagementSelectedProject project in viewModel.Projects) {
- AddProjectToTreeView (project);
- }
- }
-
- void AddProjectToTreeView (IPackageManagementSelectedProject project)
- {
- projectsStore.AppendValues (project.IsSelected, GetProjectNameMarkup (project), project);
- }
-
- string GetProjectNameMarkup (IPackageManagementSelectedProject project)
- {
- if (project.IsEnabled) {
- return project.Name;
- }
-
- string format = "<span foreground='lightgrey'>{0}</span>";
- return MarkupString.Format (format, project.Name);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNode.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNode.cs index 00bb8d682f..1e1bcd79ac 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNode.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNode.cs @@ -25,11 +25,13 @@ // THE SOFTWARE.
using System;
-using System.Runtime.Versioning;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Tasks;
-using NuGet;
+using NuGet.Frameworks;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
+using NuGet.Versioning;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
@@ -40,7 +42,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders PackageReference packageReference,
bool installed,
bool pending = false,
- IPackageName updatedPackage = null)
+ PackageIdentity updatedPackage = null)
{
ParentNode = parentNode;
PackageReference = packageReference;
@@ -51,7 +53,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders IsReinstallNeeded = packageReference.RequireReinstallation;
}
- SemanticVersion GetUpdatedPackageVersion (IPackageName updatedPackage)
+ NuGetVersion GetUpdatedPackageVersion (PackageIdentity updatedPackage)
{
if (updatedPackage != null) {
return updatedPackage.Version;
@@ -64,7 +66,6 @@ namespace MonoDevelop.PackageManagement.NodeBuilders public bool IsInstallPending { get; private set; }
public bool IsReinstallNeeded { get; private set; }
-
ProjectPackagesFolderNode ParentNode { get; set; }
public IDotNetProject Project {
@@ -72,29 +73,29 @@ namespace MonoDevelop.PackageManagement.NodeBuilders }
public string Name {
- get { return PackageReference.Id; }
+ get { return Id; }
}
public string Id {
- get { return PackageReference.Id; }
+ get { return PackageReference.PackageIdentity.Id; }
}
- public SemanticVersion Version {
- get { return PackageReference.Version; }
+ public NuGetVersion Version {
+ get { return PackageReference.PackageIdentity.Version; }
}
- public SemanticVersion UpdatedVersion { get; private set; }
+ public NuGetVersion UpdatedVersion { get; private set; }
public bool IsDevelopmentDependency {
get { return PackageReference.IsDevelopmentDependency; }
}
- public FrameworkName TargetFramework {
+ public NuGetFramework TargetFramework {
get { return PackageReference.TargetFramework; }
}
- public IVersionSpec VersionConstraint {
- get { return PackageReference.VersionConstraint; }
+ public VersionRange VersionConstraint {
+ get { return PackageReference.AllowedVersions; }
}
public string GetLabel ()
@@ -130,9 +131,17 @@ namespace MonoDevelop.PackageManagement.NodeBuilders return Stock.Reference;
}
+ public string GetPackageDisplayVersion ()
+ {
+ if (PackageReference.IsFloating ()) {
+ return PackageReference.AllowedVersions.Float.ToString ();
+ }
+ return Version.ToString ();
+ }
+
public string GetPackageVersionLabel ()
{
- return GettextCatalog.GetString ("Version {0}", Version);
+ return GettextCatalog.GetString ("Version {0}", GetPackageDisplayVersion ());
}
public TaskSeverity? GetStatusSeverity ()
@@ -165,7 +174,13 @@ namespace MonoDevelop.PackageManagement.NodeBuilders public bool IsReleaseVersion ()
{
- return PackageReference.IsReleaseVersion ();
+ return !PackageReference.PackageIdentity.Version.IsPrerelease;
+ }
+
+ public bool NeedsRestoreBeforeUninstall () + {
+ return !ParentNode.IsNuGetIntegratedProject () &&
+ !ParentNode.IsPackageInstalled (PackageReference); }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNodeDescriptor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNodeDescriptor.cs index e91d50f65d..2b59b1b3a1 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNodeDescriptor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/PackageReferenceNodeDescriptor.cs @@ -24,11 +24,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.Core;
using MonoDevelop.DesignerSupport;
-using NuGet;
-using System.Runtime.Versioning;
+using NuGet.Frameworks;
+using NuGet.Versioning;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
@@ -51,8 +50,8 @@ namespace MonoDevelop.PackageManagement.NodeBuilders [LocalizedCategory ("Package")]
[LocalizedDisplayName ("Version")]
[LocalizedDescription ("Package version.")]
- public SemanticVersion Version {
- get { return packageReferenceNode.Version; }
+ public string Version {
+ get { return packageReferenceNode.GetPackageDisplayVersion (); }
}
[LocalizedCategory ("Package")]
@@ -65,14 +64,14 @@ namespace MonoDevelop.PackageManagement.NodeBuilders [LocalizedCategory ("Package")]
[LocalizedDisplayName ("Target Framework")]
[LocalizedDescription ("Target framework for the Package.")]
- public FrameworkName TargetFramework {
+ public NuGetFramework TargetFramework {
get { return packageReferenceNode.TargetFramework; }
}
[LocalizedCategory ("Package")]
[LocalizedDisplayName ("Version Constraint")]
[LocalizedDescription ("Version constraint for the Package.")]
- public IVersionSpec VersionConstraint {
+ public VersionRange VersionConstraint {
get { return packageReferenceNode.VersionConstraint; }
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNode.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNode.cs index b4cb538c29..c4b7a2ae5e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNode.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNode.cs @@ -26,33 +26,77 @@ using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Projects;
-using NuGet;
+using NuGet.Configuration;
+using NuGet.PackageManagement;
+using NuGet.Packaging;
+using NuGet.ProjectManagement;
+using NuGet.ProjectManagement.Projects;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
internal class ProjectPackagesFolderNode
{
IDotNetProject project;
- IUpdatedPackagesInSolution updatedPackagesInSolution;
- List<PackageReference> packageReferences;
+ NuGetProject nugetProject;
+ FolderNuGetProject folder;
+ VersionFolderPathResolver packagePathResolver;
+ IUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace;
+ List<PackageReference> packageReferences = new List<PackageReference> ();
+ bool packageReferencesRefreshed;
+
+ CancellationTokenSource cancellationTokenSource;
+
+ public static readonly string NodeName = "Packages";
public ProjectPackagesFolderNode (DotNetProject project)
- : this (new DotNetProjectProxy (project), PackageManagementServices.UpdatedPackagesInSolution)
+ : this (new DotNetProjectProxy (project), PackageManagementServices.UpdatedPackagesInWorkspace)
{
}
public ProjectPackagesFolderNode (
IDotNetProject project,
- IUpdatedPackagesInSolution updatedPackagesInSolution)
+ IUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace)
+ : this (project, updatedPackagesInWorkspace, true)
+ {
+ }
+
+ protected ProjectPackagesFolderNode (
+ IDotNetProject project,
+ IUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace,
+ bool createNuGetProject)
{
this.project = project;
- this.updatedPackagesInSolution = updatedPackagesInSolution;
+ this.updatedPackagesInWorkspace = updatedPackagesInWorkspace;
+
+ if (createNuGetProject)
+ CreateInitNuGetProject ();
}
+ protected void CreateInitNuGetProject ()
+ {
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution);
+ nugetProject = solutionManager.GetNuGetProject (project);
+
+ if (nugetProject is INuGetIntegratedProject) {
+ PackagesFolderPath = SettingsUtility.GetGlobalPackagesFolder (solutionManager.Settings);
+ packagePathResolver = new VersionFolderPathResolver (
+ PackagesFolderPath,
+ normalizePackageId: false);
+ } else {
+ PackagesFolderPath = nugetProject.GetPackagesFolderPath (solutionManager);
+ folder = new FolderNuGetProject (PackagesFolderPath);
+ }
+ }
+
+ public FilePath PackagesFolderPath { get; private set; }
+
public DotNetProject DotNetProject {
get { return project.DotNetProject; }
}
@@ -99,54 +143,124 @@ namespace MonoDevelop.PackageManagement.NodeBuilders int GetUpdatedPackagesCount ()
{
- return updatedPackagesInSolution
- .GetUpdatedPackages (project)
- .GetPackages ()
- .Count ();
- }
-
- IEnumerable<PackageReference> PackageReferences {
- get {
- if (packageReferences == null) {
- packageReferences = GetPackageReferences ().ToList ();
- }
- return packageReferences;
+ if (!packageReferencesRefreshed) {
+ return 0;
}
+
+ UpdatedNuGetPackagesInProject updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (project);
+ updatedPackages.RemoveUpdatedPackages (GetPackageReferences ());
+
+ return updatedPackages.GetPackages ().Count ();
}
- protected virtual IEnumerable<PackageReference> GetPackageReferences ()
+ public bool AnyPackageReferences ()
{
- if (project.HasPackages ()) {
- var packageReferenceFile = new PackageReferenceFile (project.GetPackagesConfigFilePath ());
- return packageReferenceFile.GetPackageReferences ();
- }
- return new PackageReference [0];
+ return packageReferences.Any ();
}
public IEnumerable<PackageReferenceNode> GetPackageReferencesNodes ()
{
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project);
- return PackageReferences.Select (reference => CreatePackageReferenceNode (reference, updatedPackages));
+ UpdatedNuGetPackagesInProject updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (project);
+ return GetPackageReferences ().Select (reference => CreatePackageReferenceNode (reference, updatedPackages));
}
- PackageReferenceNode CreatePackageReferenceNode (PackageReference reference, UpdatedPackagesInProject updatedPackages)
+ protected virtual IEnumerable<PackageReference> GetPackageReferences ()
{
+ return packageReferences;
+ }
+
+ PackageReferenceNode CreatePackageReferenceNode (PackageReference reference, UpdatedNuGetPackagesInProject updatedPackages)
+ {
+ // Floating package references (e.g. 1.0.1-*) are shown as installed.
+ // Currently the version being used can be found in the project.lock.json but
+ // reading this is not currently supported. So for now the package is shown
+ // as installed since without the full version it is not possible to check
+ // the NuGet package exists.
+ bool installed = reference.IsFloating () || IsPackageInstalled (reference);
+
return new PackageReferenceNode (
this,
reference,
- IsPackageInstalled (reference),
+ installed,
false,
- updatedPackages.GetUpdatedPackage (reference.Id));
+ updatedPackages.GetUpdatedPackage (reference.PackageIdentity.Id));
}
- protected virtual bool IsPackageInstalled (PackageReference reference)
+ public virtual bool IsPackageInstalled (PackageReference reference)
{
- return reference.IsPackageInstalled (project.DotNetProject);
+ if (IsNuGetIntegratedProject ()) {
+ string path = packagePathResolver.GetHashPath (reference.PackageIdentity.Id, reference.PackageIdentity.Version);
+ return File.Exists (path);
+ }
+
+ return folder.PackageExists (reference.PackageIdentity);
+ }
+
+ public bool IsNuGetIntegratedProject () + { + return nugetProject is INuGetIntegratedProject; + }
+
+ public event EventHandler PackageReferencesChanged;
+
+ void OnPackageReferencesChanged ()
+ {
+ var handler = PackageReferencesChanged;
+ if (handler != null) {
+ handler (this, new EventArgs ());
+ }
+ }
+
+ public void RefreshPackages ()
+ {
+ try {
+ CancelCurrentRefresh ();
+ GetInstalledPackages ();
+ } catch (Exception ex) {
+ LoggingService.LogError ("Refresh packages folder error.", ex);
+ }
+ }
+
+ void CancelCurrentRefresh ()
+ {
+ if (cancellationTokenSource != null) {
+ cancellationTokenSource.Cancel ();
+ cancellationTokenSource.Dispose ();
+ cancellationTokenSource = null;
+ }
+ }
+
+ void GetInstalledPackages ()
+ {
+ var tokenSource = new CancellationTokenSource ();
+ cancellationTokenSource = tokenSource;
+ GetInstalledPackagesAsync (tokenSource)
+ .ContinueWith (task => OnInstalledPackagesRead (task, tokenSource), TaskScheduler.FromCurrentSynchronizationContext ());
+ }
+
+ protected virtual Task<IEnumerable<PackageReference>> GetInstalledPackagesAsync (CancellationTokenSource tokenSource)
+ {
+ return nugetProject.GetInstalledPackagesAsync (tokenSource.Token);
+ }
+
+ protected virtual void OnInstalledPackagesRead (Task<IEnumerable<PackageReference>> task, CancellationTokenSource tokenSource)
+ {
+ try {
+ if (task.IsFaulted) {
+ LoggingService.LogError ("OnInstalledPackagesRead error.", task.Exception);
+ } else if (!tokenSource.IsCancellationRequested) {
+ packageReferencesRefreshed = true;
+ packageReferences = task.Result.ToList ();
+ OnPackageReferencesChanged ();
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("OnInstalledPackagesRead error.", ex);
+ }
}
- public void ClearPackageReferences ()
+ public bool AnyPackageReferencesRequiringReinstallation ()
{
- packageReferences = null;
+ return GetPackageReferences ().Any (packageReference => packageReference.RequireReinstallation);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNodeBuilder.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNodeBuilder.cs index de7c26d701..19a5b428e2 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesFolderNodeBuilder.cs @@ -27,14 +27,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using Gdk;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.PackageManagement.Commands;
using MonoDevelop.Projects;
-using NuGet;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
@@ -46,7 +43,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
{
- return "Packages";
+ return ProjectPackagesFolderNode.NodeName;
}
public override Type CommandHandlerType {
@@ -81,8 +78,8 @@ namespace MonoDevelop.PackageManagement.NodeBuilders List<PackageReferenceNode> nodes = projectPackagesNode.GetPackageReferencesNodes ().ToList ();
- foreach (InstallPackageAction installAction in GetPendingInstallActions (projectPackagesNode.DotNetProject)) {
- if (!nodes.Any (node => node.Id == installAction.GetPackageId ())) {
+ foreach (IInstallNuGetPackageAction installAction in GetPendingInstallActions (projectPackagesNode.DotNetProject)) {
+ if (!nodes.Any (node => node.Id == installAction.PackageId)) {
nodes.Add (CreatePackageReferenceNode (projectPackagesNode, installAction));
}
}
@@ -92,16 +89,16 @@ namespace MonoDevelop.PackageManagement.NodeBuilders }
}
- IEnumerable<InstallPackageAction> GetPendingInstallActions (DotNetProject project)
+ IEnumerable<IInstallNuGetPackageAction> GetPendingInstallActions (DotNetProject project)
{
return PackageManagementServices.BackgroundPackageActionRunner.PendingInstallActionsForProject (project);
}
- PackageReferenceNode CreatePackageReferenceNode (ProjectPackagesFolderNode parentNode, InstallPackageAction installAction)
+ PackageReferenceNode CreatePackageReferenceNode (ProjectPackagesFolderNode parentNode, IInstallNuGetPackageAction installAction)
{
return new PackageReferenceNode (
parentNode,
- new PackageReference (installAction.GetPackageId (), installAction.GetPackageVersion (), null, null, false),
+ new PackageReference (new PackageIdentity (installAction.PackageId, installAction.Version), null),
false,
true);
}
@@ -110,6 +107,32 @@ namespace MonoDevelop.PackageManagement.NodeBuilders {
treeBuilder.AddChildren (GetPackageReferencesNodes (dataObject));
}
+
+ public override void OnNodeAdded (object dataObject)
+ {
+ var projectPackagesNode = (ProjectPackagesFolderNode)dataObject;
+ projectPackagesNode.PackageReferencesChanged += OnPackageReferencesChanged;
+ }
+ + public override void OnNodeRemoved (object dataObject)
+ {
+ var projectPackagesNode = (ProjectPackagesFolderNode)dataObject;
+ projectPackagesNode.PackageReferencesChanged -= OnPackageReferencesChanged;
+ }
+
+ void OnPackageReferencesChanged (object sender, EventArgs e)
+ {
+ var projectPackagesNode = (ProjectPackagesFolderNode)sender;
+ ITreeBuilder builder = Context.GetTreeBuilder (projectPackagesNode);
+ if (builder != null) {
+ builder.UpdateAll ();
+ builder.MoveToParent ();
+ }
+
+ if (builder.MoveToChild ("References", typeof (ProjectReferenceCollection))) {
+ builder.UpdateAll ();
+ }
+ }
}
}
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 b4033cbcf8..a2d44bcb48 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectPackagesProjectNodeBuilderExtension.cs @@ -26,7 +26,6 @@ using System;
using System.Linq;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using MonoDevelop.Ide.Gui.Components;
@@ -44,6 +43,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders packageManagementEvents.PackagesRestored += PackagesRestored;
packageManagementEvents.PackageOperationsStarting += PackageOperationsStarting;
+ packageManagementEvents.PackageOperationsFinished += PackageOperationsFinished;
packageManagementEvents.PackageOperationError += PackageOperationError;
packageManagementEvents.UpdatedPackagesAvailable += UpdatedPackagesAvailable;
@@ -60,6 +60,11 @@ namespace MonoDevelop.PackageManagement.NodeBuilders RefreshAllChildNodes ();
}
+ void PackageOperationsFinished (object sender, EventArgs e)
+ {
+ RefreshAllChildNodes ();
+ }
+
void PackageOperationError (object sender, EventArgs e)
{
RefreshAllChildNodes ();
@@ -83,15 +88,9 @@ namespace MonoDevelop.PackageManagement.NodeBuilders {
ITreeBuilder builder = Context.GetTreeBuilder (project);
if (builder != null) {
- if (builder.MoveToChild ("References", typeof (ProjectReferenceCollection))) {
- builder.UpdateAll ();
- builder.MoveToParent ();
- }
-
- if (builder.MoveToChild ("Packages", typeof (ProjectPackagesFolderNode))) {
+ if (builder.MoveToChild (ProjectPackagesFolderNode.NodeName, typeof (ProjectPackagesFolderNode))) {
var packagesFolder = (ProjectPackagesFolderNode)builder.DataItem;
- packagesFolder.ClearPackageReferences ();
- builder.UpdateAll ();
+ packagesFolder.RefreshPackages ();
builder.MoveToParent ();
}
}
@@ -103,6 +102,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders packageManagementEvents.PackagesRestored -= PackagesRestored;
packageManagementEvents.PackageOperationsStarting -= PackageOperationsStarting;
+ packageManagementEvents.PackageOperationsFinished -= PackageOperationsFinished;
packageManagementEvents.PackageOperationError -= PackageOperationError;
packageManagementEvents.UpdatedPackagesAvailable -= UpdatedPackagesAvailable;
}
@@ -120,19 +120,21 @@ namespace MonoDevelop.PackageManagement.NodeBuilders public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
{
var project = (DotNetProject)dataObject;
- treeBuilder.AddChild (new ProjectPackagesFolderNode (project));
+ var folderNode = new ProjectPackagesFolderNode (project);
+ folderNode.RefreshPackages ();
+ treeBuilder.AddChild (folderNode);
}
void FileChanged (object sender, FileEventArgs e)
{
- if (IsPackagesConfigFileChanged (e)) {
+ if (IsPackagesConfigOrProjectJsonFileChanged (e)) {
RefreshAllChildNodes ();
}
}
- bool IsPackagesConfigFileChanged (FileEventArgs fileEventArgs)
+ bool IsPackagesConfigOrProjectJsonFileChanged (FileEventArgs fileEventArgs)
{
- return fileEventArgs.Any (file => file.FileName.IsPackagesConfigFileName ());
+ return fileEventArgs.Any (file => file.FileName.IsPackagesConfigOrProjectJsonFileName ());
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferenceNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferenceNodeBuilderExtension.cs index f65d0c2902..04e05282b4 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferenceNodeBuilderExtension.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferenceNodeBuilderExtension.cs @@ -25,12 +25,9 @@ // THE SOFTWARE.
using System;
-using System.IO;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.Ide.Gui.Pads.ProjectPad;
using MonoDevelop.Projects;
-using MonoDevelop.PackageManagement;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNode.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNode.cs index d6f4bf7270..a8a7eb0586 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNode.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNode.cs @@ -24,40 +24,57 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
using System.Collections.Generic;
using System.Linq;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
namespace MonoDevelop.PackageManagement.NodeBuilders
{
internal class ProjectReferencesFromPackagesFolderNode
{
+ public static readonly string NodeName = "From Packages";
+
public ProjectReferencesFromPackagesFolderNode (
- DotNetProject project,
+ ProjectPackagesFolderNode packagesFolder,
ProjectReferenceCollection projectReferences)
+ : this (
+ packagesFolder.DotNetProject,
+ projectReferences,
+ packagesFolder.PackagesFolderPath)
+ {
+ }
+
+ public ProjectReferencesFromPackagesFolderNode (
+ DotNetProject project,
+ ProjectReferenceCollection projectReferences,
+ FilePath packagesFolderPath)
{
Project = project;
References = projectReferences;
+ PackagesFolderPath = packagesFolderPath;
}
-
+ public DotNetProject Project { get; private set; }
public ProjectReferenceCollection References { get; private set; }
+ public FilePath PackagesFolderPath { get; private set; }
- public bool AnyReferencesFromPackages ()
- {
- return GetReferencesFromPackages ().Any ();
- }
+ public bool AnyReferencesFromPackages ()
+ {
+ return GetReferencesFromPackages ().Any ();
+ }
public IEnumerable<ProjectReference> GetReferencesFromPackages ()
{
- if (Project.HasPackages ()) {
- foreach (ProjectReference projectReference in References.Where (reference => reference.IsReferenceFromPackage ())) {
- yield return projectReference;
- }
+ foreach (ProjectReference projectReference in References.Where (IsReferenceFromPackage)) {
+ yield return projectReference;
}
}
+
+ bool IsReferenceFromPackage (ProjectReference reference)
+ {
+ return reference.IsReferenceFromPackage (PackagesFolderPath);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNodeBuilder.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNodeBuilder.cs index aa529a834d..26b5aea6b8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNodeBuilder.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesFromPackagesFolderNodeBuilder.cs @@ -41,7 +41,7 @@ namespace MonoDevelop.PackageManagement.NodeBuilders public override string GetNodeName (ITreeNavigator thisNode, object dataObject)
{
- return "From Packages";
+ return ProjectReferencesFromPackagesFolderNode.NodeName;
}
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesNodeBuilderExtension.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesNodeBuilderExtension.cs index dd36fc27b8..8dc6331f38 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesNodeBuilderExtension.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.NodeBuilders/ProjectReferencesNodeBuilderExtension.cs @@ -25,7 +25,6 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Ide.Gui.Components;
using MonoDevelop.Projects;
@@ -40,34 +39,42 @@ namespace MonoDevelop.PackageManagement.NodeBuilders public override bool HasChildNodes (ITreeBuilder builder, object dataObject)
{
- return ProjectHasPackages (builder);
- }
-
- bool ProjectHasPackages (ITreeBuilder builder)
- {
- DotNetProject project = GetProject (builder);
- if (project != null) {
- return project.HasPackages ();
+ ProjectPackagesFolderNode packagesFolder = GetPackagesFolderNode (builder);
+ if (packagesFolder != null) {
+ return packagesFolder.AnyPackageReferences ();
}
return false;
}
- DotNetProject GetProject (ITreeBuilder builder)
- {
- return builder.GetParentDataItem (typeof(DotNetProject), false) as DotNetProject;
- }
-
public override void BuildChildNodes (ITreeBuilder treeBuilder, object dataObject)
{
- DotNetProject project = GetProject (treeBuilder);
- if (project != null) {
+ ProjectPackagesFolderNode packagesFolder = GetPackagesFolderNode (treeBuilder);
+ if (packagesFolder != null && packagesFolder.AnyPackageReferences ()) {
var projectReferences = dataObject as ProjectReferenceCollection;
- var folderNode = new ProjectReferencesFromPackagesFolderNode (project, projectReferences);
+ var folderNode = new ProjectReferencesFromPackagesFolderNode (packagesFolder, projectReferences);
if (folderNode.AnyReferencesFromPackages ()) {
treeBuilder.AddChild (folderNode);
}
}
}
+
+ ProjectPackagesFolderNode GetPackagesFolderNode (ITreeBuilder treeBuilder)
+ {
+ NodePosition originalPosition = treeBuilder.CurrentPosition;
+
+ if (!treeBuilder.MoveToParent ()) {
+ return null;
+ }
+
+ ProjectPackagesFolderNode packagesFolder = null;
+ if (treeBuilder.MoveToChild (ProjectPackagesFolderNode.NodeName, typeof(ProjectPackagesFolderNode))) {
+ packagesFolder = treeBuilder.DataItem as ProjectPackagesFolderNode;
+ }
+
+ treeBuilder.MoveToPosition (originalPosition);
+
+ return packagesFolder;
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Refactoring/PackageCodeDiagnosticProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Refactoring/PackageCodeDiagnosticProvider.cs index 1b14140a14..b676ee224c 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Refactoring/PackageCodeDiagnosticProvider.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Refactoring/PackageCodeDiagnosticProvider.cs @@ -86,7 +86,7 @@ namespace MonoDevelop.PackageManagement.Refactoring if (dotNetProject != null) { var proxy = new DotNetProjectProxy (dotNetProject); if (proxy.HasPackages ()) { - var packagesPath = new SolutionPackageRepositoryPath (proxy, PackageManagementServices.Options); + var packagesPath = new SolutionPackageRepositoryPath (proxy); foreach (var file in Directory.EnumerateFiles (packagesPath.PackageRepositoryPath, "*.dll", SearchOption.AllDirectories)) { cancellationToken.ThrowIfCancellationRequested (); try { diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingPackageMetadataResource.cs index 7493238378..78b8078139 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForUpdatesTaskRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingPackageMetadataResource.cs @@ -1,51 +1,51 @@ -//
-// TestableCheckForUpdatesTaskRunner.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;
-using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestableCheckForUpdatesTaskRunner : CheckForUpdatesTaskRunner
- {
- public List<string> LoggedErrorMessages = new List<string> ();
- public List<Exception> LoggedExceptions = new List<Exception> ();
-
- public TestableCheckForUpdatesTaskRunner (ITaskFactory taskFactory)
- : base (taskFactory)
- {
- }
-
- protected override void LogError (string message, Exception ex)
- {
- LoggedErrorMessages.Add (message);
- LoggedExceptions.Add (ex);
- }
- }
-}
-
+// +// ExceptionThrowingPackageMetadataResource.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Logging; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + public class ExceptionThrowingPackageMetadataResource : FakePackageMetadataResource + { + Exception ex; + + public ExceptionThrowingPackageMetadataResource (Exception ex) + { + this.ex = ex; + } + + public override Task<IEnumerable<IPackageSearchMetadata>> GetMetadataAsync (string packageId, bool includePrerelease, bool includeUnlisted, ILogger log, CancellationToken token) + { + throw ex; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingProcessPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingProcessPackageAction.cs deleted file mode 100644 index ab04f3fad3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingProcessPackageAction.cs +++ /dev/null @@ -1,42 +0,0 @@ -//
-// ExceptionThrowingProcessPackageAction.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;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class ExceptionThrowingProcessPackageAction : TestableProcessPackageAction
- {
- public Exception ExceptionToThrowInExecuteCore =
- new Exception ("Error");
-
- protected override void ExecuteCore ()
- {
- throw ExceptionToThrowInExecuteCore;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeBackgroundPackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeBackgroundPackageActionRunner.cs index f8819225b3..6236b8c24f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeBackgroundPackageActionRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeBackgroundPackageActionRunner.cs @@ -33,7 +33,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
class FakeBackgroundPackageActionRunner : IBackgroundPackageActionRunner
{
- public IEnumerable<InstallPackageAction> PendingInstallActionsForProject (DotNetProject project)
+ public IEnumerable<IInstallNuGetPackageAction> PendingInstallActionsForProject (DotNetProject project)
{
throw new NotImplementedException ();
}
@@ -72,7 +72,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public string ShowErrorMessage;
public Exception ShowErrorException;
- public IEnumerable<InstallPackageAction> PendingInstallActions {
+ public IEnumerable<IInstallNuGetPackageAction> PendingInstallActions {
get {
throw new NotImplementedException ();
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeDotNetProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeDotNetProject.cs index 7bb4c0cb71..2004a34a9c 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeDotNetProject.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeDotNetProject.cs @@ -49,6 +49,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
References = new ProjectReferenceCollection ();
Files = new ProjectFileCollection ();
+ TargetFrameworkMoniker = new TargetFrameworkMoniker ("v4.5");
CreateEqualsAction ();
}
@@ -73,7 +74,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public void AddProjectType (Guid guid)
{
- ExtendedProperties.Add ("ProjectTypeGuids", guid.ToString ());
+ AddFlavorGuid (guid.ToString ());
}
public int ReferencesWhenSavedCount;
@@ -126,6 +127,15 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers }
}
+ public event EventHandler Saved;
+
+ public void RaiseSavedEvent ()
+ {
+ if (Saved != null) {
+ Saved (this, new EventArgs ());
+ }
+ }
+
public Func<IDotNetProject, bool> EqualsAction;
void CreateEqualsAction ()
@@ -150,6 +160,13 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
IsProjectBuilderDisposed = true;
}
+
+ public bool IsReferenceStatusRefreshed;
+
+ public void RefreshReferenceStatus ()
+ {
+ IsReferenceStatusRefreshed = true;
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeInstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeInstallPackageAction.cs deleted file mode 100644 index 792eff1f63..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeInstallPackageAction.cs +++ /dev/null @@ -1,82 +0,0 @@ -//
-// FakeInstallPackageAction.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakeInstallPackageAction : InstallPackageAction
- {
- public FakeInstallPackageAction ()
- : this (null)
- {
- }
-
- public FakeInstallPackageAction (IPackageManagementProject project)
- : this (project, null)
- {
- }
-
- public FakeInstallPackageAction (IPackageManagementProject project, IPackageManagementEvents packageManagementEvents)
- : this (project, packageManagementEvents, new FakeFileRemover (), new FakeLicenseAcceptanceService ())
- {
- }
-
- public FakeInstallPackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- FakeFileRemover fileRemover,
- FakeLicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents, fileRemover, licenseAcceptanceService)
- {
- FileRemover = fileRemover;
- LicenseAcceptanceService = licenseAcceptanceService;
- Operations = new List<PackageOperation> ();
- Logger = new FakeLogger ();
- }
-
- public bool IsExecuteCalled;
-
- protected override void ExecuteCore ()
- {
- IsExecuteCalled = true;
- ExecuteAction ();
- }
-
- protected override void BeforeExecute ()
- {
- }
-
- public Action ExecuteAction = () => { };
-
- public FakeFileRemover FileRemover;
- public FakeLicenseAcceptanceService LicenseAcceptanceService;
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeLicenseAcceptanceService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeLicenseAcceptanceService.cs index 1ae0c6c837..1add6692cc 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeLicenseAcceptanceService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeLicenseAcceptanceService.cs @@ -24,13 +24,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using System; using System.Linq; using System.Collections.Generic; using NuGet; namespace MonoDevelop.PackageManagement.Tests.Helpers { - public class FakeLicenseAcceptanceService : ILicenseAcceptanceService + class FakeLicenseAcceptanceService : ILicenseAcceptanceService { public bool AcceptLicensesReturnValue = true; public List<IPackage> PackagesAccepted; @@ -40,6 +41,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers PackagesAccepted = packages.ToList (); return AcceptLicensesReturnValue; } + + public List<NuGetPackageLicense> PackageLicensesAccepted; + + public bool AcceptLicenses (IEnumerable<NuGetPackageLicense> licenses) + { + PackageLicensesAccepted = licenses.ToList (); + return AcceptLicensesReturnValue; + } } } diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageAction.cs new file mode 100644 index 0000000000..966e816cab --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageAction.cs @@ -0,0 +1,79 @@ +// +// FakeNuGetPackageAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using System.Threading; +using NuGet.PackageManagement; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeNuGetPackageAction : INuGetPackageAction, INuGetProjectActionsProvider + { + public FakeNuGetPackageAction () + { + PackageId = "Test"; + } + + public string PackageId { get; set; } + + public void Execute () + { + } + + public void Execute (CancellationToken cancellationToken) + { + } + + public List<NuGetProjectAction> ProjectActions = new List<NuGetProjectAction> (); + + public IEnumerable<NuGetProjectAction> GetNuGetProjectActions () + { + return ProjectActions; + } + + public bool HasPackageScriptsToRun () + { + return false; + } + + public void AddNuGetProjectInstallAction (string packageId, string packageVersion) + { + AddNuGetProjectAction (packageId, packageVersion, NuGetProjectActionType.Install); + } + + public void AddNuGetProjectUninstallAction (string packageId, string packageVersion) + { + AddNuGetProjectAction (packageId, packageVersion, NuGetProjectActionType.Uninstall); + } + + void AddNuGetProjectAction (string packageId, string packageVersion, NuGetProjectActionType actionType) + { + var projectAction = new FakeNuGetProjectAction (packageId, packageVersion, actionType); + ProjectActions.Add (projectAction); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageManager.cs new file mode 100644 index 0000000000..9380409977 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageManager.cs @@ -0,0 +1,243 @@ +// +// FakeNuGetPackageManager.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Logging; +using NuGet.PackageManagement; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeNuGetPackageManager : INuGetPackageManager + { + public INuGetProjectContext ClearDirectInstallProjectContext; + + public void ClearDirectInstall (INuGetProjectContext nuGetProjectContext) + { + ClearDirectInstallProjectContext = nuGetProjectContext; + } + + public PackageIdentity SetDirectInstallPackageIdentity; + public INuGetProjectContext SetDirectInstallProjectContext; + + public void SetDirectInstall (PackageIdentity directInstall, INuGetProjectContext nuGetProjectContext) + { + SetDirectInstallPackageIdentity = directInstall; + SetDirectInstallProjectContext = nuGetProjectContext; + } + + public NuGetProject ExecutedNuGetProject; + public List<NuGetProjectAction> ExecutedActions; + public INuGetProjectContext ExecutedProjectContext; + public CancellationToken ExecutedCancellationToken; + + public Action BeforeExecuteAction = () => { }; + + public Task ExecuteNuGetProjectActionsAsync ( + NuGetProject nuGetProject, + IEnumerable<NuGetProjectAction> nuGetProjectActions, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + ExecutedNuGetProject = nuGetProject; + ExecutedActions = nuGetProjectActions.ToList (); + ExecutedProjectContext = nuGetProjectContext; + ExecutedCancellationToken = token; + + BeforeExecuteAction (); + + return Task.FromResult (0); + } + + public NuGetVersion LatestVersion = new NuGetVersion ("1.2.3"); + public string GetLatestVersionPackageId; + public NuGetProject GetLatestVersionProject; + public ResolutionContext GetLatestVersionResolutionContext; + public List<SourceRepository> GetLatestVersionSources; + public ILogger GetLatestVersionLogger; + public CancellationToken GetLatestVersionCancellationToken; + + public Task<NuGetVersion> GetLatestVersionAsync ( + string packageId, + NuGetProject project, + ResolutionContext resolutionContext, + IEnumerable<SourceRepository> sources, + ILogger log, + CancellationToken token) + { + GetLatestVersionPackageId = packageId; + GetLatestVersionProject = project; + GetLatestVersionResolutionContext = resolutionContext; + GetLatestVersionSources = sources.ToList (); + GetLatestVersionLogger = log; + GetLatestVersionCancellationToken = token; + + return Task.FromResult (LatestVersion); + } + + public List<FakeNuGetProjectAction> InstallActions = new List<FakeNuGetProjectAction> (); + + public NuGetProject PreviewInstallProject; + public PackageIdentity PreviewInstallPackageIdentity; + public ResolutionContext PreviewInstallResolutionContext; + public List<SourceRepository> PreviewInstallPrimarySources; + public IEnumerable<SourceRepository> PreviewInstallSecondarySources; + public CancellationToken PreviewInstallCancellationToken; + + public Task<IEnumerable<NuGetProjectAction>> PreviewInstallPackageAsync ( + NuGetProject nuGetProject, + PackageIdentity packageIdentity, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token) + { + PreviewInstallProject = nuGetProject; + PreviewInstallPackageIdentity = packageIdentity; + PreviewInstallResolutionContext = resolutionContext; + PreviewInstallPrimarySources = primarySources.ToList (); + PreviewInstallSecondarySources = secondarySources; + PreviewInstallCancellationToken = token; + + IEnumerable<NuGetProjectAction> actions = InstallActions.ToArray (); + return Task.FromResult (actions); + } + + public List<PackageIdentity> PackagesInPackagesFolder = new List<PackageIdentity> (); + + public bool PackageExistsInPackagesFolder (PackageIdentity packageIdentity) + { + return PackagesInPackagesFolder.Contains (packageIdentity); + } + + public List<FakeNuGetProjectAction> UpdateActions = new List<FakeNuGetProjectAction> (); + + public NuGetProject PreviewUpdateProject; + public string PreviewUpdatePackageId; + public ResolutionContext PreviewUpdateResolutionContext; + public List<SourceRepository> PreviewUpdatePrimarySources; + public IEnumerable<SourceRepository> PreviewUpdateSecondarySources; + public CancellationToken PreviewUpdateCancellationToken; + + public Task<IEnumerable<NuGetProjectAction>> PreviewUpdatePackagesAsync ( + string packageId, + NuGetProject nuGetProject, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token) + { + PreviewUpdateProject = nuGetProject; + PreviewUpdatePackageId = packageId; + PreviewUpdateResolutionContext = resolutionContext; + PreviewUpdatePrimarySources = primarySources.ToList (); + PreviewUpdateSecondarySources = secondarySources; + PreviewUpdateCancellationToken = token; + + IEnumerable<NuGetProjectAction> actions = UpdateActions.ToArray (); + return Task.FromResult (actions); + } + + public Task<IEnumerable<NuGetProjectAction>> PreviewUpdatePackagesAsync ( + NuGetProject nuGetProject, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token) + { + return PreviewUpdatePackagesAsync ( + null, + nuGetProject, + resolutionContext, + nuGetProjectContext, + primarySources, + secondarySources, + token + ); + } + + public void AddPackageToPackagesFolder (string packageId, string version) + { + var package = new PackageIdentity (packageId, new NuGetVersion (version)); + PackagesInPackagesFolder.Add (package); + } + + public List<FakeNuGetProjectAction> UninstallActions = new List<FakeNuGetProjectAction> (); + + public NuGetProject PreviewUninstallProject; + public string PreviewUninstallPackageId; + public UninstallationContext PreviewUninstallContext; + public INuGetProjectContext PreviewUninstallProjectContext; + public CancellationToken PreviewUninstallCancellationToken; + + public Task<IEnumerable<NuGetProjectAction>> PreviewUninstallPackageAsync ( + NuGetProject nuGetProject, + string packageId, + UninstallationContext uninstallationContext, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + PreviewUninstallProject = nuGetProject; + PreviewUninstallPackageId = packageId; + PreviewUninstallContext = uninstallationContext; + PreviewUninstallProjectContext = nuGetProjectContext; + PreviewUninstallCancellationToken = token; + + IEnumerable<NuGetProjectAction> actions = UninstallActions.ToArray (); + return Task.FromResult (actions); + } + + public NuGetProject OpenReadmeFilesForProject; + public List<PackageIdentity> OpenReadmeFilesForPackages; + public INuGetProjectContext OpenReadmeFilesWithProjectContext; + public CancellationToken OpenReadmeFilesWithCancellationToken; + + public Task OpenReadmeFiles ( + NuGetProject project, + IEnumerable<PackageIdentity> packages, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + OpenReadmeFilesForProject = project; + OpenReadmeFilesForPackages = packages.ToList (); + OpenReadmeFilesWithProjectContext = nuGetProjectContext; + OpenReadmeFilesWithCancellationToken = token; + + return Task.FromResult (0); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageNewImportsHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageNewImportsHandler.cs index ac2a71ea6a..eb140bb14a 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageNewImportsHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetPackageNewImportsHandler.cs @@ -25,7 +25,7 @@ // THE SOFTWARE. using System.Collections.Generic; -using NuGet; +using NuGet.ProjectManagement; namespace MonoDevelop.PackageManagement.Tests.Helpers { @@ -34,7 +34,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public bool IsDisposed; public List<ImportAndCondition> ImportsAdded = new List<ImportAndCondition> (); - public void AddImportIfMissing (string name, string condition, ProjectImportLocation location) + public void AddImportIfMissing (string name, string condition, ImportLocation location) { ImportsAdded.Add (new ImportAndCondition (name, condition, location)); } diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProject.cs new file mode 100644 index 0000000000..82388b7a6d --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProject.cs @@ -0,0 +1,108 @@ +// +// FakeNuGetProject.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Frameworks; +using NuGet.PackageManagement; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeNuGetProject : NuGetProject, IBuildIntegratedNuGetProject + { + public FakeNuGetProject (IDotNetProject project) + { + Project = project; + } + + public IDotNetProject Project { get; private set; } + + public List<PackageReference> InstalledPackages = new List<PackageReference> (); + + public override Task<IEnumerable<PackageReference>> GetInstalledPackagesAsync (CancellationToken token) + { + return Task.FromResult (InstalledPackages.AsEnumerable ()); + } + + public override Task<bool> InstallPackageAsync (PackageIdentity packageIdentity, DownloadResourceResult downloadResourceResult, INuGetProjectContext nuGetProjectContext, CancellationToken token) + { + throw new NotImplementedException (); + } + + public override Task<bool> UninstallPackageAsync (PackageIdentity packageIdentity, INuGetProjectContext nuGetProjectContext, CancellationToken token) + { + throw new NotImplementedException (); + } + + public void AddPackageReference (string id, string version, VersionRange versionRange = null) + { + var packageId = new PackageIdentity (id, new NuGetVersion (version)); + var packageReference = new PackageReference ( + packageId, + new NuGetFramework ("net45"), + true, + false, + false, + versionRange + ); + InstalledPackages.Add (packageReference); + } + + public List<NuGetProjectAction> ActionsPassedToOnBeforeUninstall; + + public void OnBeforeUninstall (IEnumerable<NuGetProjectAction> actions) + { + ActionsPassedToOnBeforeUninstall = actions.ToList (); + } + + public List<NuGetProjectAction> ActionsPassedToOnAfterExecuteActions; + + public void OnAfterExecuteActions (IEnumerable<NuGetProjectAction> actions) + { + ActionsPassedToOnAfterExecuteActions = actions.ToList (); + } + + public INuGetProjectContext PostProcessProjectContext; + public CancellationToken PostProcessCancellationToken; + + public override Task PostProcessAsync (INuGetProjectContext nuGetProjectContext, CancellationToken token) + { + PostProcessProjectContext = nuGetProjectContext; + PostProcessCancellationToken = token; + + return Task.FromResult (0); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingRegisteredPackageRepositories.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProjectAction.cs index d67d3e878c..3f749289c2 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ExceptionThrowingRegisteredPackageRepositories.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProjectAction.cs @@ -1,46 +1,54 @@ -//
-// ExceptionThrowingRegisteredPackageRepositories.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 NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class ExceptionThrowingRegisteredPackageRepositories : FakeRegisteredPackageRepositories
- {
- public Exception ExceptionToThrowWhenActiveRepositoryAccessed { get; set; }
-
- public override IPackageRepository ActiveRepository {
- get {
- if (ExceptionToThrowWhenActiveRepositoryAccessed != null) {
- throw ExceptionToThrowWhenActiveRepositoryAccessed;
- }
- return base.ActiveRepository;
- }
- }
- }
-}
-
+// +// FakeNuGetProjectAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 NuGet.PackageManagement; +using NuGet.Packaging.Core; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeNuGetProjectAction : NuGetProjectAction + { + public FakeNuGetProjectAction ( + string packageId, + string packageVersion, + NuGetProjectActionType actionType) + : base ( + CreatePackageIdentity (packageId, packageVersion), + actionType) + { + } + + static PackageIdentity CreatePackageIdentity (string packageId, string packageVersion) + { + NuGetVersion nuGetVersion = null; + if (packageVersion != null) { + nuGetVersion = new NuGetVersion (packageVersion); + } + return new PackageIdentity (packageId, nuGetVersion); + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/UninstallPackageHelper.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProjectContext.cs index e6eed525b0..304d87b085 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/UninstallPackageHelper.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetProjectContext.cs @@ -1,68 +1,67 @@ -//
-// UninstallPackageHelper.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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class UninstallPackageHelper
- {
- UninstallPackageAction action;
-
- public UninstallPackageHelper (UninstallPackageAction action)
- {
- this.action = action;
- }
-
- public FakePackage TestPackage = new FakePackage () {
- Id = "Test"
- };
-
- public void UninstallTestPackage ()
- {
- action.Package = TestPackage;
- action.Execute ();
- }
-
- public SemanticVersion Version;
- public PackageSource PackageSource = new PackageSource ("http://monodevelop.net");
- public bool ForceRemove;
- public bool RemoveDependencies;
-
- public void UninstallPackageById (string packageId)
- {
- action.PackageId = packageId;
- action.PackageVersion = Version;
- action.ForceRemove = ForceRemove;
- action.RemoveDependencies = RemoveDependencies;
- action.Execute ();
- }
- }
-}
-
-
+// +// FakeNuGetProjectContext.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Xml.Linq; +using NuGet.Packaging; +using NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + public class FakeNuGetProjectContext : INuGetProjectContext + { + public NuGetActionType ActionType { get; set; } + + public ExecutionContext ExecutionContext { get; set; } + + public XDocument OriginalPackagesConfig { get; set; } + + public PackageExtractionContext PackageExtractionContext { get; set; } + + public ISourceControlManagerProvider SourceControlManagerProvider { + get { return null; } + } + + public void Log (MessageLevel level, string message, params object [] args) + { + LastLogLevel = level; + LastMessageLogged = String.Format (message, args); + } + + public MessageLevel? LastLogLevel { get; set; } + public string LastMessageLogged { get; set; } + + public void ReportError (string message) + { + } + + public FileConflictAction ResolveFileConflict (string message) + { + return FileConflictAction.Ignore; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetSettings.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetSettings.cs new file mode 100644 index 0000000000..86d485ad5b --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeNuGetSettings.cs @@ -0,0 +1,106 @@ +// +// FakeNuGetSettings.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using NuGet.Configuration; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeNuGetSettings : ISettings + { + public string FileName { + get { + throw new NotImplementedException (); + } + } + + public IEnumerable<ISettings> Priority { + get { + throw new NotImplementedException (); + } + } + + public string Root { + get { + throw new NotImplementedException (); + } + } + + public event EventHandler SettingsChanged; + + void OnSettingsChanged (object sender, EventArgs e) + { + SettingsChanged?.Invoke (sender, e); + } + + public bool DeleteSection (string section) + { + throw new NotImplementedException (); + } + + public bool DeleteValue (string section, string key) + { + throw new NotImplementedException (); + } + + public IList<KeyValuePair<string, string>> GetNestedValues (string section, string subSection) + { + throw new NotImplementedException (); + } + + public IList<SettingValue> GetSettingValues (string section, bool isPath = false) + { + throw new NotImplementedException (); + } + + public string GetValue (string section, string key, bool isPath = false) + { + return null; + } + + public void SetNestedValues (string section, string subSection, IList<KeyValuePair<string, string>> values) + { + throw new NotImplementedException (); + } + + public void SetValue (string section, string key, string value) + { + throw new NotImplementedException (); + } + + public void SetValues (string section, IReadOnlyList<SettingValue> values) + { + throw new NotImplementedException (); + } + + public void UpdateSections (string section, IReadOnlyList<SettingValue> values) + { + throw new NotImplementedException (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeOperationAwareRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeOperationAwareRepository.cs deleted file mode 100644 index e3e769d494..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeOperationAwareRepository.cs +++ /dev/null @@ -1,76 +0,0 @@ -//
-// FakeOperationAwareRepository.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 NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- public class FakeOperationAwarePackageRepository : FakePackageRepository, IOperationAwareRepository, IDisposable
- {
- public string OperationStarted;
- public string MainPackageIdForOperationStarted;
- public string MainPackageVersionForOperationStarted;
-
- public IDisposable StartOperation (string operationName, string mainPackageId, string mainPackageVersion)
- {
- OperationStarted = operationName;
- MainPackageIdForOperationStarted = mainPackageId;
- MainPackageVersionForOperationStarted = mainPackageVersion;
- return this;
- }
-
- public void AssertOperationWasStartedAndDisposed (string expectedOperationName, string expectedMainPackageId)
- {
- Assert.AreEqual (expectedOperationName, OperationStarted);
- Assert.AreEqual (expectedMainPackageId, MainPackageIdForOperationStarted);
- AssertOperationIsDisposed ();
- }
-
- public void AssertOperationWasStartedAndDisposed (string expectedOperationName, string expectedMainPackageId, string expectedMainPackageVersion)
- {
- Assert.AreEqual (expectedOperationName, OperationStarted);
- Assert.AreEqual (expectedMainPackageId, MainPackageIdForOperationStarted);
- Assert.AreEqual (expectedMainPackageVersion, MainPackageVersionForOperationStarted);
- AssertOperationIsDisposed ();
- }
-
- void AssertOperationIsDisposed ()
- {
- Assert.IsTrue (IsDisposed);
- }
-
- public bool IsDisposed;
-
- public void Dispose ()
- {
- IsDisposed = true;
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackage.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackage.cs index b621fe6bd4..ffd3997abb 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackage.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackage.cs @@ -28,12 +28,11 @@ using System; using System.Collections.Generic;
using System.IO;
using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
using NuGet;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
- public class FakePackage : IPackageFromRepository
+ public class FakePackage : IPackage
{
public Stream Stream = null;
public List<string> AuthorsList = new List<string> ();
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 deleted file mode 100644 index eb9318b244..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProject.cs +++ /dev/null @@ -1,410 +0,0 @@ -//
-// FakePackageManagementProject.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 System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageManagementProject : IPackageManagementProject
- {
- public FakePackageManagementProject ()
- : this ("Test")
- {
- }
-
- public FakePackageManagementProject (string name)
- {
- FakeUninstallPackageAction = new FakeUninstallPackageAction (this) {
- Logger = new FakeLogger ()
- };
-
- FindPackageAction = packageId => {
- 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;
- UpdateDependenciesPassedToUpdatePackage = updateAction.UpdateDependencies;
- AllowPrereleaseVersionsPassedToUpdatePackage = updateAction.AllowPrereleaseVersions;
- IsUpdatePackageCalled = true;
- };
-
- UninstallPackageAction = (package, uninstallAction) => {
- PackagePassedToUninstallPackage = package;
- ForceRemovePassedToUninstallPackage = uninstallAction.ForceRemove;
- RemoveDependenciesPassedToUninstallPackage = uninstallAction.RemoveDependencies;
- };
-
- CreateUninstallPackageActionFunc = () => FakeUninstallPackageAction;
-
- this.Name = name;
-
- ConstraintProvider = NullConstraintProvider.Instance;
- }
-
- public FakeUninstallPackageAction FakeUninstallPackageAction;
-
- public FakeUpdatePackageAction FirstFakeUpdatePackageActionCreated {
- get { return FakeUpdatePackageActionsCreated [0]; }
- }
-
- public FakeUpdatePackageAction SecondFakeUpdatePackageActionCreated {
- get { return FakeUpdatePackageActionsCreated [1]; }
- }
-
- public List<FakeUpdatePackageAction> FakeUpdatePackageActionsCreated =
- new List<FakeUpdatePackageAction> ();
-
- public string Name {
- get { return FakeDotNetProject.Name; }
- set { FakeDotNetProject.Name = value; }
- }
-
- public bool IsPackageInstalled (string packageId)
- {
- return FakePackages.Any (p => p.Id == packageId);
- }
-
- public bool IsPackageInstalled (IPackage package)
- {
- return FakePackages.Contains (package);
- }
-
- public List<FakePackage> FakePackages = new List<FakePackage> ();
-
- public IQueryable<IPackage> GetPackages ()
- {
- return FakePackages.AsQueryable ();
- }
-
- public List<FakePackageOperation> FakeInstallOperations = new List<FakePackageOperation> ();
- public IPackage PackagePassedToGetInstallPackageOperations;
- public bool IgnoreDependenciesPassedToGetInstallPackageOperations;
- public bool AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- public virtual IEnumerable<PackageOperation> GetInstallPackageOperations (IPackage package, InstallPackageAction installAction)
- {
- PackagePassedToGetInstallPackageOperations = package;
- IgnoreDependenciesPassedToGetInstallPackageOperations = installAction.IgnoreDependencies;
- AllowPrereleaseVersionsPassedToGetInstallPackageOperations = installAction.AllowPrereleaseVersions;
-
- return FakeInstallOperations;
- }
-
- public ILogger Logger { get; set; }
-
- public IPackage PackagePassedToInstallPackage;
- public IEnumerable<PackageOperation> PackageOperationsPassedToInstallPackage;
- public bool IgnoreDependenciesPassedToInstallPackage;
- public bool AllowPrereleaseVersionsPassedToInstallPackage;
-
- public Action<IPackage, InstallPackageAction> InstallPackageAction;
-
- public void InstallPackage (IPackage package, InstallPackageAction installAction)
- {
- InstallPackageAction (package, installAction);
- }
-
- public FakePackageOperation AddFakeInstallOperation ()
- {
- var package = new FakePackage ("MyPackage");
- var operation = new FakePackageOperation (package, PackageAction.Install);
- FakeInstallOperations.Add (operation);
- return operation;
- }
-
- public FakePackageOperation AddFakeUninstallOperation ()
- {
- var package = new FakePackage ("MyPackage");
- var operation = new FakePackageOperation (package, PackageAction.Uninstall);
- FakeInstallOperations.Add (operation);
- return operation;
- }
-
- public FakePackageRepository FakeSourceRepository = new FakePackageRepository ();
-
- public IPackageRepository SourceRepository {
- get { return FakeSourceRepository; }
- }
-
- public IPackage PackagePassedToUninstallPackage;
- public bool ForceRemovePassedToUninstallPackage;
- public bool RemoveDependenciesPassedToUninstallPackage;
-
- public void UninstallPackage (IPackage package, UninstallPackageAction uninstallAction)
- {
- UninstallPackageAction (package, uninstallAction);
- }
-
- public Action<IPackage, UninstallPackageAction> UninstallPackageAction;
-
- public IPackage PackagePassedToUpdatePackage;
- public IEnumerable<PackageOperation> PackageOperationsPassedToUpdatePackage;
- public bool UpdateDependenciesPassedToUpdatePackage;
- public bool AllowPrereleaseVersionsPassedToUpdatePackage;
- public bool IsUpdatePackageCalled;
-
- public void UpdatePackage (IPackage package, UpdatePackageAction updateAction)
- {
- UpdatePackageAction (package, updateAction);
- }
-
- public Action<IPackage, UpdatePackageAction> UpdatePackageAction;
-
- public FakeInstallPackageAction LastInstallPackageCreated;
-
- public Action InstallPackageExecuteAction = () => { };
-
- public virtual InstallPackageAction CreateInstallPackageAction ()
- {
- LastInstallPackageCreated = new FakeInstallPackageAction (this);
- LastInstallPackageCreated.ExecuteAction = InstallPackageExecuteAction;
- return LastInstallPackageCreated;
- }
-
- public virtual UninstallPackageAction CreateUninstallPackageAction ()
- {
- return CreateUninstallPackageActionFunc ();
- }
-
- public Func<UninstallPackageAction> CreateUninstallPackageActionFunc;
-
- public UpdatePackageAction CreateUpdatePackageAction ()
- {
- var action = new FakeUpdatePackageAction (this);
- FakeUpdatePackageActionsCreated.Add (action);
- return action;
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageInstalled;
-
- public void FirePackageInstalledEvent (PackageOperationEventArgs e)
- {
- if (PackageInstalled != null) {
- PackageInstalled (this, e);
- }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageUninstalled;
-
- public void FirePackageUninstalledEvent (PackageOperationEventArgs e)
- {
- if (PackageUninstalled != null) {
- PackageUninstalled (this, e);
- }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageReferenceAdded;
-
- public void FirePackageReferenceAddedEvent (PackageOperationEventArgs e)
- {
- if (PackageReferenceAdded != null) {
- PackageReferenceAdded (this, e);
- }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageReferenceRemoving;
-
- public void FirePackageReferenceRemovingEvent (PackageOperationEventArgs e)
- {
- if (PackageReferenceRemoving != null) {
- PackageReferenceRemoving (this, e);
- }
- }
-
- public List<FakePackage> FakePackagesInReverseDependencyOrder =
- new List<FakePackage> ();
-
- public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder ()
- {
- return FakePackagesInReverseDependencyOrder;
- }
-
- public void AddFakePackage (string id)
- {
- FakePackages.Add (new FakePackage (id));
- }
-
- public FakePackage AddFakePackage (string id, string version)
- {
- return AddFakePackage (new FakePackage (id, version));
- }
-
- public FakePackage AddFakePackage (FakePackage package)
- {
- FakePackages.Add (package);
- return package;
- }
-
- public void AddFakePackageToSourceRepository (string packageId)
- {
- FakeSourceRepository.AddFakePackage (packageId);
- }
-
- public FakePackage AddFakePackageToSourceRepository (string packageId, string version)
- {
- return FakeSourceRepository.AddFakePackageWithVersion (packageId, version);
- }
-
- public void UpdatePackages (UpdatePackagesAction action)
- {
- }
-
- public List<UpdatePackagesAction> UpdatePackagesActionsCreated =
- new List<UpdatePackagesAction> ();
-
- public UpdatePackagesAction CreateUpdatePackagesAction ()
- {
- var action = new UpdatePackagesAction (this, null);
- UpdatePackagesActionsCreated.Add (action);
- return action;
- }
-
- public UpdatePackagesAction UpdatePackagesActionPassedToGetUpdatePackagesOperations;
- public IUpdatePackageSettings SettingsPassedToGetUpdatePackagesOperations;
- public List<IPackage> PackagesOnUpdatePackagesActionPassedToGetUpdatePackagesOperations;
- public List<PackageOperation> PackageOperationsToReturnFromGetUpdatePackagesOperations =
- new List<PackageOperation> ();
-
- public IEnumerable<PackageOperation> GetUpdatePackagesOperations (
- IEnumerable<IPackage> packages,
- IUpdatePackageSettings settings)
- {
- SettingsPassedToGetUpdatePackagesOperations = settings;
- PackagesOnUpdatePackagesActionPassedToGetUpdatePackagesOperations = packages.ToList ();
- return PackageOperationsToReturnFromGetUpdatePackagesOperations;
- }
-
- public ReinstallPackageOperations ReinstallOperations;
- public IEnumerable<IPackage> PackagesPassedToGetReinstallPackageOperations;
-
- public ReinstallPackageOperations GetReinstallPackageOperations (IEnumerable<IPackage> packages)
- {
- PackagesPassedToGetReinstallPackageOperations = packages;
- return ReinstallOperations;
- }
-
- public IEnumerable<PackageOperation> PackageOperationsRun;
-
- public void RunPackageOperations (IEnumerable<PackageOperation> operations)
- {
- PackageOperationsRun = operations;
- }
-
- public bool HasOlderPackageInstalled (IPackage package)
- {
- IPackage matchedPackage = FakePackages.FirstOrDefault (p => p.Id == package.Id);
- if (matchedPackage != null) {
- return matchedPackage.Version < package.Version;
- }
- return false;
- }
-
- public void UpdatePackageReference (IPackage package, IUpdatePackageSettings settings)
- {
- throw new NotImplementedException ();
- }
-
- #pragma warning disable 0067
- public event EventHandler<PackageOperationEventArgs> PackageReferenceRemoved;
- #pragma warning restore 0067
-
- public Func<string, IPackage> FindPackageAction;
-
- public IPackage FindPackage (string packageId)
- {
- return FindPackageAction (packageId);
- }
-
- public FrameworkName TargetFramework { get; set; }
-
- public DotNetProject DotNetProject {
- get {
- throw new NotImplementedException ();
- }
- }
-
- public ReinstallPackageAction CreateReinstallPackageAction ()
- {
- var action = new ReinstallPackageAction (this, new PackageManagementEvents ());
- ReinstallPackageActionsCreated.Add (action);
- return action;
- }
-
- public List<ReinstallPackageAction> ReinstallPackageActionsCreated = new List<ReinstallPackageAction> ();
-
- public List<IPackage> PackageReferencesAdded = new List<IPackage> ();
-
- public void AddPackageReference (IPackage package)
- {
- PackageReferencesAdded.Add (package);
- }
-
- public FakeDotNetProject FakeDotNetProject = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj");
-
- public IDotNetProject Project {
- get { return FakeDotNetProject; }
- }
-
- FakeProjectManager projectManager = new FakeProjectManager ();
-
- public List<PackageReference> PackageReferences {
- get { return projectManager.PackageReferences; }
- }
-
- public PackageReference AddPackageReference (string packageId, string packageVersion)
- {
- return projectManager.AddPackageReference (packageId, packageVersion);
- }
-
- public IEnumerable<PackageReference> GetPackageReferences ()
- {
- return PackageReferences;
- }
-
- public bool AnyUnrestoredPackages ()
- {
- throw new NotImplementedException ();
- }
-
- public IPackageConstraintProvider ConstraintProvider { get; set; }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectFactory.cs deleted file mode 100644 index 4fb30c6769..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectFactory.cs +++ /dev/null @@ -1,80 +0,0 @@ -//
-// FakePackageManagementProjectFactory.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageManagementProjectFactory : IPackageManagementProjectFactory
- {
- public FakePackageManagementProjectFactory ()
- {
- CreatePackageManagementProject = (sourceRepository, project) => {
- RepositoriesPassedToCreateProject.Add (sourceRepository);
- ProjectsPassedToCreateProject.Add (project);
-
- var fakeProject = new FakePackageManagementProject ();
- FakeProjectsCreated.Add (fakeProject);
- return fakeProject;
- };
- }
-
- public List<FakePackageManagementProject> FakeProjectsCreated =
- new List<FakePackageManagementProject> ();
-
- public FakePackageManagementProject FirstFakeProjectCreated {
- get { return FakeProjectsCreated [0]; }
- }
-
- public IPackageRepository FirstRepositoryPassedToCreateProject {
- get { return RepositoriesPassedToCreateProject [0]; }
- }
-
- public List<IPackageRepository> RepositoriesPassedToCreateProject =
- new List<IPackageRepository> ();
-
- public IDotNetProject FirstProjectPassedToCreateProject {
- get { return ProjectsPassedToCreateProject [0]; }
- }
-
- public Func<IPackageRepository, IDotNetProject, FakePackageManagementProject>
- CreatePackageManagementProject = (sourceRepository, project) => {
- return null;
- };
-
- public List<IDotNetProject> ProjectsPassedToCreateProject =
- new List<IDotNetProject> ();
-
- public IPackageManagementProject CreateProject (IPackageRepository sourceRepository, IDotNetProject project)
- {
- return CreatePackageManagementProject (sourceRepository, project);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectService.cs index 3832caaf4e..41978875ea 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementProjectService.cs @@ -50,11 +50,6 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers return OpenProjects;
}
- public IProjectBrowserUpdater CreateProjectBrowserUpdater ()
- {
- throw new NotImplementedException ();
- }
-
Dictionary<string, string> defaultCustomTools = new Dictionary<string, string> ();
public void AddDefaultCustomToolForFileName (string fileName, string customTool)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementSolution.cs deleted file mode 100644 index f2495b0445..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagementSolution.cs +++ /dev/null @@ -1,228 +0,0 @@ -//
-// FakePackageManagementSolution.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageManagementSolution : IPackageManagementSolution
- {
- public void AddPackageToActiveProjectLocalRepository (FakePackage package)
- {
- FakeActiveProject.FakePackages.Add (package);
- }
-
- public FakePackage AddPackageToActiveProjectLocalRepository (string packageId)
- {
- var package = new FakePackage (packageId);
- AddPackageToActiveProjectLocalRepository (package);
- return package;
- }
-
- public int GetActiveProjectCallCount;
- public FakePackageManagementProject FakeActiveProject = new FakePackageManagementProject ();
- public bool IsGetActiveProjectWithNoParametersCalled;
-
- public virtual IPackageManagementProject GetActiveProject ()
- {
- GetActiveProjectCallCount++;
- IsGetActiveProjectWithNoParametersCalled = true;
-
- return FakeActiveProject;
- }
-
- public IPackageRepository RepositoryPassedToGetActiveProject;
-
- public virtual IPackageManagementProject GetActiveProject (IPackageRepository sourceRepository)
- {
- RepositoryPassedToGetActiveProject = sourceRepository;
- return FakeActiveProject;
- }
-
- public FakePackageManagementProject FakeProjectToReturnFromGetProject =
- new FakePackageManagementProject ();
-
- public PackageSource PackageSourcePassedToGetProject;
- public string ProjectNamePassedToGetProject;
-
- public IPackageManagementProject GetProject (PackageSource source, string projectName)
- {
- PackageSourcePassedToGetProject = source;
- ProjectNamePassedToGetProject = projectName;
- return FakeProjectToReturnFromGetProject;
- }
-
- public IPackageRepository RepositoryPassedToGetProject;
-
- public IPackageManagementProject GetProject (IPackageRepository sourceRepository, string projectName)
- {
- RepositoryPassedToGetProject = sourceRepository;
- ProjectNamePassedToGetProject = projectName;
- return FakeProjectToReturnFromGetProject;
- }
-
- public IDotNetProject ProjectPassedToGetProject;
- public List<IDotNetProject> ProjectsPassedToGetProject = new List<IDotNetProject> ();
- public Dictionary<string, FakePackageManagementProject> FakeProjectsToReturnFromGetProject
- = new Dictionary<string, FakePackageManagementProject> ();
-
- public virtual IPackageManagementProject GetProject (IPackageRepository sourceRepository, IDotNetProject project)
- {
- RepositoryPassedToGetProject = sourceRepository;
- ProjectPassedToGetProject = project;
- ProjectsPassedToGetProject.Add (project);
- FakePackageManagementProject fakeProject = null;
- if (FakeProjectsToReturnFromGetProject.TryGetValue (project.Name, out fakeProject)) {
- return fakeProject;
- }
- return FakeProjectToReturnFromGetProject;
- }
-
- public FakeDotNetProject FakeActiveDotNetProject;
-
- public IDotNetProject GetActiveDotNetProject ()
- {
- return FakeActiveDotNetProject;
- }
-
- public List<FakeDotNetProject> FakeDotNetProjects = new List<FakeDotNetProject> ();
-
- public IEnumerable<IDotNetProject> GetDotNetProjects ()
- {
- return FakeDotNetProjects;
- }
-
- public bool IsOpen { get; set; }
-
- public bool HasMultipleProjects ()
- {
- return FakeDotNetProjects.Count > 1;
- }
-
- public string FileName { get; set; }
-
- public List<FakePackage> FakeInstalledPackages = new List<FakePackage> ();
-
- public bool IsPackageInstalled (IPackage package)
- {
- return FakeInstalledPackages.Contains (package);
- }
-
- public IQueryable<IPackage> GetPackages ()
- {
- return FakeInstalledPackages.AsQueryable ();
- }
-
- public void NoProjectsSelected ()
- {
- FakeActiveProject = null;
- FakeActiveDotNetProject = null;
- }
-
- public FakePackageManagementProject AddFakeProjectToReturnFromGetProject (string name)
- {
- var project = new FakePackageManagementProject (name);
- FakeProjectsToReturnFromGetProject.Add (name, project);
- return project;
- }
-
- public List<FakePackage> FakePackagesInReverseDependencyOrder =
- new List<FakePackage> ();
-
- public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder ()
- {
- return FakePackagesInReverseDependencyOrder;
- }
-
- public List<FakePackageManagementProject> FakeProjects =
- new List<FakePackageManagementProject> ();
-
- public IPackageRepository SourceRepositoryPassedToGetProjects;
-
- public IEnumerable<IPackageManagementProject> GetProjects (IPackageRepository sourceRepository)
- {
- SourceRepositoryPassedToGetProjects = sourceRepository;
- return FakeProjects;
- }
-
- public FakePackageManagementProject AddFakeProject (string projectName)
- {
- var project = new FakePackageManagementProject (projectName);
- FakeProjects.Add (project);
- return project;
- }
-
- public FakePackage AddPackageToSharedLocalRepository (string packageId, string version)
- {
- var package = new FakePackage (packageId, version);
- FakeInstalledPackages.Add (package);
- return package;
- }
-
- public FakePackage AddPackageToSharedLocalRepository (string packageId)
- {
- var package = new FakePackage (packageId);
- FakeInstalledPackages.Add (package);
- return package;
- }
-
- public string GetInstallPath (IPackage package)
- {
- throw new NotImplementedException ();
- }
-
- public FakeSolutionPackageRepository SolutionPackageRepository = new FakeSolutionPackageRepository ();
-
- public ISolutionPackageRepository GetRepository ()
- {
- return SolutionPackageRepository;
- }
-
- public bool IsPackageRestored (string packageId, SemanticVersion packageVersion)
- {
- return FakeInstalledPackages.Any (package => {
- return (package.Id == packageId) &&
- (package.Version == packageVersion);
- });
- }
-
- public void AddPackageReference (string packageId, string packageVersion)
- {
- SolutionPackageRepository.AddPackageReference (packageId, packageVersion);
- }
-
- public IPackageManagementProject GetProject (IDotNetProject project)
- {
- return FakeActiveProject;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManager.cs deleted file mode 100644 index 21f358b016..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManager.cs +++ /dev/null @@ -1,264 +0,0 @@ -//
-// FakePackageManager.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 System.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageManager : IMonoDevelopPackageManager
- {
- public FakeProjectManager FakeProjectManager = new FakeProjectManager ();
- public FakePackageManagementProjectService FakeProjectService = new FakePackageManagementProjectService ();
-
- public IPackage PackagePassedToInstallPackage;
- public bool IgnoreDependenciesPassedToInstallPackage;
- public bool AllowPrereleaseVersionsPassedToInstallPackage;
-
- public IPackage PackagePassedToUninstallPackage;
-
- public UpdatePackagesAction UpdatePackagesActionsPassedToUpdatePackages;
-
- #pragma warning disable 67
- public event EventHandler<PackageOperationEventArgs> PackageInstalled;
- public event EventHandler<PackageOperationEventArgs> PackageInstalling;
- public event EventHandler<PackageOperationEventArgs> PackageUninstalled;
- public event EventHandler<PackageOperationEventArgs> PackageUninstalling;
- #pragma warning restore 67
-
- public IFileSystem FileSystem {
- get { return FakeFileSystem; }
- set { FakeFileSystem = value as FakeFileSystem; }
- }
-
- public FakeFileSystem FakeFileSystem = new FakeFileSystem ();
-
- public IPackageRepository LocalRepository { get; set; }
-
- public ILogger Logger { get; set; }
-
- public IPackageRepository SourceRepository { get; set; }
-
- public IMonoDevelopProjectManager ProjectManager { get; set; }
-
- public FakePackageRepository FakeSourceRepository = new FakePackageRepository ();
-
- public FakePackageManager ()
- {
- ProjectManager = FakeProjectManager;
- SourceRepository = FakeSourceRepository;
- }
-
- public bool ForceRemovePassedToUninstallPackage;
- public bool RemoveDependenciesPassedToUninstallPackage;
-
- public void UninstallPackage (IPackage package, UninstallPackageAction uninstallAction)
- {
- PackagePassedToUninstallPackage = package;
- ForceRemovePassedToUninstallPackage = uninstallAction.ForceRemove;
- RemoveDependenciesPassedToUninstallPackage = uninstallAction.RemoveDependencies;
- }
-
- public void UninstallPackage (IPackage package, bool forceRemove, bool removeDependencies)
- {
- throw new NotImplementedException ();
- }
-
- public IEnumerable<PackageOperation> PackageOperationsPassedToInstallPackage;
-
- public void InstallPackage (IPackage package, InstallPackageAction installAction)
- {
- PackagePassedToInstallPackage = package;
-
- IgnoreDependenciesPassedToInstallPackage = installAction.IgnoreDependencies;
- PackageOperationsPassedToInstallPackage = installAction.Operations;
- AllowPrereleaseVersionsPassedToInstallPackage = installAction.AllowPrereleaseVersions;
- }
-
- public List<PackageOperation> PackageOperationsToReturnFromGetInstallPackageOperations = new List<PackageOperation> ();
- public IPackage PackagePassedToGetInstallPackageOperations;
- public bool IgnoreDependenciesPassedToGetInstallPackageOperations;
- public bool AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- public IEnumerable<PackageOperation> GetInstallPackageOperations (IPackage package, InstallPackageAction installAction)
- {
- PackagePassedToGetInstallPackageOperations = package;
- IgnoreDependenciesPassedToGetInstallPackageOperations = installAction.IgnoreDependencies;
- AllowPrereleaseVersionsPassedToGetInstallPackageOperations = installAction.AllowPrereleaseVersions;
- return PackageOperationsToReturnFromGetInstallPackageOperations;
- }
-
- public IPackage PackagePassedToUpdatePackage;
- public IEnumerable<PackageOperation> PackageOperationsPassedToUpdatePackage;
- public bool UpdateDependenciesPassedToUpdatePackage;
-
- public void UpdatePackage (IPackage package, UpdatePackageAction updateAction)
- {
- PackagePassedToUpdatePackage = package;
- PackageOperationsPassedToUpdatePackage = updateAction.Operations;
- UpdateDependenciesPassedToUpdatePackage = updateAction.UpdateDependencies;
- AllowPrereleaseVersionsPassedToInstallPackage = updateAction.AllowPrereleaseVersions;
- }
-
- public void FirePackageInstalled (PackageOperationEventArgs e)
- {
- PackageInstalled (this, e);
- }
-
- public void FirePackageUninstalled (PackageOperationEventArgs e)
- {
- PackageUninstalled (this, e);
- }
-
- public IPackagePathResolver PathResolver {
- get {
- throw new NotImplementedException ();
- }
- }
-
- public void UpdatePackage (IPackage newPackage, bool updateDependencies)
- {
- throw new NotImplementedException ();
- }
-
- public void UpdatePackage (string packageId, IVersionSpec versionSpec, bool updateDependencies)
- {
- throw new NotImplementedException ();
- }
-
- public void InstallPackage (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public void InstallPackage (string packageId, SemanticVersion version, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public void UpdatePackage (IPackage newPackage, bool updateDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public void UpdatePackage (string packageId, SemanticVersion version, bool updateDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public void UpdatePackage (string packageId, IVersionSpec versionSpec, bool updateDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public void UninstallPackage (string packageId, SemanticVersion version, bool forceRemove, bool removeDependencies)
- {
- throw new NotImplementedException ();
- }
-
- public void UpdatePackages (UpdatePackagesAction updateAction)
- {
- UpdatePackagesActionsPassedToUpdatePackages = updateAction;
- }
-
- public List<PackageOperation> PackageOperationsToReturnFromGetUpdatePackageOperations = new List<PackageOperation> ();
- public IUpdatePackageSettings SettingsPassedToGetUpdatePackageOperations;
- public IEnumerable<IPackage> PackagesPassedToGetUpdatePackageOperations;
-
- public IEnumerable<PackageOperation> GetUpdatePackageOperations (IEnumerable<IPackage> packages, IUpdatePackageSettings settings)
- {
- SettingsPassedToGetUpdatePackageOperations = settings;
- PackagesPassedToGetUpdatePackageOperations = packages;
- return PackageOperationsToReturnFromGetUpdatePackageOperations;
- }
-
- public List<PackageOperation> PackageOperationsPassedToRunPackageOperations;
-
- public void RunPackageOperations (IEnumerable<PackageOperation> operations)
- {
- PackageOperationsPassedToRunPackageOperations = operations.ToList ();
- }
-
- public IPackage PackagePassedToUpdatePackageReference;
- public IUpdatePackageSettings SettingsPassedToUpdatePackageReference;
-
- public void UpdatePackageReference (IPackage package, IUpdatePackageSettings settings)
- {
- PackagePassedToUpdatePackageReference = package;
- SettingsPassedToUpdatePackageReference = settings;
- }
-
- public bool IgnoreWalkInfoPassedToInstallPackage;
- public bool IsPackageInstalled;
-
- public void InstallPackage (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions, bool ignoreWalkInfo)
- {
- IsPackageInstalled = true;
-
- PackagePassedToInstallPackage = package;
- IgnoreDependenciesPassedToInstallPackage = ignoreDependencies;
- AllowPrereleaseVersionsPassedToInstallPackage = allowPrereleaseVersions;
- IgnoreWalkInfoPassedToInstallPackage = ignoreWalkInfo;
-
- PackagesInstalled.Add (package);
- }
-
- public List<IPackage> PackagesInstalled = new List<IPackage> ();
-
- public DependencyVersion DependencyVersion {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
-
- public bool WhatIf {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
-
- public ReinstallPackageOperations GetReinstallPackageOperations (IEnumerable<IPackage> packages)
- {
- throw new NotImplementedException ();
- }
-
- public void AddPackageReference (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- }
-
- public void InstallPackageIntoSolutionRepository (IPackage package)
- {
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagerFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagerFactory.cs deleted file mode 100644 index a9e07fa479..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageManagerFactory.cs +++ /dev/null @@ -1,57 +0,0 @@ -//
-// FakePackageManagerFactory.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageManagerFactory : IPackageManagerFactory
- {
- public FakePackageManager FakePackageManager = new FakePackageManager ();
- public IPackageRepository PackageRepositoryPassedToCreatePackageManager;
- public IDotNetProject ProjectPassedToCreateRepository;
- public ISolutionPackageRepository SolutionPackageRepositoryPassedToCreatePackageManager;
-
- public IMonoDevelopPackageManager CreatePackageManager (IPackageRepository sourceRepository, IDotNetProject project)
- {
- PackageRepositoryPassedToCreatePackageManager = sourceRepository;
- ProjectPassedToCreateRepository = project;
- return FakePackageManager;
- }
-
- public IPackageManager CreatePackageManager (IPackageRepository sourceRepository, ISolutionPackageRepository solutionPackageRepository)
- {
- PackageRepositoryPassedToCreatePackageManager = sourceRepository;
- SolutionPackageRepositoryPassedToCreatePackageManager = solutionPackageRepository;
- return FakePackageManager;
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataProvider.cs new file mode 100644 index 0000000000..5255095b64 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataProvider.cs @@ -0,0 +1,75 @@ +// +// FakePackageMetadataProvider.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.PackageManagement.UI; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + public class FakePackageMetadataProvider : IPackageMetadataProvider + { + public Task<IPackageSearchMetadata> GetLatestPackageMetadataAsync (PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) + { + throw new NotImplementedException (); + } + + public Task<IPackageSearchMetadata> GetLocalPackageMetadataAsync (PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) + { + throw new NotImplementedException (); + } + + public Task<IPackageSearchMetadata> GetPackageMetadataAsync (PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) + { + throw new NotImplementedException (); + } + + public Task<IEnumerable<IPackageSearchMetadata>> GetPackageMetadataListAsync (string packageId, bool includePrerelease, bool includeUnlisted, CancellationToken cancellationToken) + { + return Task.FromResult (packageMetadataList.AsEnumerable ()); + } + + List<IPackageSearchMetadata> packageMetadataList = new List<IPackageSearchMetadata> (); + + public FakePackageSearchMetadata AddPackageMetadata (string id, string version) + { + var metadata = new FakePackageSearchMetadata { + Identity = new PackageIdentity (id, new NuGetVersion (version)) + }; + + packageMetadataList.Add (metadata); + + return metadata; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/RecentPackageInfoCollectionAssert.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataResource.cs index a005c9fabe..4c554bf0d0 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/RecentPackageInfoCollectionAssert.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataResource.cs @@ -1,53 +1,72 @@ -//
-// RecentPackageInfoCollectionAssert.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- static class RecentPackageInfoCollectionAssert
- {
- public static void AreEqual (IEnumerable<RecentPackageInfo> expectedPackages, IEnumerable<RecentPackageInfo> actualPackages)
- {
- var expectedPackagesAsList = ConvertToStringList (expectedPackages);
- var actualPackagesAsList = ConvertToStringList (actualPackages);
-
- CollectionAssert.AreEqual (expectedPackagesAsList, actualPackagesAsList);
- }
-
- static List<string> ConvertToStringList (IEnumerable<RecentPackageInfo> expectedPackages)
- {
- var items = new List<string> ();
- foreach (RecentPackageInfo recentPackage in expectedPackages) {
- items.Add (recentPackage.ToString ());
- }
- return items;
- }
- }
-}
-
+// +// FakePackageMetadataResource.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Logging; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + public class FakePackageMetadataResource : PackageMetadataResource + { + public override Task<IEnumerable<IPackageSearchMetadata>> GetMetadataAsync (string packageId, bool includePrerelease, bool includeUnlisted, ILogger log, CancellationToken token) + { + var packages = packageMetadataList.Where (p => IsMatch (p, packageId, includePrerelease)); + return Task.FromResult (packages); + } + + static bool IsMatch (IPackageSearchMetadata package, string packageId, bool includePrerelease) + { + if (package.Identity.Id == packageId) { + if (package.Identity.Version.IsPrerelease) { + return includePrerelease; + } + return true; + } + return false; + } + + List<IPackageSearchMetadata> packageMetadataList = new List<IPackageSearchMetadata> (); + + public FakePackageSearchMetadata AddPackageMetadata (string id, string version) + { + var metadata = new FakePackageSearchMetadata { + Identity = new PackageIdentity (id, new NuGetVersion (version)) + }; + + packageMetadataList.Add (metadata); + + return metadata; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUninstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataResourceProvider.cs index 1e5777b56b..ae44af474f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUninstallPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageMetadataResourceProvider.cs @@ -1,54 +1,49 @@ -//
-// FakeUninstallPackageAction.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakeUninstallPackageAction : UninstallPackageAction
- {
- public bool IsExecuted;
-
- public FakeUninstallPackageAction (IPackageManagementProject project)
- : base (project, null)
- {
- }
-
- protected override void ExecuteCore ()
- {
- IsExecuted = true;
- ExecuteAction ();
- }
-
- protected override void BeforeExecute ()
- {
- }
-
- public Action ExecuteAction = () => { };
- }
-}
-
+// +// FakePackageMetadataResourceProvider.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Threading; +using System.Threading.Tasks; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + public class FakePackageMetadataResourceProvider : ResourceProvider + { + public FakePackageMetadataResourceProvider () + : base (typeof(PackageMetadataResource)) + { + } + + public FakePackageMetadataResource PackageMetadataResource = new FakePackageMetadataResource (); + + public override Task<Tuple<bool, INuGetResource>> TryCreate (SourceRepository source, CancellationToken token) + { + return Task.FromResult (Tuple.Create<bool, INuGetResource> (true, PackageMetadataResource)); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageOperationResolverFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageOperationResolverFactory.cs deleted file mode 100644 index 7677db192f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageOperationResolverFactory.cs +++ /dev/null @@ -1,78 +0,0 @@ -//
-// FakePackageOperationResolverFactory.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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageOperationResolverFactory : IPackageOperationResolverFactory
- {
- public FakePackageOperationResolver FakeInstallPackageOperationResolver = new FakePackageOperationResolver ();
- public IPackageRepository LocalRepositoryPassedToCreateInstallPackageOperationsResolver;
- public IPackageRepository SourceRepositoryPassedToCreateInstallPackageOperationsResolver;
- public ILogger LoggerPassedToCreateInstallPackageOperationResolver;
- public bool IgnoreDependenciesPassedToCreateInstallPackageOperationResolver;
- public bool AllowPrereleaseVersionsPassedToCreateInstallPackageOperationResolver;
-
- public IPackageOperationResolver CreateInstallPackageOperationResolver (
- IPackageRepository localRepository,
- IPackageRepository sourceRepository,
- ILogger logger,
- InstallPackageAction installAction)
- {
- LocalRepositoryPassedToCreateInstallPackageOperationsResolver = localRepository;
- SourceRepositoryPassedToCreateInstallPackageOperationsResolver = sourceRepository;
- LoggerPassedToCreateInstallPackageOperationResolver = logger;
- IgnoreDependenciesPassedToCreateInstallPackageOperationResolver = installAction.IgnoreDependencies;
- AllowPrereleaseVersionsPassedToCreateInstallPackageOperationResolver = installAction.AllowPrereleaseVersions;
-
- return FakeInstallPackageOperationResolver;
- }
-
- public IPackageRepository LocalRepositoryPassedToCreateUpdatePackageOperationsResolver;
- public IPackageRepository SourceRepositoryPassedToCreateUpdatePackageOperationsResolver;
- public IPackageOperationResolver UpdatePackageOperationsResolver = new FakePackageOperationResolver ();
- public ILogger LoggerPassedToCreateUpdatePackageOperationResolver;
- public IUpdatePackageSettings SettingsPassedToCreatePackageOperationResolver;
-
- public IPackageOperationResolver CreateUpdatePackageOperationResolver (
- IPackageRepository localRepository,
- IPackageRepository sourceRepository,
- ILogger logger,
- IUpdatePackageSettings settings)
- {
- LocalRepositoryPassedToCreateUpdatePackageOperationsResolver = localRepository;
- SourceRepositoryPassedToCreateUpdatePackageOperationsResolver = sourceRepository;
- LoggerPassedToCreateUpdatePackageOperationResolver = logger;
- SettingsPassedToCreatePackageOperationResolver = settings;
-
- return UpdatePackageOperationsResolver;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepository.cs index 2bd4b437bd..ba7ab5a6cc 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepository.cs @@ -32,7 +32,7 @@ using NuGet; namespace MonoDevelop.PackageManagement.Tests.Helpers
{
- public class FakePackageRepository : IRecentPackageRepository, IProgressProvider, ICloneableRepository
+ public class FakePackageRepository : IPackageRepository, IProgressProvider, ICloneableRepository
{
public List<FakePackage> FakePackages = new List<FakePackage> ();
public bool IsRemovePackageCalled;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepositoryFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepositoryFactory.cs index ab21fc5b7e..b310046b94 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepositoryFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepositoryFactory.cs @@ -26,13 +26,12 @@ using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
using MonoDevelop.PackageManagement.Tests.Helpers;
using NuGet;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
- class FakePackageRepositoryFactory : IPackageRepositoryCache
+ class FakePackageRepositoryFactory : IMonoDevelopPackageRepositoryFactory
{
public List<string> PackageSourcesPassedToCreateRepository
= new List<string> ();
@@ -85,19 +84,6 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers return FakeAggregateRepository;
}
- public FakeRecentPackageRepository FakeRecentPackageRepository = new FakeRecentPackageRepository ();
- public IList<RecentPackageInfo> RecentPackagesPassedToCreateRecentPackageRepository;
- public IPackageRepository AggregateRepositoryPassedToCreateRecentPackageRepository;
-
- public IRecentPackageRepository CreateRecentPackageRepository (
- IList<RecentPackageInfo> recentPackages,
- IPackageRepository aggregateRepository)
- {
- RecentPackagesPassedToCreateRecentPackageRepository = recentPackages;
- AggregateRepositoryPassedToCreateRecentPackageRepository = aggregateRepository;
- return FakeRecentPackageRepository;
- }
-
public IEnumerable<IPackageRepository> RepositoriesPassedToCreateAggregateRepository;
public Func<IEnumerable<IPackageRepository>, IPackageRepository> CreateAggregrateRepositoryAction;
@@ -114,10 +100,6 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers return repository;
}
- public IRecentPackageRepository RecentPackageRepository {
- get { return FakeRecentPackageRepository; }
- }
-
public FakePackageRepository FakePriorityPackageRepository = new FakePackageRepository ();
public IPackageRepository CreateAggregateWithPriorityMachineCacheRepository ()
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRestoreManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRestoreManager.cs new file mode 100644 index 0000000000..584756a346 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRestoreManager.cs @@ -0,0 +1,145 @@ +// +// FakePackageRestoreManager.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Frameworks; +using NuGet.PackageManagement; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakePackageRestoreManager : IPackageRestoreManager + { + public bool IsCurrentSolutionEnabledForRestore { + get { + throw new NotImplementedException (); + } + } + + #pragma warning disable 67 + public event EventHandler<NuGet.PackageManagement.PackageRestoredEventArgs> PackageRestoredEvent; + public event EventHandler<PackageRestoreFailedEventArgs> PackageRestoreFailedEvent; + public event EventHandler<PackagesMissingStatusEventArgs> PackagesMissingStatusChanged; + #pragma warning restore 67 + + public void RaisePackageRestoreFailedEvent (Exception exception, string projectName) + { + var packageReference = new PackageReference ( + new PackageIdentity ("Test", new NuGetVersion ("1.2")), + new NuGetFramework ("any") + ); + var eventArgs = new PackageRestoreFailedEventArgs ( + packageReference, + exception, + new [] { projectName } + ); + PackageRestoreFailedEvent?.Invoke (this, eventArgs); + } + + public void EnableCurrentSolutionForRestore (bool fromActivation) + { + throw new NotImplementedException (); + } + + public Dictionary<string, List<PackageRestoreData>> PackagesInSolution = + new Dictionary<string, List<PackageRestoreData>> (); + + public void AddUnrestoredPackageForProject (string projectName, string solutionDirectory) + { + var packageReference = new PackageReference ( + new PackageIdentity ("Test", new NuGetVersion ("1.0")), + new NuGetFramework ("any")); + + var restoreData = new PackageRestoreData ( + packageReference, + new [] { projectName }, + isMissing: true); + + var restoreDataList = new List<PackageRestoreData> (); + restoreDataList.Add (restoreData); + PackagesInSolution[solutionDirectory] = restoreDataList; + } + + public Task<IEnumerable<PackageRestoreData>> GetPackagesInSolutionAsync ( + string solutionDirectory, + CancellationToken token) + { + List<PackageRestoreData> restoreData = null; + if (!PackagesInSolution.TryGetValue (solutionDirectory, out restoreData)) + restoreData = new List<PackageRestoreData> (); + + return Task.FromResult (restoreData.AsEnumerable ()); + } + + public Task RaisePackagesMissingEventForSolutionAsync (string solutionDirectory, CancellationToken token) + { + throw new NotImplementedException (); + } + + public Task<PackageRestoreResult> RestoreMissingPackagesAsync (string solutionDirectory, IEnumerable<PackageRestoreData> packages, INuGetProjectContext nuGetProjectContext, CancellationToken token) + { + throw new NotImplementedException (); + } + + public string RestoreMissingPackagesSolutionDirectory; + public NuGetProject RestoreMissingPackagesProject; + public INuGetProjectContext RestoreMissingPackagesProjectContext; + public CancellationToken RestoreMissingPackagesCancellationToken; + + public PackageRestoreResult RestoreResult = new PackageRestoreResult (true); + + public Action BeforeRestoreMissingPackagesAsync = () => { }; + + public Task<PackageRestoreResult> RestoreMissingPackagesAsync ( + string solutionDirectory, + NuGetProject nuGetProject, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + RestoreMissingPackagesSolutionDirectory = solutionDirectory; + RestoreMissingPackagesProject = nuGetProject; + RestoreMissingPackagesProjectContext = nuGetProjectContext; + RestoreMissingPackagesCancellationToken = token; + + BeforeRestoreMissingPackagesAsync (); + + return Task.FromResult (RestoreResult); + } + + public Task<PackageRestoreResult> RestoreMissingPackagesInSolutionAsync (string solutionDirectory, INuGetProjectContext nuGetProjectContext, CancellationToken token) + { + throw new NotImplementedException (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/SelectedProjectCollectionAssert.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageSearchMetadata.cs index 166509a9e2..1bf857f1b7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/SelectedProjectCollectionAssert.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageSearchMetadata.cs @@ -1,61 +1,78 @@ -//
-// SelectedProjectCollectionAssert.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- static class SelectedProjectCollectionAssert
- {
- public static void AreEqual (
- IEnumerable<IPackageManagementSelectedProject> expected,
- IEnumerable<IPackageManagementSelectedProject> actual)
- {
- List<string> expectedAsStrings = ConvertToStrings (expected);
- List<string> actualAsStrings = ConvertToStrings (actual);
- CollectionAssert.AreEqual (expectedAsStrings, actualAsStrings);
- }
-
- static List<string> ConvertToStrings (IEnumerable<IPackageManagementSelectedProject> projects)
- {
- var projectsAsString = new List<string> ();
- foreach (IPackageManagementSelectedProject project in projects) {
- string text = String.Format (
- "Name: {0}, IsSelected: {1}, IsEnabled: {2}",
- project.Name,
- project.IsSelected,
- project.IsEnabled);
- projectsAsString.Add (text);
- }
- return projectsAsString;
- }
- }
-}
-
-
+// +// FakePackageSearchMetadata.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading.Tasks; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + public class FakePackageSearchMetadata : IPackageSearchMetadata + { + public string Authors { get; set; } + + public List<PackageDependencyGroup> DependencySetsList = new List<PackageDependencyGroup> (); + + public IEnumerable<PackageDependencyGroup> DependencySets { + get { return DependencySetsList; } + } + + public string Description { get; set; } + + public long? DownloadCount { get; set; } + + public Uri IconUrl { get; set; } + + public PackageIdentity Identity { get; set; } + + public Uri LicenseUrl { get; set; } + + public string Owners { get; set; } + + public Uri ProjectUrl { get; set; } + + public DateTimeOffset? Published { get; set; } + + public Uri ReportAbuseUrl { get; set; } + + public bool RequireLicenseAcceptance { get; set; } + + public string Summary { get; set; } + + public string Tags { get; set; } + + public string Title { get; set; } + + public Task<IEnumerable<VersionInfo>> GetVersionsAsync () + { + throw new NotImplementedException (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageSourceProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageSourceProvider.cs new file mode 100644 index 0000000000..c676994474 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageSourceProvider.cs @@ -0,0 +1,77 @@ +//
+// FakePackageSourceProvider.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using NuGet.Configuration;
+
+namespace MonoDevelop.PackageManagement.Tests.Helpers
+{
+ class FakePackageSourceProvider : IPackageSourceProvider
+ {
+ public List<PackageSource> PackageSources = new List<PackageSource> ();
+ public List<PackageSource> SavedPackageSources;
+ public PackageSource ActivePackageSource; + + public string ActivePackageSourceName { get; set; }
+
+ public event EventHandler PackageSourcesChanged;
+
+ public void FirePackageSourcesChanged ()
+ {
+ PackageSourcesChanged?.Invoke (this, new EventArgs ());
+ }
+
+ public void DisablePackageSource (PackageSource source)
+ {
+ }
+
+ public bool IsPackageSourceEnabled (PackageSource source)
+ {
+ return PackageSources.Any (packageSource => (packageSource == source) && packageSource.IsEnabled);
+ }
+
+ public IEnumerable<PackageSource> LoadPackageSources ()
+ {
+ return PackageSources;
+ }
+
+ public void SaveActivePackageSource (PackageSource source)
+ {
+ ActivePackageSource = source;
+ ActivePackageSourceName = source?.Name;
+ }
+
+ public void SavePackageSources (IEnumerable<PackageSource> sources)
+ {
+ SavedPackageSources = sources.ToList ();
+ PackageSources.Clear ();
+ PackageSources.AddRange (sources);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageViewModelFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageViewModelFactory.cs deleted file mode 100644 index e7866e947b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageViewModelFactory.cs +++ /dev/null @@ -1,72 +0,0 @@ -//
-// FakePackageViewModelFactory.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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakePackageViewModelFactory : IPackageViewModelFactory
- {
- public FakePackageManagementSolution FakeSolution = new FakePackageManagementSolution ();
- PackageManagementEvents packageManagementEvents = new PackageManagementEvents ();
- public FakeLogger FakeLogger = new FakeLogger ();
-
- public PackageViewModel CreatePackageViewModel (IPackageViewModelParent parent, IPackageFromRepository package)
- {
- SelectedProjects = new PackageManagementSelectedProjects (FakeSolution);
- return new PackageViewModel (
- parent,
- package,
- SelectedProjects,
- PackageManagementEvents,
- null,
- FakeLogger);
- }
-
- public IPackageManagementSolution Solution {
- get { return FakeSolution; }
- }
-
- public PackageManagementSelectedProjects SelectedProjects { get; set; }
-
- public ILogger Logger {
- get { return FakeLogger; }
- }
-
- public IPackageManagementEvents PackageManagementEvents {
- get { return packageManagementEvents; }
- }
-
- public IPackageActionRunner PackageActionRunner {
- get {
- throw new NotImplementedException ();
- }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProject.cs index 6debd6da0c..02c3448fe2 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProject.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProject.cs @@ -40,9 +40,12 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public ISolution ParentSolution { get; set; }
public IDictionary ExtendedProperties { get; set; }
+ List<string> flavorGuids;
+
public FakeProject ()
{
ExtendedProperties = new Hashtable ();
+ flavorGuids = new List<string> ();
}
public FakeProject (string fileName)
@@ -66,7 +69,12 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers }
public IEnumerable<string> FlavorGuids {
- get { yield break; }
+ get { return flavorGuids; }
+ }
+
+ public void AddFlavorGuid (string guid)
+ {
+ flavorGuids.Add (guid);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProjectManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProjectManager.cs deleted file mode 100644 index f279c7c4e6..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProjectManager.cs +++ /dev/null @@ -1,241 +0,0 @@ -//
-// FakeProjectManager.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 MonoDevelop.PackageManagement;
-using NuGet;
-using System.Collections.Generic;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- public class FakeProjectManager : IMonoDevelopProjectManager
- {
- public FakePackageRepository FakeLocalRepository {
- get { return LocalRepository as FakePackageRepository; }
- set { LocalRepository = value; }
- }
-
- public FakePackageRepository FakeSourceRepository {
- get { return SourceRepository as FakePackageRepository; }
- set { SourceRepository = value; }
- }
-
- public bool IsInstalledReturnValue;
-
- public FakeProjectManager ()
- {
- LocalRepository = new FakePackageRepository ();
- SourceRepository = new FakePackageRepository ();
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageReferenceAdded;
-
- protected virtual void OnPackageReferenceAdded (IPackage package)
- {
- OnPackageReferenceAdded (new PackageOperationEventArgs (package, null, String.Empty));
- }
-
- protected virtual void OnPackageReferenceAdded (PackageOperationEventArgs eventArgs)
- {
- if (PackageReferenceAdded != null) {
- PackageReferenceAdded (this, eventArgs);
- }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageReferenceRemoved;
-
- protected virtual void OnPackageReferenceRemoved (PackageOperationEventArgs eventArgs)
- {
- if (PackageReferenceRemoved != null) {
- PackageReferenceRemoved (this, eventArgs);
- }
- }
-
- #pragma warning disable 67
- public event EventHandler<PackageOperationEventArgs> PackageReferenceAdding;
- public event EventHandler<PackageOperationEventArgs> PackageReferenceRemoving;
- #pragma warning restore 67
-
- public IPackageRepository LocalRepository { get; set; }
-
- public ILogger Logger { 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 RemovePackageReference (string packageId, bool forceRemove, bool removeDependencies)
- {
- throw new NotImplementedException ();
- }
-
- public IPackage PackagePassedToIsInstalled;
-
- public bool IsInstalled (IPackage package)
- {
- PackagePassedToIsInstalled = package;
- return IsInstalledReturnValue;
- }
-
- public string PackageIdPassedToIsInstalled;
-
- public bool IsInstalled (string packageId)
- {
- PackageIdPassedToIsInstalled = packageId;
- return IsInstalledReturnValue;
- }
-
- public void FirePackageReferenceAdded (IPackage package)
- {
- OnPackageReferenceAdded (package);
- }
-
- public void FirePackageReferenceAdded (PackageOperationEventArgs eventArgs)
- {
- OnPackageReferenceAdded (eventArgs);
- }
-
- public void FirePackageReferenceRemoved (IPackage package)
- {
- FirePackageReferenceRemoved (new PackageOperationEventArgs (package, null, String.Empty));
- }
-
- public void FirePackageReferenceRemoved (PackageOperationEventArgs eventArgs)
- {
- OnPackageReferenceRemoved (eventArgs);
- }
-
- public void AddPackageReference (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public void RemovePackageReference (IPackage package, bool forceRemove, bool removeDependencies)
- {
- throw new NotImplementedException ();
- }
-
- public void AddPackageReference (string packageId, SemanticVersion version, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- string key = packageId + version.ToString ();
- if (addPackageReferenceCallbacks.ContainsKey (key)) {
- Action callback = addPackageReferenceCallbacks [key];
- callback ();
- }
- }
-
- Dictionary<string, Action> addPackageReferenceCallbacks = new Dictionary<string, Action> ();
-
- public void WhenAddPackageReferenceCalled (string id, SemanticVersion version, Action callback)
- {
- string key = id + version.ToString ();
- addPackageReferenceCallbacks.Add (key, callback);
- }
-
- public void UpdatePackageReference (string packageId, SemanticVersion version, bool updateDependencies, bool allowPrereleaseVersions)
- {
- string key = packageId + version.ToString ();
- if (updatePackageReferenceCallbacks.ContainsKey (key)) {
- Action callback = updatePackageReferenceCallbacks [key];
- callback ();
- }
- }
-
- Dictionary<string, Action> updatePackageReferenceCallbacks = new Dictionary<string, Action> ();
-
- public void WhenUpdatePackageReferenceCalled (string id, SemanticVersion version, Action callback)
- {
- string key = id + version.ToString ();
- updatePackageReferenceCallbacks.Add (key, callback);
- }
-
- public void UpdatePackageReference (string packageId, IVersionSpec versionSpec, bool updateDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public IPackage PackagePassedToHasOlderPackageInstalled;
- public bool HasOlderPackageInstalledReturnValue;
-
- public bool HasOlderPackageInstalled (IPackage package)
- {
- PackagePassedToHasOlderPackageInstalled = package;
- return HasOlderPackageInstalledReturnValue;
- }
-
- public DependencyVersion DependencyVersion {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
-
- public bool WhatIf {
- get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
- }
- }
-
- public void UpdatePackageReference (IPackage remotePackage, bool updateDependencies, bool allowPrereleaseVersions)
- {
- throw new NotImplementedException ();
- }
-
- public List<PackageReference> PackageReferences = new List<PackageReference> ();
-
- public PackageReference AddPackageReference (string packageId, string packageVersion)
- {
- var packageReference = new PackageReference (
- packageId,
- new SemanticVersion (packageVersion),
- null,
- null,
- false,
- false);
-
- PackageReferences.Add (packageReference);
-
- return packageReference;
- }
-
- public IEnumerable<PackageReference> GetPackageReferences ()
- {
- return PackageReferences;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRecentPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRecentPackageRepository.cs index fe607f739d..1c5e05ccc7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRecentPackageRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRecentPackageRepository.cs @@ -32,7 +32,7 @@ using NuGet; namespace MonoDevelop.PackageManagement.Tests.Helpers
{
- public class FakeRecentPackageRepository : IRecentPackageRepository
+ public class FakeRecentPackageRepository : IPackageRepository
{
public string Source { get; set; }
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRegisteredPackageRepositories.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRegisteredPackageRepositories.cs deleted file mode 100644 index c7ac9bef61..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeRegisteredPackageRepositories.cs +++ /dev/null @@ -1,134 +0,0 @@ -//
-// FakeRegisteredPackageRepositories.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakeRegisteredPackageRepositories : IRegisteredPackageRepositories
- {
- public FakeRegisteredPackageRepositories ()
- {
- PackageSources = new RegisteredPackageSources (new PackageSource[0]);
- }
-
- public FakePackageRepository FakeActiveRepository = new FakePackageRepository ();
-
- public Func<IPackageRepository> GetActiveRepositoryAction;
-
- public virtual IPackageRepository ActiveRepository {
- get {
- if (GetActiveRepositoryAction != null) {
- return GetActiveRepositoryAction ();
- }
- return FakeActiveRepository;
- }
- }
-
- public FakePackageRepository FakeRecentPackageRepository = new FakePackageRepository ();
-
- public IRecentPackageRepository RecentPackageRepository {
- get { return FakeRecentPackageRepository; }
- }
-
- public bool HasMultiplePackageSources { get; set; }
-
- public PackageSource ActivePackageSource { get; set; }
-
- public RegisteredPackageSources PackageSources { get; set; }
-
- public FakePackageRepository FakePackageRepository = new FakePackageRepository ();
- public PackageSource PackageSourcePassedToCreateRepository;
-
- public IPackageRepository CreateRepository (PackageSource source)
- {
- PackageSourcePassedToCreateRepository = source;
- return FakePackageRepository;
- }
-
- public FakePackageRepository FakeAggregateRepository = new FakePackageRepository ();
-
- public Func<IPackageRepository> CreateAggregateRepositoryAction;
-
- public IPackageRepository CreateAggregateRepository ()
- {
- if (CreateAggregateRepositoryAction != null) {
- return CreateAggregateRepositoryAction ();
- }
- return FakeAggregateRepository;
- }
-
- public void ClearPackageSources ()
- {
- PackageSources.Clear ();
- }
-
- public PackageSource AddOnePackageSource ()
- {
- return AddOnePackageSource ("Test");
- }
-
- public PackageSource AddOnePackageSource (string name)
- {
- var source = new PackageSource ("http://monodevelop.codeplex.com", name);
- PackageSources.Add (source);
- return source;
- }
-
- public void AddPackageSources (IEnumerable<PackageSource> sources)
- {
- PackageSources.AddRange (sources);
- }
-
- public FakePackage AddFakePackageWithVersionToActiveRepository (string version)
- {
- return AddFakePackageWithVersionToActiveRepository ("Test", version);
- }
-
- public FakePackage AddFakePackageWithVersionToActiveRepository (string id, string version)
- {
- var package = FakePackage.CreatePackageWithVersion (id, version);
- FakeActiveRepository.FakePackages.Add (package);
- return package;
- }
-
- public FakePackage AddFakePackageWithVersionToAggregrateRepository (string id, string version)
- {
- var package = FakePackage.CreatePackageWithVersion (id, version);
- FakeAggregateRepository.FakePackages.Add (package);
- return package;
- }
-
- public void UpdatePackageSources (IEnumerable<PackageSource> updatedPackageSources)
- {
- throw new NotImplementedException ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSettings.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSettings.cs index 0ea24e7221..dd79efa0ad 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSettings.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSettings.cs @@ -54,12 +54,13 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public const string PackageSourcesSectionName = "packageSources";
public const string DisabledPackageSourcesSectionName = "disabledPackageSources";
+ public const string ActivePackageSourceSectionName = "activePackageSource";
public const string ConfigSectionName = "config";
public FakeSettings ()
{
Sections.Add (PackageSourcesSectionName, PackageSources);
- Sections.Add (RegisteredPackageSourceSettings.ActivePackageSourceSectionName, ActivePackageSourceSettings);
+ Sections.Add (ActivePackageSourceSectionName, ActivePackageSourceSettings);
Sections.Add (DisabledPackageSourcesSectionName, DisabledPackageSources);
}
@@ -94,7 +95,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public SettingValue GetValuePassedToSetValueForActivePackageSourceSection ()
{
- return SavedSectionValues [RegisteredPackageSourceSettings.ActivePackageSourceSectionName];
+ return SavedSectionValues [ActivePackageSourceSectionName];
}
public void SetValues (string section, IList<SettingValue> values)
@@ -138,7 +139,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public bool IsActivePackageSourceSectionDeleted {
get {
- return SectionsDeleted.Contains (RegisteredPackageSourceSettings.ActivePackageSourceSectionName);
+ return SectionsDeleted.Contains (ActivePackageSourceSectionName);
}
}
@@ -151,8 +152,8 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public void MakeActivePackageSourceSectionNull ()
{
- Sections.Remove (RegisteredPackageSourceSettings.ActivePackageSourceSectionName);
- Sections.Add (RegisteredPackageSourceSettings.ActivePackageSourceSectionName, null);
+ Sections.Remove (ActivePackageSourceSectionName);
+ Sections.Add (ActivePackageSourceSectionName, null);
}
public void MakePackageSourceSectionsNull ()
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProcess.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSettingsProvider.cs index c922d58210..61bdebcaed 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProcess.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSettingsProvider.cs @@ -1,42 +1,49 @@ -//
-// FakeProcess.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- public class FakeProcess : IProcess
- {
- public string FileNamePassedToStart;
-
- public void Start (string fileName)
- {
- FileNamePassedToStart = fileName;
- }
- }
-}
-
+// +// FakeSettingsProvider.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 NuGet; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeSettingsProvider : ISettingsProvider + { + public event EventHandler SettingsChanged; + + void OnSettingsChanged () + { + SettingsChanged?.Invoke (this, new EventArgs ()); + } + + public FakeSettings FakeSettings = new FakeSettings (); + + public ISettings LoadSettings () + { + return FakeSettings; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSharedPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSharedPackageRepository.cs index f4ecfeec9b..3f7d1beca1 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSharedPackageRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSharedPackageRepository.cs @@ -65,6 +65,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
throw new NotImplementedException ();
}
+
+ public Action BeforeGetPackagesAction = () => { };
+
+ public override IQueryable<IPackage> GetPackages () + {
+ BeforeGetPackagesAction (); + return base.GetPackages (); + }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs index 38b766b63f..b834a33f50 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolution.cs @@ -74,6 +74,11 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers ProjectRemoved (this, new DotNetProjectEventArgs (project));
}
}
+
+ public bool Equals (ISolution solution)
+ {
+ return this == solution;
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolutionManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolutionManager.cs new file mode 100644 index 0000000000..8691c441d8 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolutionManager.cs @@ -0,0 +1,144 @@ +// +// FakeSolutionManager.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using NuGet.Configuration; +using NuGet.PackageManagement; +using NuGet.ProjectManagement; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeSolutionManager : IMonoDevelopSolutionManager + { + public FakeSolutionManager () + { + SolutionDirectory = @"d:\projects\MyProject".ToNativePath (); + } + + public NuGetProject DefaultNuGetProject { + get { + throw new NotImplementedException (); + } + } + + public string DefaultNuGetProjectName { + get { + throw new NotImplementedException (); + } + + set { + throw new NotImplementedException (); + } + } + + public bool IsSolutionAvailable { + get { + throw new NotImplementedException (); + } + } + + public bool IsSolutionOpen { + get { + throw new NotImplementedException (); + } + } + + public INuGetProjectContext NuGetProjectContext { + get { + throw new NotImplementedException (); + } + + set { + throw new NotImplementedException (); + } + } + + public FakeNuGetSettings FakeSettings = new FakeNuGetSettings (); + + public ISettings Settings { + get { return FakeSettings; } + } + + public string SolutionDirectory { get; set; } + + #pragma warning disable 67 + public event EventHandler<ActionsExecutedEventArgs> ActionsExecuted; + public event EventHandler<NuGetProjectEventArgs> NuGetProjectAdded; + public event EventHandler<NuGetProjectEventArgs> NuGetProjectRemoved; + public event EventHandler<NuGetProjectEventArgs> NuGetProjectRenamed; + public event EventHandler SolutionClosed; + public event EventHandler SolutionClosing; + public event EventHandler SolutionOpened; + public event EventHandler SolutionOpening; + #pragma warning restore 67 + + public FakeSourceRepositoryProvider SourceRepositoryProvider = new FakeSourceRepositoryProvider (); + + public ISourceRepositoryProvider CreateSourceRepositoryProvider () + { + return SourceRepositoryProvider; + } + + public NuGetProject GetNuGetProject (string nuGetProjectSafeName) + { + throw new NotImplementedException (); + } + + public Dictionary<IDotNetProject, FakeNuGetProject> NuGetProjects = new Dictionary<IDotNetProject, FakeNuGetProject> (); + + public NuGetProject GetNuGetProject (IDotNetProject project) + { + FakeNuGetProject nugetProject = null; + if (NuGetProjects.TryGetValue (project, out nugetProject)) + return nugetProject; + + return new FakeNuGetProject (project); + } + + public IEnumerable<NuGetProject> GetNuGetProjects () + { + throw new NotImplementedException (); + } + + public string GetNuGetProjectSafeName (NuGetProject nuGetProject) + { + throw new NotImplementedException (); + } + + public void OnActionsExecuted (IEnumerable<ResolvedAction> actions) + { + throw new NotImplementedException (); + } + + public void ReloadSettings () + { + throw new NotImplementedException (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PageCollectionAssert.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSourceRepositoryProvider.cs index cd87754a84..9a8e485526 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PageCollectionAssert.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSourceRepositoryProvider.cs @@ -1,60 +1,65 @@ -//
-// PageCollectionAssert.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- static class PageCollectionAssert
- {
- public static void AreEqual (IEnumerable<Page> expectedPages, IEnumerable<Page> actualPages)
- {
- List<string> convertedExpectedPages = ConvertToStrings (expectedPages);
- List<string> convertedActualPages = ConvertToStrings (actualPages);
-
- CollectionAssert.AreEqual (convertedExpectedPages, convertedActualPages);
- }
-
- static List<string> ConvertToStrings (IEnumerable<Page> pages)
- {
- List<string> pagesAsText = new List<string> ();
- foreach (Page page in pages) {
- pagesAsText.Add (GetPageAsString (page));
- }
- return pagesAsText;
- }
-
- static string GetPageAsString (Page page)
- {
- return String.Format ("Page: Number: {0}, IsSelected: {1}",
- page.Number,
- page.IsSelected);
- }
- }
-}
+// +// FakeSourceRepositoryProvider.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using NuGet.Configuration; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class FakeSourceRepositoryProvider : ISourceRepositoryProvider + { + public List<SourceRepository> Repositories = new List<SourceRepository> (); + public FakePackageSourceProvider FakePackageSourceProvider = new FakePackageSourceProvider (); + + public IPackageSourceProvider PackageSourceProvider { + get { return FakePackageSourceProvider; } + } + + public SourceRepository CreateRepository (PackageSource source) + { + return new SourceRepository (source, new INuGetResourceProvider[0]); + } + + public IEnumerable<SourceRepository> GetRepositories () + { + return Repositories; + } + + public void AddRepositories (IEnumerable<PackageSource> sources) + { + foreach (PackageSource source in sources) { + AddRepository (source); + } + } + + public void AddRepository (PackageSource source) + { + Repositories.Add (CreateRepository (source)); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeTaskFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeTaskFactory.cs deleted file mode 100644 index 4f6fcfa20e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeTaskFactory.cs +++ /dev/null @@ -1,80 +0,0 @@ -//
-// FakeTaskFactory.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakeTaskFactory : ITaskFactory
- {
- public bool IsCreateTaskCalled;
- public bool RunTasksSynchronously;
-
- public FakeTask<PackagesForSelectedPageResult> FirstFakeTaskCreated {
- get { return FakeTasksCreated [0] as FakeTask<PackagesForSelectedPageResult>; }
- }
-
- public List<object> FakeTasksCreated = new List<object> ();
-
- public ITask<TResult> CreateTask<TResult> (
- Func<TResult> function,
- Action<ITask<TResult>> continueWith)
- {
- IsCreateTaskCalled = true;
- var task = new FakeTask<TResult> (function, continueWith, RunTasksSynchronously);
- FakeTasksCreated.Add (task);
- return task;
- }
-
- public void ExecuteAllFakeTasks ()
- {
- foreach (FakeTask<PackagesForSelectedPageResult> task in FakeTasksCreated) {
- task.ExecuteTaskCompletely ();
- }
- }
-
- public void ExecuteAllTasks<T> ()
- {
- foreach (FakeTask<T> task in FakeTasksCreated) {
- task.ExecuteTaskCompletely ();
- }
- }
-
- public void ExecuteTask (int index)
- {
- var task = FakeTasksCreated [index] as FakeTask<PackagesForSelectedPageResult>;
- task.ExecuteTaskCompletely ();
- }
-
- public void ClearAllFakeTasks ()
- {
- FakeTasksCreated.Clear ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatePackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatePackageAction.cs deleted file mode 100644 index 5da205d6dd..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatePackageAction.cs +++ /dev/null @@ -1,73 +0,0 @@ -//
-// FakeUpdatePackageAction.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakeUpdatePackageAction : UpdatePackageAction
- {
- public bool IsExecuted;
-
- public FakePackageManagementProject FakeProject;
- public FakeFileRemover FileRemover;
- public FakeLicenseAcceptanceService LicenseAcceptanceService;
-
- public FakeUpdatePackageAction ()
- : this (new FakePackageManagementProject ())
- {
- }
-
- public FakeUpdatePackageAction (IPackageManagementProject project)
- : this (project, null, new FakeFileRemover (), new FakeLicenseAcceptanceService ())
- {
- FakeProject = project as FakePackageManagementProject;
- }
-
- public FakeUpdatePackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- FakeFileRemover fileRemover,
- FakeLicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents, fileRemover, licenseAcceptanceService)
- {
- FakeProject = project as FakePackageManagementProject;
- FileRemover = fileRemover;
- LicenseAcceptanceService = licenseAcceptanceService;
- }
-
- protected override void ExecuteCore ()
- {
- IsExecuted = true;
- }
-
- protected override void BeforeExecute ()
- {
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatedPackagesInSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatedPackagesInWorkspace.cs index 2f940c8df0..fa66a3e91d 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatedPackagesInSolution.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeUpdatedPackagesInWorkspace.cs @@ -1,5 +1,5 @@ //
-// UpdatedPackagesInSolution.cs
+// FakeUpdatedPackagesInWorkspace.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
@@ -24,20 +24,19 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
using System.Linq;
-using NuGet;
+using NuGet.Packaging.Core;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
- class FakeUpdatedPackagesInSolution : IUpdatedPackagesInSolution
+ class FakeUpdatedPackagesInWorkspace : IUpdatedNuGetPackagesInWorkspace
{
- public List<UpdatedPackagesInProject> ProjectsWithUpdatedPackages = new List<UpdatedPackagesInProject> ();
+ public List<UpdatedNuGetPackagesInProject> ProjectsWithUpdatedPackages = new List<UpdatedNuGetPackagesInProject> ();
- public void AddUpdatedPackages (FakeDotNetProject project, params PackageName[] packageNames)
+ public void AddUpdatedPackages (FakeDotNetProject project, params PackageIdentity[] packages)
{
- var updatedPackages = new UpdatedPackagesInProject (project, packageNames);
+ var updatedPackages = new UpdatedNuGetPackagesInProject (project, packages);
ProjectsWithUpdatedPackages.Add (updatedPackages);
}
@@ -50,7 +49,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
}
- public UpdatedPackagesInProject GetUpdatedPackages (IDotNetProject project)
+ public UpdatedNuGetPackagesInProject GetUpdatedPackages (IDotNetProject project)
{
return ProjectsWithUpdatedPackages.FirstOrDefault (item => item.Project == project);
}
@@ -59,6 +58,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
return ProjectsWithUpdatedPackages.Any ();
}
+
+ public void Clear (ISolution solution)
+ {
+ }
+
+ public void CheckForUpdates (ISolution solution)
+ {
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ImportAndCondition.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ImportAndCondition.cs index c073ef5e2e..be148fe555 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ImportAndCondition.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/ImportAndCondition.cs @@ -24,18 +24,18 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using NuGet; +using NuGet.ProjectManagement; namespace MonoDevelop.PackageManagement.Tests.Helpers
{
public class ImportAndCondition
{ public ImportAndCondition (string name, string condition) - : this (name, condition, ProjectImportLocation.Bottom) + : this (name, condition, ImportLocation.Bottom) { } - public ImportAndCondition (string name, string condition, ProjectImportLocation location)
+ public ImportAndCondition (string name, string condition, ImportLocation location)
{
Name = name;
Condition = condition; @@ -44,7 +44,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public string Name { get; set; }
public string Condition { get; set; } - public ProjectImportLocation Location { get; set; }
+ public ImportLocation Location { get; set; }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/InstallPackageHelper.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/InstallPackageHelper.cs deleted file mode 100644 index 5b19ebb45f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/InstallPackageHelper.cs +++ /dev/null @@ -1,83 +0,0 @@ -//
-// InstallPackageHelper.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class InstallPackageHelper
- {
- InstallPackageAction action;
-
- public FakePackage TestPackage = new FakePackage () {
- Id = "Test"
- };
-
- public FakePackageRepository PackageRepository = new FakePackageRepository ();
- public List<PackageOperation> PackageOperations = new List<PackageOperation> ();
-
- public InstallPackageHelper (InstallPackageAction action)
- {
- this.action = action;
- }
-
- public void InstallTestPackage ()
- {
- action.Package = TestPackage;
- action.Operations = PackageOperations;
- action.IgnoreDependencies = IgnoreDependencies;
- action.AllowPrereleaseVersions = AllowPrereleaseVersions;
- action.Execute ();
- }
-
- public FakePackage AddPackageInstallOperation ()
- {
- var package = new FakePackage ("Package to install");
- var operation = new PackageOperation (package, PackageAction.Install);
- PackageOperations.Add (operation);
- return package;
- }
-
- public PackageSource PackageSource = new PackageSource ("http://monodevelop/packages");
- public bool IgnoreDependencies;
- public bool AllowPrereleaseVersions;
- public SemanticVersion Version;
-
- public void InstallPackageById (string packageId)
- {
- action.PackageId = packageId;
- action.PackageVersion = Version;
- action.IgnoreDependencies = IgnoreDependencies;
- action.AllowPrereleaseVersions = AllowPrereleaseVersions;
-
- action.Execute ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/OneRegisteredPackageSourceHelper.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/OneRegisteredPackageSourceHelper.cs deleted file mode 100644 index 0dc030e9a1..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/OneRegisteredPackageSourceHelper.cs +++ /dev/null @@ -1,88 +0,0 @@ -//
-// OneRegisteredPackageSourceHelper.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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class OneRegisteredPackageSourceHelper
- {
- public TestablePackageManagementOptions Options;
- public FakeSettings FakeSettings;
- public PackageSource PackageSource = new PackageSource ("http://monodevelop.com", "Test Package Source");
-
- public RegisteredPackageSources RegisteredPackageSources {
- get { return Options.PackageSources; }
- }
-
- public OneRegisteredPackageSourceHelper ()
- {
- CreateOneRegisteredPackageSource ();
- }
-
- void CreateOneRegisteredPackageSource ()
- {
- Options = new TestablePackageManagementOptions ();
- FakeSettings = Options.FakeSettings;
- AddOnePackageSource ();
- }
-
- public void AddOnePackageSource ()
- {
- RegisteredPackageSources.Clear ();
- RegisteredPackageSources.Add (PackageSource);
- }
-
- public void AddOnePackageSource (string source)
- {
- RegisteredPackageSources.Clear ();
- AddPackageSource (source);
- }
-
- public void AddTwoPackageSources ()
- {
- AddOnePackageSource ();
- var packageSource = new PackageSource ("http://second.codeplex.com", "second");
- RegisteredPackageSources.Add (packageSource);
- }
-
- public void AddTwoPackageSources (string source1, string source2)
- {
- RegisteredPackageSources.Clear ();
- AddPackageSource (source1);
- AddPackageSource (source2);
- }
-
- void AddPackageSource (string source)
- {
- var packageSource = new PackageSource (source);
- RegisteredPackageSources.Add (packageSource);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageCollectionAssert.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageCollectionAssert.cs index 4462399efa..1716c87861 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageCollectionAssert.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageCollectionAssert.cs @@ -34,23 +34,6 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
static class PackageCollectionAssert
{
- public static void AreEqual (IEnumerable<IPackage> expectedPackages, IEnumerable<PackageViewModel> actualViewModels)
- {
- var expectedPackagesAsList = new List<IPackage> (expectedPackages);
- List<IPackage> actualPackages = ConvertToPackageList (actualViewModels);
-
- CollectionAssert.AreEqual (expectedPackagesAsList, actualPackages);
- }
-
- static List<IPackage> ConvertToPackageList (IEnumerable<PackageViewModel> viewModels)
- {
- var packages = new List<IPackage> ();
- foreach (PackageViewModel viewModel in viewModels) {
- packages.Add (viewModel.GetPackage ());
- }
- return packages;
- }
-
public static void AreEqual (IEnumerable<IPackage> expectedPackages, IEnumerable<IPackage> actualPackages)
{
var expectedPackagesAsList = new List<IPackage> (expectedPackages);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageSourceCollectionAssert.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageSourceCollectionAssert.cs index 9c0a1389ab..871fc67d5e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageSourceCollectionAssert.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/PackageSourceCollectionAssert.cs @@ -26,7 +26,6 @@ using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
using NuGet;
namespace MonoDevelop.PackageManagement.Tests.Helpers
@@ -41,6 +40,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers CollectionAssert.AreEqual (expectedSourcesAsList, actualSources);
}
+ public static void AreEqual (IEnumerable<NuGet.Configuration.PackageSource> expectedSources, IEnumerable<PackageSourceViewModel> actualViewModels)
+ {
+ List<string> expectedSourcesAsList = ConvertToStrings (expectedSources);
+ List<string> actualSources = ConvertToStrings (actualViewModels);
+
+ CollectionAssert.AreEqual (expectedSourcesAsList, actualSources);
+ }
+
public static void AreEqual (IEnumerable<PackageSource> expectedSources, IEnumerable<PackageSource> actualSources)
{
List<string> expectedSourcesAsList = ConvertToStrings (expectedSources);
@@ -49,6 +56,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers CollectionAssert.AreEqual (expectedSourcesAsList, actualSourcesAsList);
}
+ public static void AreEqual (IEnumerable<NuGet.Configuration.PackageSource> expectedSources, IEnumerable<NuGet.Configuration.PackageSource> actualSources)
+ {
+ List<string> expectedSourcesAsList = ConvertToStrings (expectedSources);
+ List<string> actualSourcesAsList = ConvertToStrings (actualSources);
+
+ CollectionAssert.AreEqual (expectedSourcesAsList, actualSourcesAsList);
+ }
+
static List<string> ConvertToStrings (IEnumerable<PackageSource> sources)
{
List<string> convertedSources = new List<string> ();
@@ -58,6 +73,15 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers return convertedSources;
}
+ static List<string> ConvertToStrings (IEnumerable<NuGet.Configuration.PackageSource> sources)
+ {
+ var convertedSources = new List<string> ();
+ foreach (NuGet.Configuration.PackageSource source in sources) {
+ convertedSources.Add (ConvertToString (source));
+ }
+ return convertedSources;
+ }
+
static string ConvertToString (PackageSource source)
{
if (source != null) {
@@ -68,11 +92,21 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers return "[PackageSource] == Null";
}
+ static string ConvertToString (NuGet.Configuration.PackageSource source)
+ {
+ if (source != null) {
+ return String.Format ("[PackageSource] Name='{0}', Source='{1}'",
+ source.Name,
+ source.Source);
+ }
+ return "[PackageSource] == Null";
+ }
+
static List<string> ConvertToStrings (IEnumerable<PackageSourceViewModel> viewModels)
{
List<string> convertedSources = new List<string> ();
foreach (PackageSourceViewModel viewModel in viewModels) {
- PackageSource source = viewModel.GetPackageSource ();
+ PackageSource source = viewModel.GetNuGet2PackageSource ();
convertedSources.Add (ConvertToString (source));
}
return convertedSources;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolutionPackageRepositoryFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestPackageReferenceFactory.cs index cedda70399..66772317f7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeSolutionPackageRepositoryFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestPackageReferenceFactory.cs @@ -1,45 +1,51 @@ -//
-// FakeSolutionPackageRepositoryFactory.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class FakeSolutionPackageRepositoryFactory : ISolutionPackageRepositoryFactory
- {
- public FakeSolutionPackageRepository FakeSolutionPackageRepository = new FakeSolutionPackageRepository ();
- public ISolution SolutionPassedToCreateSolutionPackageRepository;
-
- public ISolutionPackageRepository CreateSolutionPackageRepository (ISolution solution)
- {
- SolutionPassedToCreateSolutionPackageRepository = solution;
- return FakeSolutionPackageRepository;
- }
- }
-}
-
-
+// +// TestPackageReferenceFactory.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Linq; +using Newtonsoft.Json.Linq; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + static class TestPackageReferenceFactory + { + public static PackageReference CreatePackageReferenceWithProjectJsonWildcardVersion ( + string package, + string version) + { + string json = "{ \"dependencies\": { \"" + package + "\": \"" + version + "\" } }"; + var jsonObject = JObject.Parse (json); + + var dependency = JsonConfigUtility.GetDependencies (jsonObject).First (); + var identity = new PackageIdentity (dependency.Id, dependency.VersionRange.MinVersion); + + return new PackageReference (identity, null, true, false, false, dependency.VersionRange); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableAllPackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableAllPackagesViewModel.cs new file mode 100644 index 0000000000..9d2586dcbb --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableAllPackagesViewModel.cs @@ -0,0 +1,102 @@ +// +// TestableAllPackagesViewModel.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using NuGet.PackageManagement.UI; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class TestableAllPackagesViewModel : AllPackagesViewModel + { + public RecentNuGetPackagesRepository RecentPackagesRepository; + public FakeNuGetProjectContext FakeNuGetProjectContext; + + public TestableAllPackagesViewModel ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject dotNetProject) + : this ( + solutionManager, + dotNetProject, + new FakeNuGetProjectContext (), + new RecentNuGetPackagesRepository ()) + { + } + + public TestableAllPackagesViewModel ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject dotNetProject, + FakeNuGetProjectContext projectContext, + RecentNuGetPackagesRepository recentPackagesRepository) + : base (solutionManager, dotNetProject, projectContext, recentPackagesRepository) + { + FakeNuGetProjectContext = projectContext; + RecentPackagesRepository = recentPackagesRepository; + } + + public FakePackageFeed PackageFeed = new FakePackageFeed (); + + protected override IPackageFeed CreatePackageFeed (IEnumerable<SourceRepository> sourceRepositories) + { + return PackageFeed; + } + + protected override Task CreateReadPackagesTask () + { + ReadPackagesTask = base.CreateReadPackagesTask (); + return ReadPackagesTask; + } + + public Task ReadPackagesTask; + + protected override Task LoadPackagesAsync (PackageItemLoader loader, CancellationToken token) + { + if (LoadPackagesAsyncTask != null) { + return LoadPackagesAsyncTask (loader, token); + } + return base.LoadPackagesAsync (loader, token); + } + + public Func<PackageItemLoader, CancellationToken, Task> LoadPackagesAsyncTask; + + public Task CallBaseLoadPackagesAsyncTask (PackageItemLoader loader, CancellationToken token) + { + return base.LoadPackagesAsync (loader, token); + } + + public Task GetPackagesInstalledInProjectTask; + + protected override Task GetPackagesInstalledInProject () + { + GetPackagesInstalledInProjectTask = base.GetPackagesInstalledInProject (); + return GetPackagesInstalledInProjectTask; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableBackgroundPackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableBackgroundPackageActionRunner.cs index 702d9d07e9..51948ae8e4 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableBackgroundPackageActionRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableBackgroundPackageActionRunner.cs @@ -26,10 +26,9 @@ using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Core;
-using MonoDevelop.Ide;
using NuGet;
+using System.Threading.Tasks;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
@@ -40,16 +39,19 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public TestableBackgroundPackageActionRunner (
IPackageManagementProgressMonitorFactory progressMonitorFactory,
IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
- : base (progressMonitorFactory, packageManagementEvents, progressProvider)
+ PackageManagementInstrumentationService instrumentationService)
+ : base (
+ progressMonitorFactory,
+ packageManagementEvents,
+ instrumentationService)
{
Init ();
}
void Init ()
{
- CreateEventMonitorAction = (monitor, packageManagementEvents, progressProvider) => {
- EventsMonitor = new TestablePackageManagementEventsMonitor (monitor, packageManagementEvents, progressProvider);
+ CreateEventMonitorAction = (monitor, packageManagementEvents) => {
+ EventsMonitor = new TestablePackageManagementEventsMonitor (monitor, packageManagementEvents);
return EventsMonitor;
};
}
@@ -80,15 +82,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public Func<ProgressMonitor,
IPackageManagementEvents,
- IProgressProvider,
PackageManagementEventsMonitor> CreateEventMonitorAction;
protected override PackageManagementEventsMonitor CreateEventMonitor (
ProgressMonitor monitor,
IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ TaskCompletionSource<bool> taskCompletionSource)
{
- return CreateEventMonitorAction (monitor, packageManagementEvents, progressProvider);
+ return CreateEventMonitorAction (monitor, packageManagementEvents);
}
public TestablePackageManagementEventsMonitor EventsMonitor;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForNuGetPackageUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForNuGetPackageUpdatesTaskRunner.cs new file mode 100644 index 0000000000..05c3dcf5c1 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableCheckForNuGetPackageUpdatesTaskRunner.cs @@ -0,0 +1,76 @@ +// +// TestableCheckForNuGetPackageUpdatesTaskRunner.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading.Tasks; +using NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class TestableCheckForNuGetPackageUpdatesTaskRunner : CheckForNuGetPackageUpdatesTaskRunner + { + public TestableCheckForNuGetPackageUpdatesTaskRunner ( + UpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace) + : base (updatedPackagesInWorkspace) + { + } + + public FakeSolutionManager SolutionManager = new FakeSolutionManager (); + + protected override IMonoDevelopSolutionManager GetSolutionManager (ISolution solution) + { + return SolutionManager; + } + + protected override NuGetProject CreateNuGetProject ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject project) + { + return nugetProjects[project]; + } + + Dictionary<IDotNetProject, NuGetProject> nugetProjects = new Dictionary<IDotNetProject, NuGetProject> (); + + public FakeNuGetProject AddNuGetProject (IDotNetProject project) + { + var nugetProject = new FakeNuGetProject (project); + nugetProjects[project] = nugetProject; + return nugetProject; + } + + public Task CheckForUpdatesTask; + public Action AfterCheckForUpdatesAction = () => { }; + + protected override Task CheckForUpdates (IEnumerable<IDotNetProject> projects) + { + CheckForUpdatesTask = base.CheckForUpdates (projects); + AfterCheckForUpdatesAction (); + return CheckForUpdatesTask; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallNuGetPackageAction.cs new file mode 100644 index 0000000000..b9c189e5cf --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallNuGetPackageAction.cs @@ -0,0 +1,86 @@ +// +// TestableInstallNuGetPackageAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class TestableInstallNuGetPackageAction : InstallNuGetPackageAction + { + public FakeNuGetProjectContext ProjectContext; + public FakeNuGetPackageManager PackageManager; + public PackageManagementEvents PackageManagementEvents; + public FakeLicenseAcceptanceService LicenseAcceptanceService = new FakeLicenseAcceptanceService (); + public FakeFileRemover FileRemover = new FakeFileRemover (); + + public TestableInstallNuGetPackageAction ( + IEnumerable<SourceRepository> primarySources, + FakeSolutionManager solutionManager, + FakeDotNetProject project) + : this ( + primarySources, + solutionManager, + project, + new FakeNuGetProjectContext (), + new FakeNuGetPackageManager (), + new PackageManagementEvents ()) + { + } + public TestableInstallNuGetPackageAction ( + IEnumerable<SourceRepository> primarySources, + FakeSolutionManager solutionManager, + FakeDotNetProject dotNetProject, + FakeNuGetProjectContext projectContext, + FakeNuGetPackageManager packageManager, + PackageManagementEvents packageManagementEvents) + : base ( + primarySources, + null, + solutionManager, + dotNetProject, + projectContext, + packageManager, + packageManagementEvents) + { + ProjectContext = projectContext; + PackageManager = packageManager; + + PackageManagementEvents = packageManagementEvents; + } + + protected override ILicenseAcceptanceService GetLicenseAcceptanceService () + { + return LicenseAcceptanceService; + } + + protected override IFileRemover GetFileRemover () + { + return FileRemover; + } + } +} + 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 deleted file mode 100644 index 0185597a5b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableInstallPackageAction.cs +++ /dev/null @@ -1,72 +0,0 @@ -//
-// TestableInstallPackageAction.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;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestableInstallPackageAction : InstallPackageAction
- {
- public TestableInstallPackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- FakeFileRemover fileRemover)
- : this (project, packageManagementEvents, fileRemover, new FakeLicenseAcceptanceService ())
- {
- }
-
- public TestableInstallPackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- FakeFileRemover fileRemover,
- FakeLicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents, fileRemover, licenseAcceptanceService)
- {
- LicenseAcceptanceService = licenseAcceptanceService;
-
- 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 IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
- {
- return CreateOpenPackageReadMeMonitorAction (packageId);
- }
-
- public bool NullOpenPackageReadMeMonitorIsCreated;
-
- public FakeLicenseAcceptanceService LicenseAcceptanceService;
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableMonoDevelopProjectSystem.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableMonoDevelopProjectSystem.cs index 145b665048..cd658a6425 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableMonoDevelopProjectSystem.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableMonoDevelopProjectSystem.cs @@ -25,22 +25,19 @@ // THE SOFTWARE.
using System;
+using System.Collections.Generic;
using System.IO;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
using System.Threading.Tasks;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
- class TestableMonoDevelopProjectSystem : MonoDevelopProjectSystem
+ class TestableMonoDevelopProjectSystem : MonoDevelopMSBuildNuGetProjectSystem
{
public string PathPassedToPhysicalFileSystemAddFile;
public Stream StreamPassedToPhysicalFileSystemAddFile;
- public Action<Stream> ActionPassedToPhysicalFileSystemAddFile;
public FakeFileService FakeFileService;
public FakePackageManagementProjectService FakeProjectService;
public PackageManagementEvents PackageManagementEvents;
- public FakeLogger FakeLogger;
public string FileNamePassedToLogDeletedFile;
public FileNameAndDirectory FileNameAndDirectoryPassedToLogDeletedFileFromDirectory;
public string DirectoryPassedToLogDeletedDirectory;
@@ -48,6 +45,7 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public ReferenceAndProjectName ReferenceAndProjectNamePassedToLogRemovedReferenceFromProject;
public FileNameAndProjectName FileNameAndProjectNamePassedToLogAddedFileToProject;
public FakeNuGetPackageNewImportsHandler NewImportsHandler;
+ public FakeNuGetProjectContext FakeNuGetProjectContext;
public static Action<Action> GuiSyncDispatcher = handler => handler.Invoke ();
public static Func<Func<Task>,Task> GuiSyncDispatcherFunc = handler => handler.Invoke();
@@ -55,25 +53,22 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public TestableMonoDevelopProjectSystem (IDotNetProject project)
: this (
project,
+ new FakeNuGetProjectContext (),
new FakeFileService (project),
- new FakePackageManagementProjectService (),
- new PackageManagementEvents (),
- new FakeLogger ())
+ new PackageManagementEvents ())
{
}
TestableMonoDevelopProjectSystem (
IDotNetProject project,
+ FakeNuGetProjectContext context,
IPackageManagementFileService fileService,
- IPackageManagementProjectService projectService,
- PackageManagementEvents packageManagementEvents,
- FakeLogger logger)
- : base (project, fileService, projectService, packageManagementEvents, GuiSyncDispatcher, GuiSyncDispatcherFunc)
+ PackageManagementEvents packageManagementEvents)
+ : base (project, context, fileService, packageManagementEvents, GuiSyncDispatcher, GuiSyncDispatcherFunc)
{
+ FakeNuGetProjectContext = context;
FakeFileService = (FakeFileService)fileService;
- FakeProjectService = (FakePackageManagementProjectService)projectService;
PackageManagementEvents = packageManagementEvents;
- Logger = logger;
}
protected override void PhysicalFileSystemAddFile (string path, Stream stream)
@@ -82,12 +77,6 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers StreamPassedToPhysicalFileSystemAddFile = stream;
}
- protected override void PhysicalFileSystemAddFile (string path, Action<Stream> writeToStream)
- {
- PathPassedToPhysicalFileSystemAddFile = path;
- ActionPassedToPhysicalFileSystemAddFile = writeToStream;
- }
-
protected override void LogDeletedFile (string fileName)
{
FileNamePassedToLogDeletedFile = fileName;
@@ -98,9 +87,9 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers FileNameAndDirectoryPassedToLogDeletedFileFromDirectory = new FileNameAndDirectory (fileName, directory);
}
- protected override void LogDeletedDirectory (string directory)
+ protected override void LogDeletedDirectory (string folder)
{
- DirectoryPassedToLogDeletedDirectory = directory;
+ DirectoryPassedToLogDeletedDirectory = folder;
}
protected override void LogAddedReferenceToProject (string referenceName, string projectName)
@@ -126,6 +115,40 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers NewImportsHandler = new FakeNuGetPackageNewImportsHandler ();
return NewImportsHandler;
}
+
+ Dictionary<string, IEnumerable<string>> enumeratedDirectories = new Dictionary<string, IEnumerable<string>> ();
+
+ public void AddDirectoriesForPath (string path, params string[] directories)
+ {
+ enumeratedDirectories[path] = directories;
+ }
+
+ protected override IEnumerable<string> EnumerateDirectories (string path) + {
+ IEnumerable<string> directories;
+ if (enumeratedDirectories.TryGetValue (path, out directories)) {
+ return directories; + }
+ return new string[0]; + }
+
+ Dictionary<string, IEnumerable<string>> enumeratedFiles = new Dictionary<string, IEnumerable<string>> ();
+
+ public void AddFilesForPath (string path, string searchPattern, SearchOption searchOption, params string[] files)
+ {
+ string key = path + searchPattern + searchOption.ToString ();
+ enumeratedFiles[key] = files;
+ }
+
+ protected override IEnumerable<string> EnumerateFiles (string path, string searchPattern, SearchOption searchOption) + { + IEnumerable<string> files;
+ string key = path + searchPattern + searchOption.ToString ();
+ if (enumeratedFiles.TryGetValue (key, out files)) {
+ return files;
+ }
+ return new string[0];
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityChecker.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityChecker.cs index 877dbe3a14..6ba72f637c 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityChecker.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityChecker.cs @@ -25,18 +25,15 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
using NuGet;
-using MonoDevelop.Ide;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
class TestablePackageCompatibilityChecker : PackageCompatibilityChecker
{
public TestablePackageCompatibilityChecker (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredRepositories)
- : base (solution, registeredRepositories)
+ FakeSolutionPackageRepository packageRepository)
+ : base (packageRepository)
{
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityRunner.cs index ebfa45b83f..f1fee37f56 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageCompatibilityRunner.cs @@ -25,10 +25,8 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
using NuGet;
using MonoDevelop.Core;
-using MonoDevelop.Ide;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
@@ -38,18 +36,12 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public TestablePackageCompatibilityRunner (
IDotNetProject project,
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredRepositories,
IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ IPackageManagementEvents packageManagementEvents)
: base (
project,
- solution,
- registeredRepositories,
progressMonitorFactory,
- packageManagementEvents,
- progressProvider)
+ packageManagementEvents)
{
PackageReferenceFile = new PackageReferenceFile (FileSystem, "packages.config");
}
@@ -66,10 +58,9 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers protected override PackageManagementEventsMonitor CreateEventMonitor (
ProgressMonitor monitor,
- IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ IPackageManagementEvents packageManagementEvents)
{
- EventsMonitor = new TestablePackageManagementEventsMonitor (monitor, packageManagementEvents, progressProvider);
+ EventsMonitor = new TestablePackageManagementEventsMonitor (monitor, packageManagementEvents);
return EventsMonitor;
}
@@ -84,14 +75,14 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public ProgressMonitorStatusMessage ProgressStatusMessage;
protected override PackageCompatibilityChecker CreatePackageCompatibilityChecker (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredRepositories)
+ ISolution solution)
{
- return new TestablePackageCompatibilityChecker (solution, registeredRepositories) {
+ return new TestablePackageCompatibilityChecker (PackageRepository) {
PackageReferenceFile = PackageReferenceFile
};
}
+ public FakeSolutionPackageRepository PackageRepository = new FakeSolutionPackageRepository ();
public PackageReferenceFile PackageReferenceFile;
public FakeFileSystem FileSystem = new FakeFileSystem ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageFromRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageFromRepository.cs deleted file mode 100644 index 1af31686a7..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageFromRepository.cs +++ /dev/null @@ -1,57 +0,0 @@ -//
-// TestablePackageFromRepository.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestablePackageFromRepository : PackageFromRepository
- {
- public FakePackage FakePackagePassedToConstructor;
- public FakePackageRepository FakePackageRepositoryPassedToConstructor;
-
- public TestablePackageFromRepository ()
- : this (new FakePackage ("Test"), new FakePackageRepository ())
- {
- }
-
- public TestablePackageFromRepository (FakePackage package, FakePackageRepository repository)
- : base (package, repository)
- {
- this.FakePackagePassedToConstructor = package;
- this.FakePackageRepositoryPassedToConstructor = repository;
- }
-
- public DateTimeOffset? DateTimeOffsetToReturnFromGetDataServicePackageLastUpdated;
-
- protected override DateTimeOffset? GetDataServicePackageLastUpdated ()
- {
- return DateTimeOffsetToReturnFromGetDataServicePackageLastUpdated;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementEventsMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementEventsMonitor.cs index e108b80d57..62f2d18cf3 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementEventsMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementEventsMonitor.cs @@ -37,9 +37,8 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
public TestablePackageManagementEventsMonitor (
ProgressMonitor progressMonitor,
- IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
- : base (progressMonitor, packageManagementEvents, progressProvider)
+ IPackageManagementEvents packageManagementEvents)
+ : base (progressMonitor, packageManagementEvents)
{
}
@@ -63,15 +62,6 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public bool IsPackageConsoleShown;
public ProgressMonitor ProgressMonitorPassedToShowPackageConsole;
-
- protected override void ReconnectAssemblyReferences (IPackageManagementProject project)
- {
- ProjectsPassedToReconnectAssemblyReferences.Add (project);
- IsTypeSystemRefreshed = true;
- }
-
- public List<IPackageManagementProject> ProjectsPassedToReconnectAssemblyReferences = new List<IPackageManagementProject> ();
- public bool IsTypeSystemRefreshed;
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementOptions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementOptions.cs deleted file mode 100644 index 826a775458..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageManagementOptions.cs +++ /dev/null @@ -1,69 +0,0 @@ -//
-// TestablePackageManagementOptions.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 MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestablePackageManagementOptions : PackageManagementOptions
- {
- public Properties Properties;
- public FakeSettings FakeSettings;
- public FakePackageManagementProjectService ProjectService;
-
- public TestablePackageManagementOptions ()
- : this (new Properties (), new FakeSettings (), new FakePackageManagementProjectService ())
- {
- }
-
- public TestablePackageManagementOptions (
- Properties properties,
- FakeSettings fakeSettings,
- FakePackageManagementProjectService projectService)
- : base (properties, CreateSettingsProvider (fakeSettings, projectService))
- {
- this.Properties = properties;
- this.FakeSettings = fakeSettings;
- this.ProjectService = projectService;
- }
-
- public static void ChangeSettingsReturnedBySettingsProvider (FakeSettings settings)
- {
- SettingsProvider.LoadDefaultSettings = (fileSystem, configFile, machineSettings) => {
- return settings;
- };
- }
-
- public static SettingsProvider CreateSettingsProvider (FakeSettings fakeSettings, FakePackageManagementProjectService projectService)
- {
- ChangeSettingsReturnedBySettingsProvider (fakeSettings);
- return new SettingsProvider (projectService);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageSearchResultViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageSearchResultViewModel.cs new file mode 100644 index 0000000000..caeec5e53e --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageSearchResultViewModel.cs @@ -0,0 +1,85 @@ +// +// TestablePackageSearchResultViewModel.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Threading; +using System.Threading.Tasks; +using NuGet.PackageManagement.UI; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class TestablePackageSearchResultViewModel : PackageSearchResultViewModel + { + public FakeDotNetProject Project; + public FakeSolutionManager SolutionManager; + + public TestablePackageSearchResultViewModel ( + PackageItemListViewModel viewModel) + : this ( + new FakeSolutionManager (), + new FakeDotNetProject (), + viewModel) + { + } + + public TestablePackageSearchResultViewModel ( + TestableAllPackagesViewModel parent, + PackageItemListViewModel viewModel) + : base (parent, viewModel) + { + } + + public TestablePackageSearchResultViewModel ( + FakeSolutionManager solutionManager, + FakeDotNetProject project, + PackageItemListViewModel viewModel) + : this ( + new TestableAllPackagesViewModel (solutionManager, project), + viewModel) + { + SolutionManager = solutionManager; + Project = project; + } + + public Task LoadPackageMetadataTask; + + protected override Task LoadPackageMetadataFromPackageDetailModelAsync ( + IPackageMetadataProvider metadataProvider, + CancellationToken cancellationToken) + { + LoadPackageMetadataTask = base.LoadPackageMetadataFromPackageDetailModelAsync (metadataProvider, cancellationToken); + return LoadPackageMetadataTask; + } + + public Task ReadVersionsTask; + + protected override Task ReadVersions (CancellationToken cancellationToken) + { + ReadVersionsTask = base.ReadVersions (cancellationToken); + return ReadVersionsTask; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageViewModel.cs deleted file mode 100644 index 283815f95d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackageViewModel.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestablePackageViewModel : PackageViewModel
- {
- public FakePackageManagementSolution FakeSolution;
- public PackageManagementEvents PackageManagementEvents;
- public FakePackage FakePackage;
- public FakeLogger FakeLogger;
-
- public TestablePackageViewModel (
- IPackageViewModelParent parent,
- FakePackageManagementSolution solution)
- : this (
- parent,
- new FakePackage ("Test"),
- new PackageManagementSelectedProjects (solution),
- new PackageManagementEvents (),
- new FakeLogger ())
- {
- this.FakeSolution = solution;
- }
-
- public TestablePackageViewModel (
- IPackageViewModelParent parent,
- FakePackage package,
- PackageManagementSelectedProjects selectedProjects,
- PackageManagementEvents packageManagementEvents,
- FakeLogger logger)
- : base (
- parent,
- package,
- selectedProjects,
- packageManagementEvents,
- null,
- logger)
- {
- this.FakePackage = package;
- this.PackageManagementEvents = packageManagementEvents;
- this.FakeLogger = logger;
- }
-
- protected override PackageViewModelOperationLogger CreateLogger (ILogger logger)
- {
- PackageViewModelOperationLogger operationLogger = base.CreateLogger (logger);
- operationLogger.AddingPackageMessageFormat = "Installing...{0}";
- operationLogger.RemovingPackageMessageFormat = "Uninstalling...{0}";
- operationLogger.ManagingPackageMessageFormat = "Managing...{0}";
- OperationLoggerCreated = operationLogger;
- return operationLogger;
- }
-
- public PackageViewModelOperationLogger OperationLoggerCreated;
-
- public PackageOperation AddOneFakeInstallPackageOperationForViewModelPackage ()
- {
- var operation = new FakePackageOperation (FakePackage, PackageAction.Install);
-
- FakeSolution
- .FakeProjectToReturnFromGetProject
- .FakeInstallOperations
- .Add (operation);
-
- return operation;
- }
-
- public PackageOperation AddOneFakeUninstallPackageOperation ()
- {
- var package = new FakePackage ("PackageToUninstall");
- var operation = new FakePackageOperation (package, PackageAction.Uninstall);
- FakeSolution.FakeProjectToReturnFromGetProject.FakeInstallOperations.Add (operation);
- return operation;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackagesViewModel.cs deleted file mode 100644 index 0d3b9259df..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestablePackagesViewModel.cs +++ /dev/null @@ -1,130 +0,0 @@ -//
-// TestablePackagesViewModel.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 System.Collections.Generic;
-using System.Linq;
-
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestablePackagesViewModel : PackagesViewModel
- {
- public FakeRegisteredPackageRepositories FakeRegisteredPackageRepositories;
- public FakeTaskFactory FakeTaskFactory;
- public List<FakePackage> FakePackages = new List<FakePackage> ();
- public int GetAllPackagesCallCount;
- public int PageCountBeforePackagesFiltered;
- public PackageSearchCriteria SearchCriteriaPassedToFilterPackagesBySearchCriteria;
-
- public TestablePackagesViewModel ()
- : this (new FakeRegisteredPackageRepositories ())
- {
- }
-
- public TestablePackagesViewModel (FakeRegisteredPackageRepositories registeredPackageRepositories)
- : this (registeredPackageRepositories, new FakeTaskFactory ())
- {
- }
-
- public TestablePackagesViewModel (
- FakeRegisteredPackageRepositories registeredPackageRepositories,
- FakeTaskFactory taskFactory)
- : base (
- registeredPackageRepositories,
- new FakePackageViewModelFactory (),
- taskFactory)
- {
- FakeRegisteredPackageRepositories = registeredPackageRepositories;
- FakeTaskFactory = taskFactory;
- }
-
- public void AddOneFakePackage ()
- {
- AddFakePackage ("Test");
- }
-
- public FakePackage AddFakePackage (string packageId)
- {
- FakePackage package = CreateFakePackage (packageId);
- FakePackages.Add (package);
- return package;
- }
-
- public FakePackage AddFakePackage (string packageId, string packageVersion)
- {
- FakePackage package = CreateFakePackage (packageId);
- package.Version = new SemanticVersion (packageVersion);
- FakePackages.Add (package);
- return package;
- }
-
- FakePackage CreateFakePackage (string packageId)
- {
- return new FakePackage () {
- Id = packageId,
- Description = ""
- };
- }
-
- public void AddSixFakePackages ()
- {
- AddFakePackages (howMany: 6);
- }
-
- void AddFakePackages (int howMany)
- {
- for (int i = 1; i <= howMany; ++i) {
- AddFakePackage ("Test " + i);
- }
- }
-
- protected override IQueryable<IPackage> GetPackages (PackageSearchCriteria search)
- {
- GetAllPackagesCallCount++;
- SearchCriteriaPassedToFilterPackagesBySearchCriteria = search;
- return FakePackages.AsQueryable ().Find (search.SearchText);
- }
-
- protected override IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults (IQueryable<IPackage> allPackages, PackageSearchCriteria search)
- {
- PageCountBeforePackagesFiltered = Pages.Count;
- return base.GetFilteredPackagesBeforePagingResults (allPackages, search);
- }
-
- public void AddTenFakePackages ()
- {
- AddFakePackages (howMany: 10);
- }
-
- public void AddThreeFakePackages ()
- {
- AddFakePackages (howMany: 3);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectManager.cs deleted file mode 100644 index bcc0ed0e9e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectManager.cs +++ /dev/null @@ -1,114 +0,0 @@ -//
-// TestableProjectManager.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestableProjectManager : MonoDevelopProjectManager
- {
- public IPackage PackagePassedToAddPackageReference;
- public bool IgnoreDependenciesPassedToAddPackageReference;
- public bool AllowPrereleaseVersionsPassedToAddPackageReference;
-
- public IPackage PackagePassedToRemovePackageReference;
- public bool ForcePassedToRemovePackageReference;
- public bool RemoveDependenciesPassedToRemovePackageReference;
-
- public IPackage PackagePassedToUpdatePackageReference;
- public bool UpdateDependenciesPassedToUpdatePackageReference;
- public bool AllowPrereleaseVersionsPassedToUpdatePackageReference;
- public List<IPackage> PackagesPassedToUpdatePackageReference = new List<IPackage> ();
-
- public FakePackageRepository FakeLocalRepository {
- get { return LocalRepository as FakePackageRepository; }
- }
-
- public TestableProjectManager ()
- : base (
- new FakePackageRepository (),
- new FakePackagePathResolver (),
- new FakeProjectSystem (),
- new FakePackageRepository ())
- {
- }
-
- public TestableProjectManager (PackageReferenceRepository repository)
- : base (
- new FakePackageRepository (),
- new FakePackagePathResolver (),
- new FakeProjectSystem (),
- repository)
- {
- }
-
- public override void AddPackageReference (string packageId, SemanticVersion version, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- var package = new FakePackage ();
- package.Id = packageId;
- package.Version = version;
- PackagePassedToAddPackageReference = package;
- IgnoreDependenciesPassedToAddPackageReference = ignoreDependencies;
- AllowPrereleaseVersionsPassedToAddPackageReference = allowPrereleaseVersions;
- }
-
- public override void AddPackageReference (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- PackagePassedToAddPackageReference = package;
- IgnoreDependenciesPassedToAddPackageReference = ignoreDependencies;
- AllowPrereleaseVersionsPassedToAddPackageReference = allowPrereleaseVersions;
- }
-
- public override void RemovePackageReference (IPackage package, bool force, bool removeDependencies)
- {
- PackagePassedToRemovePackageReference = package;
- ForcePassedToRemovePackageReference = force;
- RemoveDependenciesPassedToRemovePackageReference = removeDependencies;
- }
-
- public override void UpdatePackageReference (string packageId, SemanticVersion version, bool updateDependencies, bool allowPrereleaseVersions)
- {
- var package = new FakePackage ();
- package.Id = packageId;
- package.Version = version;
-
- PackagePassedToUpdatePackageReference = package;
- UpdateDependenciesPassedToUpdatePackageReference = updateDependencies;
- AllowPrereleaseVersionsPassedToUpdatePackageReference = allowPrereleaseVersions;
-
- PackagesPassedToUpdatePackageReference.Add (package);
- }
-
- public FakePackage AddFakePackageToProjectLocalRepository (string packageId, string version)
- {
- return FakeLocalRepository.AddFakePackageWithVersion (packageId, version);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectPackagesFolderNode.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectPackagesFolderNode.cs index 9351ca65b0..b5bf8da510 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectPackagesFolderNode.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProjectPackagesFolderNode.cs @@ -24,10 +24,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
using MonoDevelop.PackageManagement.NodeBuilders;
-using NuGet;
+using NuGet.Packaging;
namespace MonoDevelop.PackageManagement.Tests.Helpers
{
@@ -35,8 +37,8 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers {
public TestableProjectPackagesFolderNode (
IDotNetProject project,
- IUpdatedPackagesInSolution updatedPackagesInSolution)
- : base (project, updatedPackagesInSolution)
+ IUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace)
+ : base (project, updatedPackagesInWorkspace, false)
{
}
@@ -49,10 +51,24 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public List<PackageReference> PackageReferencesWithPackageInstalled = new List<PackageReference> ();
- protected override bool IsPackageInstalled (PackageReference reference)
+ public override bool IsPackageInstalled (PackageReference reference)
{
return PackageReferencesWithPackageInstalled.Contains (reference);
}
+
+ public TaskCompletionSource<bool> RefreshTaskCompletionSource;
+
+ protected override Task<IEnumerable<PackageReference>> GetInstalledPackagesAsync (CancellationTokenSource tokenSource)
+ {
+ RefreshTaskCompletionSource = new TaskCompletionSource<bool> ();
+ return Task.FromResult (PackageReferences.AsEnumerable ());
+ }
+
+ protected override void OnInstalledPackagesRead (Task<IEnumerable<PackageReference>> task, CancellationTokenSource tokenSource)
+ {
+ base.OnInstalledPackagesRead (task, tokenSource);
+ RefreshTaskCompletionSource.SetResult (true);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableReinstallNuGetPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableReinstallNuGetPackageActionTests.cs new file mode 100644 index 0000000000..b2b95d2165 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableReinstallNuGetPackageActionTests.cs @@ -0,0 +1,97 @@ +// +// TestableReinstallNuGetPackageAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class TestableReinstallNuGetPackageAction : ReinstallNuGetPackageAction + { + public FakeNuGetProjectContext ProjectContext; + public PackageManagementEvents PackageManagementEvents; + public FakeFileRemover FileRemover = new FakeFileRemover (); + public TestableInstallNuGetPackageAction InstallAction; + public TestableUninstallNuGetPackageAction UninstallAction; + + public TestableReinstallNuGetPackageAction ( + FakeDotNetProject project, + FakeSolutionManager solutionManager) + : this ( + project, + solutionManager, + new FakeNuGetProjectContext (), + new PackageManagementEvents ()) + { + } + + public TestableReinstallNuGetPackageAction ( + FakeDotNetProject dotNetProject, + FakeSolutionManager solutionManager, + FakeNuGetProjectContext projectContext, + PackageManagementEvents packageManagementEvents) + : base ( + dotNetProject, + solutionManager, + projectContext, + packageManagementEvents) + { + ProjectContext = projectContext; + + PackageManagementEvents = packageManagementEvents; + } + + protected override IFileRemover GetFileRemover () + { + return FileRemover; + } + + protected override InstallNuGetPackageAction CreateInstallAction ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject project, + IEnumerable<SourceRepository> repositories) + { + InstallAction = new TestableInstallNuGetPackageAction ( + repositories, + (FakeSolutionManager)solutionManager, + (FakeDotNetProject)project); + + return InstallAction; + } + + protected override UninstallNuGetPackageAction CreateUninstallAction ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject project) + { + UninstallAction = new TestableUninstallNuGetPackageAction ( + (FakeSolutionManager)solutionManager, + (FakeDotNetProject)project); + + return UninstallAction; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableSolutionPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableSolutionPackageRepository.cs index 68fb33cc77..6bcfd87141 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableSolutionPackageRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableSolutionPackageRepository.cs @@ -35,17 +35,12 @@ namespace MonoDevelop.PackageManagement.Tests.Helpers public TestableSolutionPackageRepository (
ISolution solution,
IMonoDevelopPackageRepositoryFactory repositoryFactory,
- PackageManagementOptions options)
- : base (solution, repositoryFactory, options)
+ ISettingsProvider settingsProvider)
+ : base (solution, repositoryFactory, settingsProvider)
{
}
public TestableLocalPackageRepository LocalPackageRepository = new TestableLocalPackageRepository ();
-
- protected override LocalPackageRepository CreateLocalPackageRepository ()
- {
- return LocalPackageRepository;
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProcessPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUninstallNuGetPackageAction.cs index 38939273ff..5fe55f73d2 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableProcessPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUninstallNuGetPackageAction.cs @@ -1,70 +1,67 @@ -//
-// TestableProcessPackageAction.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestableProcessPackageAction : ProcessPackageAction
- {
- public FakePackageManagementProject FakeProject;
- public PackageManagementEvents PackageManagementEvents;
- public FakePackage FakePackage = new FakePackage ("Test");
-
- public TestableProcessPackageAction ()
- : this (new FakePackageManagementProject (), new PackageManagementEvents ())
- {
- }
-
- public TestableProcessPackageAction (
- FakePackageManagementProject project,
- PackageManagementEvents packageManagementEvents)
- : base (project, packageManagementEvents)
- {
- FakeProject = project;
- PackageManagementEvents = packageManagementEvents;
- this.Package = FakePackage;
- }
-
- public void CallBeforeExecute ()
- {
- base.BeforeExecute ();
- }
-
- public bool IsRunPackageScriptsActionCreated;
- public bool IsExecuteCoreCalled;
-
- protected override void ExecuteCore ()
- {
- IsExecuteCoreCalled = true;
- }
-
- protected override string StartingMessageFormat {
- get { return String.Empty; }
- }
- }
-}
-
+// +// TestableUninstallNuGetPackageAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Tests.Helpers +{ + class TestableUninstallNuGetPackageAction : UninstallNuGetPackageAction + { + public FakeNuGetProjectContext ProjectContext; + public FakeNuGetPackageManager PackageManager; + public PackageManagementEvents PackageManagementEvents; + + public TestableUninstallNuGetPackageAction ( + FakeSolutionManager solutionManager, + FakeDotNetProject project) + : this ( + solutionManager, + project, + new FakeNuGetProjectContext (), + new FakeNuGetPackageManager (), + new PackageManagementEvents ()) + { + } + + public TestableUninstallNuGetPackageAction ( + FakeSolutionManager solutionManager, + FakeDotNetProject dotNetProject, + FakeNuGetProjectContext projectContext, + FakeNuGetPackageManager packageManager, + PackageManagementEvents packageManagementEvents) + : base ( + solutionManager, + dotNetProject, + projectContext, + packageManager, + packageManagementEvents) + { + ProjectContext = projectContext; + PackageManager = packageManager; + + PackageManagementEvents = packageManagementEvents; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdateAllNuGetPackagesInProjectAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdateAllNuGetPackagesInProjectAction.cs new file mode 100644 index 0000000000..86c47fc2ee --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdateAllNuGetPackagesInProjectAction.cs @@ -0,0 +1,84 @@ +// +// TestableUpdateAllNuGetPackagesInProjectAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Tests.Helpers +{ + class TestableUpdateAllNuGetPackagesInProjectAction : UpdateAllNuGetPackagesInProjectAction + { + public FakeNuGetProjectContext ProjectContext; + public FakeNuGetPackageManager PackageManager; + public FakePackageRestoreManager RestoreManager; + public PackageManagementEvents PackageManagementEvents; + public FakeLicenseAcceptanceService LicenseAcceptanceService = new FakeLicenseAcceptanceService (); + public FakeFileRemover FileRemover = new FakeFileRemover (); + + public TestableUpdateAllNuGetPackagesInProjectAction ( + FakeSolutionManager solutionManager, + FakeDotNetProject project) + : this ( + solutionManager, + project, + new FakeNuGetProjectContext (), + new FakeNuGetPackageManager (), + new FakePackageRestoreManager (), + new PackageManagementEvents ()) + { + } + + public TestableUpdateAllNuGetPackagesInProjectAction ( + FakeSolutionManager solutionManager, + FakeDotNetProject dotNetProject, + FakeNuGetProjectContext projectContext, + FakeNuGetPackageManager packageManager, + FakePackageRestoreManager restoreManager, + PackageManagementEvents packageManagementEvents) + : base ( + solutionManager, + dotNetProject, + projectContext, + packageManager, + restoreManager, + packageManagementEvents) + { + ProjectContext = projectContext; + PackageManager = packageManager; + RestoreManager = restoreManager; + + PackageManagementEvents = packageManagementEvents; + } + + protected override ILicenseAcceptanceService GetLicenseAcceptanceService () + { + return LicenseAcceptanceService; + } + + protected override IFileRemover GetFileRemover () + { + return FileRemover; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdateNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdateNuGetPackageAction.cs new file mode 100644 index 0000000000..684d0ff667 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdateNuGetPackageAction.cs @@ -0,0 +1,82 @@ +// +// TestableUpdateNuGetPackageAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement.Tests.Helpers +{ + class TestableUpdateNuGetPackageAction : UpdateNuGetPackageAction + { + public FakeNuGetProjectContext ProjectContext; + public FakeNuGetPackageManager PackageManager; + public PackageManagementEvents PackageManagementEvents; + public FakeLicenseAcceptanceService LicenseAcceptanceService = new FakeLicenseAcceptanceService (); + public FakeFileRemover FileRemover = new FakeFileRemover (); + + public TestableUpdateNuGetPackageAction ( + FakeSolutionManager solutionManager, + FakeDotNetProject project) + : this ( + solutionManager, + project, + new FakeNuGetProjectContext (), + new FakeNuGetPackageManager (), + new PackageManagementEvents ()) + { + } + + public TestableUpdateNuGetPackageAction ( + FakeSolutionManager solutionManager, + FakeDotNetProject dotNetProject, + FakeNuGetProjectContext projectContext, + FakeNuGetPackageManager packageManager, + PackageManagementEvents packageManagementEvents) + : base ( + solutionManager, + dotNetProject, + projectContext, + packageManager, + packageManagementEvents) + { + ProjectContext = projectContext; + PackageManager = packageManager; + + PackageManagementEvents = packageManagementEvents; + } + + protected override ILicenseAcceptanceService GetLicenseAcceptanceService () + { + return LicenseAcceptanceService; + } + + protected override IFileRemover GetFileRemover () + { + return FileRemover; + } + } +} + 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 deleted file mode 100644 index da0456771f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatePackageAction.cs +++ /dev/null @@ -1,67 +0,0 @@ -//
-// TestableUpdatePackageAction.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;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestableUpdatePackageAction : UpdatePackageAction
- {
- public TestableUpdatePackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- IFileRemover fileRemover)
- : this (project, packageManagementEvents, fileRemover, new FakeLicenseAcceptanceService ())
- {
- }
-
- public TestableUpdatePackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- IFileRemover fileRemover,
- FakeLicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents, fileRemover, licenseAcceptanceService)
- {
- LicenseAcceptanceService = licenseAcceptanceService;
- CreateOpenPackageReadMeMonitorAction = packageId => {
- OpenPackageReadMeMonitor = base.CreateOpenPackageReadMeMonitor (packageId) as OpenPackageReadMeMonitor;
- return OpenPackageReadMeMonitor;
- };
- }
-
- public OpenPackageReadMeMonitor OpenPackageReadMeMonitor;
- public Func<string, IOpenPackageReadMeMonitor> CreateOpenPackageReadMeMonitorAction;
-
- protected override IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
- {
- return CreateOpenPackageReadMeMonitorAction (packageId);
- }
-
- public FakeLicenseAcceptanceService LicenseAcceptanceService;
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatedPackagesInSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatedNuGetPackagesInWorkspace.cs index 391bf97b96..f767ae11e8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatedPackagesInSolution.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/TestableUpdatedNuGetPackagesInWorkspace.cs @@ -1,64 +1,60 @@ -//
-// TestableUpdatedPackagesInSolution.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 MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class TestableUpdatedPackagesInSolution : UpdatedPackagesInSolution
- {
- public TestableUpdatedPackagesInSolution (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageManagementEvents packageManagementEvents,
- CheckForUpdatesTaskRunner taskRunner)
- : base (
- solution,
- registeredPackageRepositories,
- packageManagementEvents,
- taskRunner)
- {
- FileExistsAction = path => {
- return true;
- };
- }
-
- protected override void GuiDispatch (Action action)
- {
- action.Invoke ();
- }
-
- public Func<string, bool> FileExistsAction;
-
- protected override bool FileExists (string path)
- {
- return FileExistsAction (path);
- }
- }
-}
-
+// +// TestableUpdatedNuGetPackagesInWorkspace.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Tests.Helpers +{ + class TestableUpdatedNuGetPackagesInWorkspace : UpdatedNuGetPackagesInWorkspace + { + public IPackageManagementEvents PackageManagementEvents; + public TestableCheckForNuGetPackageUpdatesTaskRunner TaskRunner; + + public TestableUpdatedNuGetPackagesInWorkspace () + : this (new PackageManagementEvents ()) + { + } + + public TestableUpdatedNuGetPackagesInWorkspace ( + IPackageManagementEvents packageManagementEvents) + : base (packageManagementEvents) + { + PackageManagementEvents = packageManagementEvents; + } + + protected override CheckForNuGetPackageUpdatesTaskRunner CreateTaskRunner () + { + TaskRunner = new TestableCheckForNuGetPackageUpdatesTaskRunner (this); + return TaskRunner; + } + + protected override void GuiDispatch (Action action) + { + action.Invoke (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/UpdatePackageHelper.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/UpdatePackageHelper.cs deleted file mode 100644 index 26da8b9e5a..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/UpdatePackageHelper.cs +++ /dev/null @@ -1,82 +0,0 @@ -//
-// UpdatePackageHelper.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- class UpdatePackageHelper
- {
- UpdatePackageAction action;
-
- public FakePackage TestPackage = new FakePackage () {
- Id = "Test"
- };
-
- public List<PackageOperation> PackageOperations = new List<PackageOperation> ();
-
- public UpdatePackageHelper (UpdatePackageAction action)
- {
- this.action = action;
- }
-
- public void UpdateTestPackage ()
- {
- action.UpdateDependencies = UpdateDependencies;
- action.AllowPrereleaseVersions = AllowPrereleaseVersions;
- action.Package = TestPackage;
- action.Operations = PackageOperations;
- action.Execute ();
- }
-
- public FakePackage AddPackageInstallOperation ()
- {
- var package = new FakePackage ("Package to install");
- var operation = new PackageOperation (package, PackageAction.Install);
- PackageOperations.Add (operation);
- return package;
- }
-
- public PackageSource PackageSource = new PackageSource ("http://monodevelop/packages");
- public bool UpdateDependencies;
- public bool AllowPrereleaseVersions;
- public SemanticVersion Version;
-
- public void UpdatePackageById (string packageId)
- {
- action.PackageId = packageId;
- action.PackageVersion = Version;
- action.UpdateDependencies = UpdateDependencies;
- action.AllowPrereleaseVersions = AllowPrereleaseVersions;
- action.Execute ();
- }
- }
-}
-
-
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 ac04c8f64c..df28fa048b 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 @@ -48,13 +48,57 @@ <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="Microsoft.Web.XmlTransform"> + <HintPath>..\..\..\..\external\nuget-binary\Microsoft.Web.XmlTransform.dll</HintPath> + </Reference> <Reference Include="NuGet.Core"> <HintPath>..\..\..\..\external\nuget-binary\NuGet.Core.dll</HintPath> <Private>False</Private> </Reference> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="Microsoft.Web.XmlTransform"> - <HintPath>..\..\..\..\external\nuget-binary\Microsoft.Web.XmlTransform.dll</HintPath> + <Reference Include="NuGet.Versioning"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Versioning.dll</HintPath> + </Reference> + <Reference Include="mscorlib" /> + <Reference Include="NuGet.Frameworks"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Frameworks.dll</HintPath> + </Reference> + <Reference Include="NuGet.Packaging.Core.Types"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Packaging.Core.Types.dll</HintPath> + </Reference> + <Reference Include="NuGet.Packaging.Core"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Packaging.Core.dll</HintPath> + </Reference> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.IO.Compression" /> + <Reference Include="NuGet.Logging"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Logging.dll</HintPath> + </Reference> + <Reference Include="NuGet.Packaging"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Packaging.dll</HintPath> + </Reference> + <Reference Include="NuGet.Configuration"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Configuration.dll</HintPath> + </Reference> + <Reference Include="System.Globalization" /> + <Reference Include="System.Security" /> + <Reference Include="NuGet.PackageManagement"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.PackageManagement.dll</HintPath> + </Reference> + <Reference Include="NuGet.Protocol.Core.Types"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Protocol.Core.Types.dll</HintPath> + </Reference> + <Reference Include="NuGet.ProjectManagement"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.ProjectManagement.dll</HintPath> + </Reference> + <Reference Include="NuGet.Common"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Common.dll</HintPath> + </Reference> + <Reference Include="NuGet.Resolver"> + <HintPath>..\..\..\..\external\nuget-binary\NuGet.Resolver.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json"> + <HintPath>..\..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> @@ -63,89 +107,43 @@ <Compile Include="MonoDevelop.PackageManagement.Tests\DelegateCommandTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\ViewModelBaseTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableViewModelBase.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageFromRepositoryTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackage.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageFromRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageAssemblyReference.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\CollectionAssert.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageOperationMessageTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageFilesTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\IPackageExtensionsTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\RecentPackageInfoTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageRepositoryCacheTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageRepositoryFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSharedPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\OneRegisteredPackageSourceHelper.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSettings.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageManagementOptions.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeRecentPackageRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackagePathResolver.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeFileSystem.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementLoggerTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementEventsTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageManagementSolution.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageManagementProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeInstallPackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeUpdatePackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeUninstallPackageAction.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageOperation.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementOptionsTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\RecentPackageInfoCollectionAssert.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\RegisteredPackageRepositoriesTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementOptionsViewModelTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeMachineCache.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeProcess.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\ThreadSafePackageManagementEventsTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageSourceViewModelTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\RegisteredPackageSourcesViewModelTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\PackageSourceCollectionAssert.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\ProcessPackageActionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableProcessPackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ExceptionThrowingProcessPackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\InstallPackageActionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\InstallPackageHelper.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\PackageOperationHelper.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\RecentPackageRepositoryTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\RecentNuGetPackagesRepositoryTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\PackageCollectionAssert.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\AvailablePackagesViewModelTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeRegisteredPackageRepositories.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeTaskFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeTask.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ExceptionThrowingRegisteredPackageRepositories.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageViewModelFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeLogger.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeServiceBasedRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementSelectedProjectTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UninstallPackageActionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\UninstallPackageHelper.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UpdatePackageActionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\UpdatePackageHelper.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UpdateAllPackagesInProjectTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UpdateAllPackagesInSolutionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UserAgentGeneratorForRepositoryRequestsTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageRepositoryWithHttpClientEvents.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\ReducedPackageOperationsTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestPackageHelper.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageOperationResolver.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\SolutionPackageRepositoryPathTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSolution.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeProject.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\SolutionPackageRepositoryTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementProjectTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageManagerFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageManager.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageManagementProjectService.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeProjectManager.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeProjectSystem.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeDotNetProject.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\PackageReferenceRepositoryHelper.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableProjectManager.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageOperationResolverFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\MonoDevelopPackageManagerTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSolutionPackageRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeWebRequest.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageRepositoryFactoryEvents.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\MonoDevelopProjectSystemTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableMonoDevelopProjectSystem.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeFileService.cs" /> @@ -153,18 +151,6 @@ <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FileNameAndProjectName.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ReferenceAndProjectName.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\ProjectHelper.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\OpenDotNetProjectTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeProjectSystemFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\MonoDevelopPackageManagerFactoryTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\MonoDevelopProjectManagerTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementSelectedProjectsTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\SelectedProjectCollectionAssert.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageViewModelTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeOperationAwareRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageManagementSolutionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSolutionPackageRepositoryFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageManagementProjectFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\WindowsPath.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\XmlDocumentTransformTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\BackgroundPackageActionRunnerTests.cs" /> @@ -173,47 +159,66 @@ <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableBackgroundPackageActionRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageManagementEventsMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\SettingProviderTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageSearchCriteriaTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\WildcardVersionSpecTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ImportAndCondition.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\ProjectTargetFrameworkMonitorTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageReferenceNodeTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageCompatibilityRunnerTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageCompatibilityRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageCompatibilityChecker.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackageReinstallerTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeBackgroundPackageActionRunner.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\ReinstallPackageActionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\ReinstallProjectPackagesActionTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\PackageCompatibilityTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UpdatedPackagesTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\UpdatedPackagesInSolutionTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableUpdatedPackagesInSolution.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests\ProjectPackagesFolderNodeTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableProjectPackagesFolderNode.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeUpdatedPackagesInSolution.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\PackagesViewModelTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackagesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\PageCollectionAssert.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeUpdatedPackagesInWorkspace.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ExceptionThrowingPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\MonoDevelopAggregateRepositoryTests.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Tests\RestorePackagesActionTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableLocalPackageRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableSolutionPackageRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeFileRemover.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageRepositoryWithConstraintProvider.cs" /> - <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\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" /> <Compile Include="MonoDevelop.PackageManagement.Tests\MinClientVersionTests.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeLicenseAcceptanceService.cs" /> <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetPackageNewImportsHandler.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageSourceProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\TestableInstrumentationService.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetProjectAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetProjectContext.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\NuGetPackageUninstallerTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\AllPackagesViewModelTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSolutionManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetProject.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSourceRepositoryProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetSettings.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\FakePackageFeed.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableAllPackagesViewModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\PackageSearchResultViewModelTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageMetadataProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageSearchMetadata.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestablePackageSearchResultViewModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageMetadataResource.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageMetadataResourceProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\UpdatedNuGetPackagesInWorkspaceTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableUpdatedNuGetPackagesInWorkspace.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableCheckForNuGetPackageUpdatesTaskRunner.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\ExceptionThrowingPackageMetadataResource.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\InstallNuGetPackageActionTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableInstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeNuGetPackageManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\UpdateNuGetPackageActionTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableUpdateNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\UninstallNuGetPackageActionTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableUninstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\UpdateAllNuGetPackagesInProjectActionTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableUpdateAllNuGetPackagesInProjectAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakePackageRestoreManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests\ReinstallNuGetPackageActionTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestableReinstallNuGetPackageActionTests.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\TestPackageReferenceFactory.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Tests.Helpers\FakeSettingsProvider.cs" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> @@ -240,4 +245,7 @@ <Folder Include="MonoDevelop.PackageManagement.Tests\" /> <Folder Include="MonoDevelop.PackageManagement.Tests.Helpers\" /> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> </Project> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/AllPackagesViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/AllPackagesViewModelTests.cs new file mode 100644 index 0000000000..5a279f58e9 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/AllPackagesViewModelTests.cs @@ -0,0 +1,1036 @@ +// +// AllPackagesViewModelTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.ComponentModel; +using System.Linq; +using System.Threading.Tasks; +using MonoDevelop.PackageManagement.Tests.Helpers; +using NuGet.Configuration; +using NuGet.PackageManagement.UI; +using NuGet.ProjectManagement; +using NuGet.Versioning; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class AllPackagesViewModelTests + { + TestableAllPackagesViewModel viewModel; + FakeSolutionManager solutionManager; + FakeDotNetProject project; + FakePackageSourceProvider packageSourceProvider; + + void CreateProject () + { + project = new FakeDotNetProject (); + solutionManager = new FakeSolutionManager (); + packageSourceProvider = solutionManager.SourceRepositoryProvider.FakePackageSourceProvider; + } + + void CreateViewModel () + { + viewModel = new TestableAllPackagesViewModel ( + solutionManager, + project); + EnsurePackageSourcesLoaded (); + } + + void EnsurePackageSourcesLoaded () + { + viewModel.PackageSources.ToList (); + } + + PackageSource[] AddTwoPackageSourcesToRegisteredSources () + { + var sources = new [] { + new PackageSource ("http://first.com", "First"), + new PackageSource ("http://second.com", "Second") + }; + solutionManager.SourceRepositoryProvider.AddRepositories (sources); + + return sources; + } + + PackageSource AddOnePackageSourceToRegisteredSources () + { + var source = new PackageSource ("http://monodevelop.com", "Test"); + solutionManager.SourceRepositoryProvider.AddRepository (source); + return source; + } + + Task SetUpTwoPackageSourcesAndViewModelHasReadPackages () + { + CreateProject (); + var sources = AddTwoPackageSourcesToRegisteredSources ().ToList (); + packageSourceProvider.ActivePackageSourceName = sources[0].Name; + CreateViewModel (); + EnsurePackageSourcesLoaded (); + viewModel.ReadPackages (); + return viewModel.ReadPackagesTask; + } + + void ChangeSelectedPackageSourceToFirstSourceNonAggregateSource () + { + var firstPackageSource = viewModel.PackageSources.First (source => !source.IsAggregate); + viewModel.SelectedPackageSource = firstPackageSource; + } + + void ChangeSelectedPackageSourceToSecondNonAggregateSource () + { + var secondPackageSource = viewModel + .PackageSources + .Where (source => !source.IsAggregate) + .Skip (1) + .First (); + viewModel.SelectedPackageSource = secondPackageSource; + } + + PackageSearchResultViewModel AddRecentPackage (string packageId, string packageVersion, string packageSource) + { + var searchResultViewModel = CreateRecentPackage (packageId, packageVersion, packageSource); + viewModel.RecentPackagesRepository.AddPackage (searchResultViewModel, packageSource); + return searchResultViewModel; + } + + PackageSearchResultViewModel CreateRecentPackage (string packageId, string packageVersion, string packageSource) + { + var allPackagesViewModelForRecentPackages = new TestableAllPackagesViewModel ( + new FakeSolutionManager (), + new FakeDotNetProject ()); + var recentPackage = new PackageItemListViewModel { + Id = packageId, + Version = new NuGetVersion (packageVersion) + }; + return new PackageSearchResultViewModel (allPackagesViewModelForRecentPackages, recentPackage); + } + + FakeNuGetProject CreateNuGetProjectForProject () + { + var nugetProject = new FakeNuGetProject (project); + solutionManager.NuGetProjects[project] = nugetProject; + return nugetProject; + } + + [Test] + public void PackageSources_TwoPackageSourcesInOptions_ReturnsTwoPackageSourcesPlusAggregatePackageSource () + { + CreateProject (); + var expectedPackageSources = AddTwoPackageSourcesToRegisteredSources ().ToList (); + CreateViewModel (); + expectedPackageSources.Insert (0, AggregateSourceRepositoryViewModel.AggregatePackageSource); + + var packageSources = viewModel.PackageSources.Select (vm => vm.PackageSource).ToList (); + + PackageSourceCollectionAssert.AreEqual (expectedPackageSources, packageSources); + } + + [Test] + public void PackageSources_OnePackageSourceInOptions_ReturnsOnePackageSource () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + var expectedPackageSources = new [] { packageSource }; + CreateViewModel (); + + var packageSources = viewModel.PackageSources.Select (vm => vm.PackageSource).ToList (); + + PackageSourceCollectionAssert.AreEqual (expectedPackageSources, packageSources); + } + + [Test] + public async Task ReadPackages_RepositoryHasOnePackage_PackageLoaded () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("Test", "0.1"); + + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + var package = viewModel.PackageViewModels.Single (); + Assert.AreEqual ("Test", package.Id); + Assert.AreEqual ("0.1", package.Version.ToString ()); + } + + [Test] + public void SelectedPackageSource_TwoPackageSourcesInOptionsAndActivePackageSourceIsFirstSource_IsFirstPackageSource () + { + CreateProject (); + var sources = AddTwoPackageSourcesToRegisteredSources ().ToList (); + var expectedPackageSource = sources[0]; + packageSourceProvider.ActivePackageSourceName = expectedPackageSource.Name; + CreateViewModel (); + + Assert.AreEqual (expectedPackageSource, viewModel.SelectedPackageSource.PackageSource); + } + + [Test] + public void SelectedPackageSource_TwoPackageSourcesInOptionsAndActivePackageSourceIsSecondSource_IsSecondPackageSource () + { + CreateProject (); + var sources = AddTwoPackageSourcesToRegisteredSources (); + var expectedPackageSource = sources[1]; + packageSourceProvider.ActivePackageSourceName = expectedPackageSource.Name; + CreateViewModel (); + + Assert.AreEqual (expectedPackageSource, viewModel.SelectedPackageSource.PackageSource); + } + + [Test] + public void SelectedPackageSource_OnePackageSourceDefinedButUnknownActivePackageSource_PackageSourceIsMadeActiveSource () + { + CreateProject (); + var sources = AddTwoPackageSourcesToRegisteredSources (); + var expectedPackageSource = sources[0]; + packageSourceProvider.ActivePackageSourceName = "Unknown"; + CreateViewModel (); + + Assert.AreEqual (expectedPackageSource, viewModel.SelectedPackageSource.PackageSource); + } + + [Test] + public void SelectedPackageSource_Changed_ActivePackageSourceChanged () + { + CreateProject (); + var packageSources = AddTwoPackageSourcesToRegisteredSources ().ToList (); + packageSourceProvider.ActivePackageSourceName = packageSources[0].Name; + CreateViewModel (); + var expectedPackageSource = packageSources[1]; + var packageSourceViewModels = viewModel.PackageSources.ToList (); + + viewModel.SelectedPackageSource = packageSourceViewModels[2]; + + Assert.AreEqual (expectedPackageSource, packageSourceProvider.ActivePackageSource); + } + + [Test] + public async Task SelectedPackageSource_PackageSourceChangedAfterReadingPackages_PackagesReadFromNewPackageSourceAndDisplayed () + { + await SetUpTwoPackageSourcesAndViewModelHasReadPackages (); + viewModel.ReadPackagesTask = null; + viewModel.PackageFeed.AddPackage ("Test", "1.2"); + ChangeSelectedPackageSourceToSecondNonAggregateSource (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Test", viewModel.PackageViewModels[0].Id); + Assert.AreSame ("1.2", viewModel.PackageViewModels[0].Version.ToString ()); + } + + [Test] + public async Task SelectedPackageSource_PackageSourceChangedAfterReadingPackages_PropertyChangedEventFiredAfterPackagesAreRead () + { + await SetUpTwoPackageSourcesAndViewModelHasReadPackages (); + + int packageCountWhenPropertyChangedEventFired = -1; + viewModel.PropertyChanged += (sender, e) => { + packageCountWhenPropertyChangedEventFired = viewModel.PackageViewModels.Count; + }; + viewModel.ReadPackagesTask = null; + viewModel.PackageFeed.AddPackage ("Test", "1.0"); + ChangeSelectedPackageSourceToSecondNonAggregateSource (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, packageCountWhenPropertyChangedEventFired); + } + + [Test] + public async Task SelectedPackageSource_PackageSourceChangedButToSameSelectedPackageSource_PackagesAreNotRead () + { + await SetUpTwoPackageSourcesAndViewModelHasReadPackages (); + viewModel.ReadPackagesTask = null; + ChangeSelectedPackageSourceToFirstSourceNonAggregateSource (); + + Assert.IsNull (viewModel.ReadPackagesTask); + } + + [Test] + public async Task SelectedPackageSource_PackageSourceChangedButToSameSelectedPackageSource_PropertyChangedEventNotFired () + { + await SetUpTwoPackageSourcesAndViewModelHasReadPackages (); + + bool fired = false; + viewModel.PropertyChanged += (sender, e) => fired = true; + ChangeSelectedPackageSourceToFirstSourceNonAggregateSource (); + + Assert.IsFalse (fired); + } + + [Test] + public async Task ReadPackages_SearchTextAndIncludePrereleaseIsTrue_SearchTextAndIncludePrereleaseUsedWhenQueryingPackageFeed () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.IncludePrerelease = true; + viewModel.SearchTerms = "Test"; + viewModel.PackageFeed.AddPackage ("Test", "1.1.0-alpha"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual ("Test", viewModel.PackageFeed.SearchText); + Assert.IsTrue (viewModel.PackageFeed.SearchFilter.IncludePrerelease); + } + + [Test] + public async Task ReadPackages_NoSearchTextAndIncludePrereleaseIsFalse_SearchTextAndIncludePrereleaseIsFalseWhenQueryingPackageFeed () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.IncludePrerelease = false; + viewModel.SearchTerms = null; + viewModel.PackageFeed.AddPackage ("Test", "1.1"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (string.Empty, viewModel.PackageFeed.SearchText); + Assert.IsFalse (viewModel.PackageFeed.SearchFilter.IncludePrerelease); + } + + [Test] + public async Task ReadPackages_ExceptionThrownDuringLoad_ExceptionIsShownAsErrorMessage () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.LoadPackagesAsyncTask = (loader, token) => { + return Task.Run (() => { + throw new Exception ("Invalid url"); + }); + }; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.IsTrue (viewModel.HasError); + Assert.AreEqual ("Invalid url", viewModel.ErrorMessage); + } + + [Test] + public async Task ReadPackages_OneRecentPackageIsAvailable_RecentPackageIsDisplayedBeforeAnyOtherPackages () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + AddRecentPackage ("Recent", "2.1", packageSource.Name); + viewModel.PackageFeed.AddPackage ("Test", "1.3"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (2, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Recent", viewModel.PackageViewModels[0].Id); + Assert.AreEqual ("Test", viewModel.PackageViewModels[1].Id); + } + + [Test] + public async Task ReadPackages_OneRecentPackageIsAvailableWhichMatchesPackageFromActiveSource_DuplicatePackageWithSameVersionFromActivePackageSourceIsNotDisplayed () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + AddRecentPackage ("A", "2.1", packageSource.Name); + viewModel.PackageFeed.AddPackage ("A", "2.5"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.PackageViewModels.Count); + Assert.IsTrue (viewModel.PackageViewModels[0].IsRecentPackage); + Assert.AreEqual ("A", viewModel.PackageViewModels[0].Id); + } + + [Test] + public async Task ReadPackages_OneRecentPackageIsAvailableAndSearchTermEntered_RecentPackageIsNotDisplayed () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + AddRecentPackage ("A", "2.1", packageSource.Name); + viewModel.SearchTerms = "A"; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (0, viewModel.PackageViewModels.Count); + } + + [Test] + public async Task HasNextPage_TwoPagesOfData_HasNextPageIsFalseAfterSecondRead () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("Test", "1.3"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + bool hasNextPageAfterFirstRead = viewModel.HasNextPage; + viewModel.ReadPackagesTask = null; + viewModel.ShowNextPage (); + await viewModel.ReadPackagesTask; + + Assert.IsTrue (hasNextPageAfterFirstRead); + Assert.IsFalse (viewModel.HasNextPage); + } + + [Test] + public void IsReadingPackages_ReadPackagesNotCalled_ReturnsFalse () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + + Assert.IsFalse (viewModel.IsReadingPackages); + } + + [Test] + public async Task IsReadingPackages_ReadPackagesCalled_ReturnsTrue () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + bool readingPackages = false; + viewModel.LoadPackagesAsyncTask = (loader, token) => { + readingPackages = viewModel.IsReadingPackages; + return Task.FromResult (0); + }; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.IsTrue (readingPackages); + } + + [Test] + public async Task ErrorMessage_BackgroundTaskHasAggregateExceptionWithNestedInnerAggregateException_ErrorMessageTakenFromInnerException () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.LoadPackagesAsyncTask = (loader, token) => { + return Task.Run (() => { + var innerEx1 = new Exception ("Test1"); + var innerEx2 = new Exception ("Test2"); + var innerAggregateEx = new AggregateException (innerEx1, innerEx2); + var aggregateEx = new AggregateException (innerAggregateEx); + throw aggregateEx; + }); + }; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + string expectedErrorMessage = + "Test1" + Environment.NewLine + + "Test2"; + + Assert.AreEqual (expectedErrorMessage, viewModel.ErrorMessage); + } + + [Test] + public async Task HasError_ErrorMessageDisplayedAndSelectedPageChangedAfterFailure_ReturnsFalse () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.LoadPackagesAsyncTask = (loader, token) => { + return Task.Run (() => { + throw new Exception ("Error"); + }); + }; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + bool firstError = viewModel.HasError; + viewModel.ReadPackagesTask = null; + viewModel.LoadPackagesAsyncTask = null; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.IsFalse (viewModel.HasError); + Assert.AreEqual (string.Empty, viewModel.ErrorMessage); + Assert.IsTrue (firstError); + } + + [Test] + public void IsDisposed_DisposeMethodCalled_ReturnsTrue () + { + CreateProject (); + CreateViewModel (); + viewModel.Dispose (); + + Assert.IsTrue (viewModel.IsDisposed); + } + + [Test] + public void IsDisposed_DisposeMethodNotCalled_ReturnsFalse () + { + CreateProject (); + CreateViewModel (); + + Assert.IsFalse (viewModel.IsDisposed); + } + + [Test] + public async Task IncludePrerelease_ChangedToTrue_PackagesAreReadAgain () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.IncludePrerelease = false; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.ReadPackagesTask = null; + + viewModel.IncludePrerelease = true; + + Assert.IsNotNull (viewModel.ReadPackagesTask); + } + + [Test] + public async Task IncludePrerelease_ChangedToFalse_PackagesAreReadAgain () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.IncludePrerelease = true; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.ReadPackagesTask = null; + + viewModel.IncludePrerelease = false; + + Assert.IsNotNull (viewModel.ReadPackagesTask); + } + + [Test] + public async Task IncludePrerelease_ChangedToTrue_PropertyChangedEventIsFired () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.IncludePrerelease = false; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.ReadPackagesTask = null; + PropertyChangedEventArgs propertyChangedEvent = null; + viewModel.PropertyChanged += (sender, e) => propertyChangedEvent = e; + + viewModel.IncludePrerelease = true; + + Assert.IsNull (propertyChangedEvent.PropertyName); + } + + [Test] + public async Task IncludePrerelease_SetToTrueWhenAlreadyTrue_PropertyChangedEventIsNotFired () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.IncludePrerelease = true; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.ReadPackagesTask = null; + bool fired = false; + viewModel.PropertyChanged += (sender, e) => fired = true; + + viewModel.IncludePrerelease = true; + + Assert.IsFalse (fired); + } + + [Test] + public async Task CheckedPackageViewModels_TwoPackagesAndOnePackageIsChecked_ReturnsOneCheckedPackage () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("A", "1.2"); + viewModel.PackageFeed.AddPackage ("B", "1.3"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + viewModel.PackageViewModels[0].IsChecked = true; + + Assert.AreEqual (2, viewModel.PackageViewModels.Count); + Assert.AreEqual (1, viewModel.CheckedPackageViewModels.Count); + Assert.AreEqual ("A", viewModel.CheckedPackageViewModels[0].Id); + } + + [Test] + public async Task CheckedPackageViewModels_OnePackageIsCheckedThenNewSearchReturnsNoPackages_ReturnsCheckedPackageEvenWhenNotVisible () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels[0].IsChecked = true; + viewModel.PackageFeed = new FakePackageFeed (); + viewModel.PackageFeed.AddPackage ("AnotherPackage", "1.2"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.CheckedPackageViewModels.Count); + Assert.AreEqual ("MyPackage", viewModel.CheckedPackageViewModels[0].Id); + } + + [Test] + public async Task CheckedPackageViewModels_OnePackageIsCheckedAndThenUnchecked_ReturnsNoCheckedPackages () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.2"); + viewModel.PackageFeed.AddPackage ("Z-Package", "1.3"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + var packageViewModel = viewModel.PackageViewModels[0]; + packageViewModel.IsChecked = true; + packageViewModel.IsChecked = false; + + Assert.AreEqual (0, viewModel.CheckedPackageViewModels.Count); + } + + [Test] + public async Task PackageViewModels_OnePackageIsCheckedAndNewSearchReturnsOriginalPackage_PackageViewHasIsCheckedSetToTrue () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels[0].IsChecked = true; + viewModel.PackageFeed = new FakePackageFeed (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.Search (); + await viewModel.ReadPackagesTask; + + var packageViewModel = viewModel.PackageViewModels[0]; + + Assert.AreEqual ("MyPackage", packageViewModel.Id); + Assert.IsTrue (packageViewModel.IsChecked); + } + + [Test] + public async Task PackageViewModels_OnePackageIsCheckedAndNewSearchReturnsOriginalPackageButWithDifferentVersion_PackageViewIsCheckedAndSameVersionIsSelectedAsTheFirstPackageChecked () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels[0].IsChecked = true; + viewModel.PackageFeed = new FakePackageFeed (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.1"); + viewModel.Search (); + await viewModel.ReadPackagesTask; + + var packageViewModel = viewModel.PackageViewModels[0]; + + Assert.AreEqual ("MyPackage", packageViewModel.Id); + Assert.IsTrue (packageViewModel.IsChecked); + Assert.AreEqual ("1.0", packageViewModel.SelectedVersion.ToString ()); + Assert.AreEqual (2, packageViewModel.Versions.Count); + Assert.AreEqual ("1.1", packageViewModel.Versions[0].ToString ()); + Assert.AreEqual ("1.0", packageViewModel.Versions[1].ToString ()); + } + + [Test] + public async Task CheckedPackageViewModels_OnePackageIsCheckedAndNewSearchReturnsMultipleVersionsOfOriginalPackage_OnlyPackageWithSameVersionIsChecked () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels[0].IsChecked = true; + viewModel.PackageFeed = new FakePackageFeed (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.1"); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.2"); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.3"); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.4"); + viewModel.Search (); + await viewModel.ReadPackagesTask; + + var packageViewModel = viewModel.CheckedPackageViewModels.FirstOrDefault (); + + Assert.AreEqual ("MyPackage", packageViewModel.Id); + Assert.AreEqual ("1.4", packageViewModel.Version.ToString ()); + Assert.AreEqual ("1.0", packageViewModel.SelectedVersion.ToString ()); + Assert.AreEqual (1, viewModel.CheckedPackageViewModels.Count); + } + + [Test] + public async Task PackageViewModels_OnePackageIsCheckedAndNewSearchReturnsOriginalPackageWhichIsThenUncheckedByUser_NoCheckedPackageViewModels () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels [0].IsChecked = true; + viewModel.PackageFeed = new FakePackageFeed (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.Search (); + await viewModel.ReadPackagesTask; + var packageViewModel = viewModel.PackageViewModels[0]; + + viewModel.PackageViewModels[0].IsChecked = false; + + Assert.AreEqual (0, viewModel.CheckedPackageViewModels.Count); + } + + [Test] + public async Task CheckedPackageViewModels_OnePackageVersionIsCheckedThenDifferentVersionChecked_OldVersionIsUnchecked () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.1"); // Old + viewModel.PackageFeed.AddPackage ("MyPackage", "1.2"); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.0"); + viewModel.PackageFeed.AddPackage ("MyPackage", "1.3"); // New + viewModel.PackageFeed.AddPackage ("MyPackage", "1.4"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + var oldPackageVersionViewModel = viewModel + .PackageViewModels + .First (item => item.Version.ToString () == "1.1"); + var newPackageVersionViewModel = viewModel + .PackageViewModels + .First (item => item.Version.ToString () == "1.3"); + oldPackageVersionViewModel.IsChecked = true; + + newPackageVersionViewModel.IsChecked = true; + + Assert.AreEqual (1, viewModel.CheckedPackageViewModels.Count); + Assert.AreEqual ("MyPackage", viewModel.CheckedPackageViewModels[0].Id); + Assert.AreEqual ("1.3", viewModel.CheckedPackageViewModels[0].Version.ToString ()); + Assert.IsFalse (oldPackageVersionViewModel.IsChecked); + } + + [Test] + public async Task Log_ErrorReportedForOnePackageSource_ErrorDisplayed () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + bool propertyChangedEventFired = false; + viewModel.PropertyChanged += (sender, e) => propertyChangedEventFired = true; + var logger = viewModel as INuGetUILogger; + logger.Log (MessageLevel.Error, "Error"); + + Assert.IsTrue (viewModel.HasError); + Assert.AreEqual ("Error", viewModel.ErrorMessage); + Assert.IsTrue (propertyChangedEventFired); + } + + [Test] + public async Task Log_TwoPackageSourcesOneReportsErrorWhenAggregateSourceSelected_OnePackageSourceCouldNotBeReachedErrorDisplayed () + { + CreateProject (); + AddTwoPackageSourcesToRegisteredSources (); + CreateViewModel (); + viewModel.SelectedPackageSource = viewModel.PackageSources.First (); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + var logger = viewModel as INuGetUILogger; + logger.Log (MessageLevel.Error, "Test error occurred"); + + Assert.IsTrue (viewModel.HasError); + Assert.IsTrue (viewModel.ErrorMessage.Contains ("Test error occurred")); + Assert.IsTrue (viewModel.ErrorMessage.Contains ("Some package sources could not be reached.")); + } + + [Test] + public async Task Log_TwoPackageSourcesBothReportErrorWhenAggregateSourceSelected_AllPackageSourceCouldNotBeReachedErrorDisplayed () + { + CreateProject (); + AddTwoPackageSourcesToRegisteredSources (); + CreateViewModel (); + viewModel.SelectedPackageSource = viewModel.PackageSources.First (); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + var logger = viewModel as INuGetUILogger; + logger.Log (MessageLevel.Error, "Test error1 occurred"); + logger.Log (MessageLevel.Error, "Test error2 occurred"); + + Assert.IsTrue (viewModel.HasError); + Assert.IsTrue (viewModel.ErrorMessage.Contains ("Test error1 occurred")); + Assert.IsTrue (viewModel.ErrorMessage.Contains ("Test error2 occurred")); + Assert.IsTrue (viewModel.ErrorMessage.Contains ("All package sources could not be reached.")); + } + + [Test] + public async Task OnInstallingSelectedPackages_OnePackageSelected_PackageAddedToRecentPackages () + { + CreateProject (); + var source = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("Test", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.SelectedPackage = viewModel.PackageViewModels[0]; + + viewModel.OnInstallingSelectedPackages (); + + var package = viewModel.RecentPackagesRepository.GetPackages (source.Name).Single (); + Assert.AreEqual ("Test", package.Id); + } + + [Test] + public async Task OnInstallingSelectedPackages_OnePackageChecked_PackageAddedToRecentPackages () + { + CreateProject (); + var source = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("A", "1.0"); + viewModel.PackageFeed.AddPackage ("B", "1.2"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels[1].IsChecked = true; + + viewModel.OnInstallingSelectedPackages (); + + var package = viewModel.RecentPackagesRepository.GetPackages (source.Name).Single (); + Assert.AreEqual ("B", package.Id); + } + + [Test] + public void IsOlderPackageInstalled_NoPackagesInstalledInProject_ReturnsFalse () + { + CreateProject (); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + + bool result = viewModel.IsOlderPackageInstalled ("Test", new NuGetVersion ("1.0")); + + Assert.IsFalse (result); + } + + [Test] + public async Task IsOlderPackageInstalled_SamePackageVersionInstalledInProject_ReturnsFalse () + { + CreateProject (); + var nugetProject = CreateNuGetProjectForProject (); + nugetProject.AddPackageReference ("Test", "1.0"); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + await viewModel.GetPackagesInstalledInProjectTask; + + bool result = viewModel.IsOlderPackageInstalled ("Test", new NuGetVersion ("1.0")); + + Assert.IsFalse (result); + } + + [Test] + public async Task IsOlderPackageInstalled_OlderPackageVersionInstalledInProject_ReturnsTrue () + { + CreateProject (); + var nugetProject = CreateNuGetProjectForProject (); + nugetProject.AddPackageReference ("Test", "1.0"); + AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + await viewModel.GetPackagesInstalledInProjectTask; + + bool result = viewModel.IsOlderPackageInstalled ("Test", new NuGetVersion ("1.1")); + + Assert.IsTrue (result); + } + + [Test] + public async Task ReadPackages_RecentPackageWasCheckedWhenInstalled_RecentPackageIsNotCheckedWhenOpeningAddPackagesDialogAgain () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + var recentPackage = CreateRecentPackage ("Recent", "2.1", packageSource.Name); + recentPackage.IsChecked = true; + viewModel.RecentPackagesRepository.AddPackage (recentPackage, packageSource.Name); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Recent", viewModel.PackageViewModels[0].Id); + Assert.IsFalse (recentPackage.IsChecked); + } + + [Test] + public async Task ReadPackages_OneRecentPackageIsChecked_RecentPackageIsInCheckedPackagesList () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + AddRecentPackage ("Recent", "2.1", packageSource.Name); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + var package = viewModel.PackageViewModels.Single (); + package.IsChecked = true; + + var checkedPackage = viewModel.CheckedPackageViewModels.Single (); + Assert.AreEqual ("Recent", package.Id); + Assert.AreEqual ("Recent", checkedPackage.Id); + } + + [Test] + public async Task OnInstallingSelectedPackages_OnePackageChecked_RecentPackageParentIsCleared () + { + CreateProject (); + var source = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("A", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.PackageViewModels[0].IsChecked = true; + + viewModel.OnInstallingSelectedPackages (); + + var package = viewModel.RecentPackagesRepository.GetPackages (source.Name).Single (); + Assert.AreEqual ("A", package.Id); + Assert.IsNull (package.Parent); + } + + [Test] + public async Task OnInstallingSelectedPackages_OnePackageSelected_RecentPackageParentIsCleared () + { + CreateProject (); + var source = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + viewModel.PackageFeed.AddPackage ("A", "1.0"); + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + viewModel.SelectedPackage = viewModel.PackageViewModels.Single (); + + viewModel.OnInstallingSelectedPackages (); + + var package = viewModel.RecentPackagesRepository.GetPackages (source.Name).Single (); + Assert.AreEqual ("A", package.Id); + Assert.IsNull (package.Parent); + } + + [Test] + public async Task ReadPackages_RecentPackageWasPrereleaseAndNowSearchingForNonPrerelease_RecentPackageIsNotDisplayed () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + var recentPackage = AddRecentPackage ("Recent1", "2.1", packageSource.Name); + recentPackage.SelectedVersion = new NuGetVersion ("2.1-beta1"); + AddRecentPackage ("Recent2", "1.2", packageSource.Name); + viewModel.IncludePrerelease = false; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Recent2", viewModel.PackageViewModels[0].Id); + } + + [Test] + public async Task ReadPackages_RecentPackageWasPrereleaseAndNowSearchingForPrerelease_RecentPackageIsDisplayed () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + var recentPackage = AddRecentPackage ("Recent1", "2.1", packageSource.Name); + recentPackage.SelectedVersion = new NuGetVersion ("2.1-beta1"); + AddRecentPackage ("Recent2", "1.2", packageSource.Name); + viewModel.IncludePrerelease = true; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (2, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Recent2", viewModel.PackageViewModels[0].Id); + Assert.AreEqual ("Recent1", viewModel.PackageViewModels[1].Id); + } + + [Test] + public async Task ReadPackages_NonPrereleaseRecentPackageWasInstalledWhenSearchingForPrereleaseAndNowSearchingForNonPrerelease_RecentPackageIsDisplayedWithoutCachedPrereleaseVersionsDisplayed () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + var recentPackage = AddRecentPackage ("Recent1", "2.1", packageSource.Name); + recentPackage.SelectedVersion = new NuGetVersion ("2.1"); + recentPackage.Versions.Add (new NuGetVersion ("2.1")); + recentPackage.Versions.Add (new NuGetVersion ("2.0")); + recentPackage.Versions.Add (new NuGetVersion ("2.0-beta1")); + recentPackage.Versions.Add (new NuGetVersion ("2.0-beta2")); + viewModel.IncludePrerelease = false; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Recent1", viewModel.PackageViewModels[0].Id); + Assert.AreEqual (2, recentPackage.Versions.Count); + Assert.AreEqual ("2.1", recentPackage.Versions[0].ToString ()); + Assert.AreEqual ("2.0", recentPackage.Versions[1].ToString ()); + } + + [Test] + public async Task ReadPackages_NonPrereleaseRecentPackageWasInstalledWhenSearchingForPrereleaseAndSearchingForPrerelease_RecentPackageIsDisplayedWithCachedPrereleaseVersionsDisplayed () + { + CreateProject (); + var packageSource = AddOnePackageSourceToRegisteredSources (); + CreateViewModel (); + var recentPackage = AddRecentPackage ("Recent1", "2.1", packageSource.Name); + recentPackage.SelectedVersion = new NuGetVersion ("2.1"); + recentPackage.Versions.Add (new NuGetVersion ("2.1")); + recentPackage.Versions.Add (new NuGetVersion ("2.0")); + recentPackage.Versions.Add (new NuGetVersion ("2.0-beta1")); + recentPackage.Versions.Add (new NuGetVersion ("2.0-beta2")); + viewModel.IncludePrerelease = true; + viewModel.ReadPackages (); + await viewModel.ReadPackagesTask; + + Assert.AreEqual (1, viewModel.PackageViewModels.Count); + Assert.AreEqual ("Recent1", viewModel.PackageViewModels[0].Id); + Assert.AreEqual (4, recentPackage.Versions.Count); + } + + [Test] + public void PackageSources_AggregateSourceSelectedThenDialogClosedAndReopened_ReturnsTwoPackageSourcesPlusAggregatePackageSource () + { + CreateProject (); + AddTwoPackageSourcesToRegisteredSources (); + CreateViewModel (); + viewModel.SelectedPackageSource = viewModel.PackageSources.First (); + Assert.IsTrue (viewModel.SelectedPackageSource.IsAggregate); + CreateViewModel (); + + var selectedPackageSource = viewModel.SelectedPackageSource; + + Assert.AreEqual ("All Sources", selectedPackageSource.Name); + Assert.IsTrue (selectedPackageSource.IsAggregate); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/AvailablePackagesViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/AvailablePackagesViewModelTests.cs deleted file mode 100644 index 845d13fa87..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/AvailablePackagesViewModelTests.cs +++ /dev/null @@ -1,1237 +0,0 @@ -//
-// AvailablePackagesViewModelTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class AvailablePackagesViewModelTests
- {
- AvailablePackagesViewModel viewModel;
- FakeRegisteredPackageRepositories registeredPackageRepositories;
- ExceptionThrowingRegisteredPackageRepositories exceptionThrowingRegisteredPackageRepositories;
- FakeTaskFactory taskFactory;
- FakeRecentPackageRepository recentPackageRepository;
- FakePackageManagementSolution solution;
-
- void CreateViewModel ()
- {
- CreateRegisteredPackageRepositories ();
- CreateViewModel (registeredPackageRepositories);
- }
-
- void CreateRegisteredPackageRepositories ()
- {
- registeredPackageRepositories = new FakeRegisteredPackageRepositories ();
- }
-
- void CreateViewModel (FakeRegisteredPackageRepositories registeredPackageRepositories)
- {
- CreateSolution ();
- CreateViewModel (registeredPackageRepositories, solution);
- }
-
- void CreateViewModel (
- FakeRegisteredPackageRepositories registeredPackageRepositories,
- FakePackageManagementSolution solution)
- {
- taskFactory = new FakeTaskFactory ();
- var packageViewModelFactory = new FakePackageViewModelFactory ();
- recentPackageRepository = new FakeRecentPackageRepository ();
-
-
- viewModel = new AvailablePackagesViewModel (
- solution,
- registeredPackageRepositories,
- recentPackageRepository,
- packageViewModelFactory,
- taskFactory);
- }
-
- void CreateSolution ()
- {
- solution = new FakePackageManagementSolution ();
- }
-
- void CreateExceptionThrowingRegisteredPackageRepositories ()
- {
- exceptionThrowingRegisteredPackageRepositories = new ExceptionThrowingRegisteredPackageRepositories ();
- }
-
- void CompleteReadPackagesTask ()
- {
- taskFactory.ExecuteAllFakeTasks ();
- }
-
- void ClearReadPackagesTasks ()
- {
- taskFactory.ClearAllFakeTasks ();
- }
-
- void AddOnePackageSourceToRegisteredSources ()
- {
- registeredPackageRepositories.ClearPackageSources ();
- registeredPackageRepositories.AddOnePackageSource ();
- registeredPackageRepositories.HasMultiplePackageSources = false;
- registeredPackageRepositories.ActivePackageSource = registeredPackageRepositories.PackageSources [0];
- }
-
- void AddTwoPackageSourcesToRegisteredSources ()
- {
- var expectedPackageSources = new PackageSource[] {
- new PackageSource ("http://first.com", "First"),
- new PackageSource ("http://second.com", "Second")
- };
- AddPackageSourcesToRegisteredSources (expectedPackageSources);
- registeredPackageRepositories.HasMultiplePackageSources = true;
- registeredPackageRepositories.ActivePackageSource = expectedPackageSources [0];
- }
-
- void AddPackageSourcesToRegisteredSources (PackageSource[] sources)
- {
- registeredPackageRepositories.ClearPackageSources ();
- registeredPackageRepositories.AddPackageSources (sources);
- }
-
- PackageSource AddTwoPackageSourcesToRegisteredSourcesWithFirstOneDisabled ()
- {
- var expectedPackageSources = new PackageSource[] {
- new PackageSource ("http://first.com", "First") { IsEnabled = false },
- new PackageSource ("http://second.com", "Second") { IsEnabled = true }
- };
- AddPackageSourcesToRegisteredSources (expectedPackageSources);
- registeredPackageRepositories.HasMultiplePackageSources = true;
- return expectedPackageSources [0];
- }
-
- void CreateNewActiveRepositoryWithDifferentPackages ()
- {
- var package = new FakePackage ("NewRepositoryPackageId");
- var newRepository = new FakePackageRepository ();
- newRepository.FakePackages.Add (package);
- registeredPackageRepositories.FakeActiveRepository = newRepository;
- }
-
- void SetUpTwoPackageSourcesAndViewModelHasReadPackages ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
- registeredPackageRepositories.ActivePackageSource = registeredPackageRepositories.PackageSources [0];
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- CreateNewActiveRepositoryWithDifferentPackages ();
- }
-
- void ChangeSelectedPackageSourceToSecondSource ()
- {
- var secondPackageSource = registeredPackageRepositories.PackageSources [1];
- viewModel.SelectedPackageSource = secondPackageSource;
- }
-
- void ChangeSelectedPackageSourceToFirstSource ()
- {
- var firstPackageSource = registeredPackageRepositories.PackageSources [0];
- viewModel.SelectedPackageSource = firstPackageSource;
- }
-
- void SearchForAllPackageVersions (string packageId, string versions = "")
- {
- viewModel.SearchTerms = string.Format ("{0} version:{1}", packageId, versions).TrimEnd ();
- }
-
- void AddAggregateRepositoryWithOneFailingRepository ()
- {
- AddAggregateRepository (new ExceptionThrowingPackageRepository (), new FakePackageRepository ());
- }
-
- void AddAggregateRepository (params IPackageRepository[] repositories)
- {
- var repository = new MonoDevelopAggregateRepository (repositories);
- registeredPackageRepositories.ActivePackageSource = registeredPackageRepositories.PackageSources [0];
- registeredPackageRepositories.GetActiveRepositoryAction = () => {
- return repository;
- };
- }
-
- void AddAggregateRepositoryWithJustFailingRepositories ()
- {
- AddAggregateRepository (new ExceptionThrowingPackageRepository (), new ExceptionThrowingPackageRepository ());
- }
-
- void AddAggregateRepositoryWithTwoFailingRepositories (Exception exception1, Exception exception2)
- {
- AddAggregateRepository (
- new ExceptionThrowingPackageRepository (exception1),
- new ExceptionThrowingPackageRepository (exception2));
- }
-
- FakePackage AddPackageToSolution (string packageId, string packageVersion)
- {
- var package = FakePackage.CreatePackageWithVersion (packageId, packageVersion);
- solution.SolutionPackageRepository.FakePackages.Add (package);
- return package;
- }
-
- [Test]
- public void ReadPackages_RepositoryHasThreePackagesWithSameIdButDifferentVersions_HasLatestPackageVersionOnly ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
-
- var package1 = new FakePackage ("Test", "0.1.0.0");
- var package2 = new FakePackage ("Test", "0.2.0.0");
- var package3 = new FakePackage ("Test", "0.3.0.0");
-
- var packages = new FakePackage[] {
- package1, package2, package3
- };
-
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package3
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void IsSearchable_ByDefault_ReturnsTrue ()
- {
- CreateViewModel ();
- Assert.IsTrue (viewModel.IsSearchable);
- }
-
- [Test]
- public void Search_RepositoryHasThreePackagesWithSameIdButSearchTermsMatchNoPackageIds_ReturnsNoPackages ()
- {
- CreateViewModel ();
-
- var package1 = new FakePackage ("Test", "0.1.0.0");
- var package2 = new FakePackage ("Test", "0.2.0.0");
- var package3 = new FakePackage ("Test", "0.3.0.0");
-
- var packages = new FakePackage[] {
- package1, package2, package3
- };
-
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ClearReadPackagesTasks ();
- viewModel.SearchTerms = "NotAMatch";
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- Assert.AreEqual (0, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void ShowNextPage_TwoObjectsWatchingForPagesCollectionChangedEventAndUserMovesToPageTwoAndFilteredPackagesReturnsLessThanExpectedPackagesDueToMatchingVersions_InvalidOperationExceptionNotThrownWhen ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- viewModel.PageSize = 2;
-
- var package1 = new FakePackage ("First", "0.1.0.0");
- var package2 = new FakePackage ("Second", "0.2.0.0");
- var package3 = new FakePackage ("Test", "0.3.0.0");
- var package4 = new FakePackage ("Test", "0.4.0.0");
-
- var packages = new FakePackage[] {
- package1, package2, package3, package4
- };
-
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ClearReadPackagesTasks ();
- bool collectionChangedEventFired = false;
- viewModel.Pages.CollectionChanged += (sender, e) => collectionChangedEventFired = true;
- viewModel.ShowNextPage ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package4
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- Assert.IsTrue (collectionChangedEventFired);
- }
-
- [Test]
- public void ShowSources_TwoPackageSources_ReturnsTrue ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- Assert.IsTrue (viewModel.ShowPackageSources);
- }
-
- [Test]
- public void ShowPackageSources_OnePackageSources_ReturnsTrue ()
- {
- CreateRegisteredPackageRepositories ();
- AddOnePackageSourceToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- Assert.IsTrue (viewModel.ShowPackageSources);
- }
-
- [Test]
- public void PackageSources_TwoPackageSourcesInOptions_ReturnsTwoPackageSourcesPlusAggregatePackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- var expectedPackageSources = new List<PackageSource> (registeredPackageRepositories.PackageSources);
- expectedPackageSources.Insert (0, RegisteredPackageSourceSettings.AggregatePackageSource);
-
- PackageSourceCollectionAssert.AreEqual (expectedPackageSources, viewModel.PackageSources);
- }
-
- [Test]
- public void PackageSources_OnePackageSourceInOptions_ReturnsOnePackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- AddOnePackageSourceToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- var expectedPackageSources = new List<PackageSource> (registeredPackageRepositories.PackageSources);
-
- PackageSourceCollectionAssert.AreEqual (expectedPackageSources, viewModel.PackageSources);
- }
-
- [Test]
- public void SelectedPackageSource_TwoPackageSourcesInOptionsAndActivePackageSourceIsFirstSource_IsFirstPackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- var expectedPackageSource = registeredPackageRepositories.PackageSources [0];
- registeredPackageRepositories.ActivePackageSource = expectedPackageSource;
-
- Assert.AreEqual (expectedPackageSource, viewModel.SelectedPackageSource);
- }
-
- [Test]
- public void SelectedPackageSource_TwoPackageSourcesInOptionsAndActivePackageSourceIsSecondSource_IsSecondPackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- var expectedPackageSource = registeredPackageRepositories.PackageSources [1];
- registeredPackageRepositories.ActivePackageSource = expectedPackageSource;
-
- Assert.AreEqual (expectedPackageSource, viewModel.SelectedPackageSource);
- }
-
- [Test]
- public void SelectedPackageSource_Changed_ActivePackageSourceChanged ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSources ();
- CreateViewModel (registeredPackageRepositories);
-
- registeredPackageRepositories.ActivePackageSource = registeredPackageRepositories.PackageSources [0];
- var expectedPackageSource = registeredPackageRepositories.PackageSources [1];
- viewModel.SelectedPackageSource = expectedPackageSource;
-
- Assert.AreEqual (expectedPackageSource, registeredPackageRepositories.ActivePackageSource);
- }
-
- [Test]
- public void SelectedPackageSource_PackageSourceChangedAfterReadingPackages_PackagesReadFromNewPackageSourceAndDisplayed ()
- {
- SetUpTwoPackageSourcesAndViewModelHasReadPackages ();
- ClearReadPackagesTasks ();
- ChangeSelectedPackageSourceToSecondSource ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = registeredPackageRepositories.FakeActiveRepository.FakePackages;
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void SelectedPackageSource_PackageSourceChangedAfterReadingPackages_PropertyChangedEventFiredAfterPackagesAreRead ()
- {
- SetUpTwoPackageSourcesAndViewModelHasReadPackages ();
-
- int packageCountWhenPropertyChangedEventFired = -1;
- viewModel.PropertyChanged += (sender, e) => packageCountWhenPropertyChangedEventFired = viewModel.PackageViewModels.Count;
- ClearReadPackagesTasks ();
- ChangeSelectedPackageSourceToSecondSource ();
- CompleteReadPackagesTask ();
-
- Assert.AreEqual (1, packageCountWhenPropertyChangedEventFired);
- }
-
- [Test]
- public void SelectedPackageSource_PackageSourceChangedButToSameSelectedPackageSource_PackagesAreNotRead ()
- {
- SetUpTwoPackageSourcesAndViewModelHasReadPackages ();
- ChangeSelectedPackageSourceToFirstSource ();
-
- Assert.AreEqual (0, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void SelectedPackageSource_PackageSourceChangedButToSameSelectedPackageSource_PropertyChangedEventNotFired ()
- {
- SetUpTwoPackageSourcesAndViewModelHasReadPackages ();
-
- bool fired = false;
- viewModel.PropertyChanged += (sender, e) => fired = true;
- ChangeSelectedPackageSourceToFirstSource ();
-
- Assert.IsFalse (fired);
- }
-
- [Test]
- public void GetAllPackages_OnePackageInRepository_RepositoryNotCreatedByBackgroundThread ()
- {
- CreateRegisteredPackageRepositories ();
- AddOnePackageSourceToRegisteredSources ();
- registeredPackageRepositories.FakeActiveRepository.FakePackages.Add (new FakePackage ());
- CreateViewModel (registeredPackageRepositories);
- viewModel.ReadPackages ();
-
- registeredPackageRepositories.FakeActiveRepository = null;
- CompleteReadPackagesTask ();
-
- Assert.AreEqual (1, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void ReadPackages_ExceptionThrownWhenAccessingActiveRepository_ErrorMessageFromExceptionNotOverriddenByReadPackagesCall ()
- {
- CreateExceptionThrowingRegisteredPackageRepositories ();
- exceptionThrowingRegisteredPackageRepositories.ExceptionToThrowWhenActiveRepositoryAccessed =
- new Exception ("Test");
- CreateViewModel (exceptionThrowingRegisteredPackageRepositories);
- exceptionThrowingRegisteredPackageRepositories.ActivePackageSource = new PackageSource ("Test");
- viewModel.ReadPackages ();
-
- ApplicationException ex = Assert.Throws<ApplicationException> (CompleteReadPackagesTask);
- Assert.AreEqual ("Test", ex.Message);
- }
-
- [Test]
- public void ReadPackages_RepositoryHasPrereleaseAndReleasePackage_HasReleasePackageOnly ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var releasePackage = new FakePackage ("Test", "1.1.0.0");
- var prereleasePackage = new FakePackage ("Test", "1.1.0-alpha");
-
- var packages = new FakePackage[] {
- releasePackage, prereleasePackage
- };
-
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- releasePackage
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_TwoPackagesWithDifferentDownloadCounts_HighestDownloadCountShownFirst ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
-
- var package1 = new FakePackage ("A", "0.1.0.0") { DownloadCount = 1 };
- var package2 = new FakePackage ("Z", "0.1.0.0") { DownloadCount = 1000 };
-
- var packages = new FakePackage[] {
- package1, package2
- };
-
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package2, package1
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void GetPackagesFromPackageSource_RepositoryHasThreePackagesWithSameIdButDifferentVersions_LatestPackageVersionOnlyRequestedFromPackageSource ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("Test", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("Test", "0.2.0.0") { IsLatestVersion = false };
- var package3 = new FakePackage ("Test", "0.3.0.0") { IsLatestVersion = true };
- var packages = new FakePackage[] {
- package1, package2, package3
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- viewModel.ReadPackages ();
-
- IList<IPackage> allPackages = viewModel.GetPackagesFromPackageSource ().ToList ();
-
- var expectedPackages = new FakePackage[] {
- package3
- };
- PackageCollectionAssert.AreEqual (expectedPackages, allPackages);
- }
-
- [Test]
- public void PackageSources_TwoPackageSourcesButFirstIsDisabled_DoesNotReturnDisabledPackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- AddTwoPackageSourcesToRegisteredSourcesWithFirstOneDisabled ();
- CreateViewModel (registeredPackageRepositories);
-
- IEnumerable<PackageSource> packageSources = viewModel.PackageSources;
-
- bool containsDisabledPackageSource = packageSources.Contains (registeredPackageRepositories.PackageSources [0]);
- bool containsEnabledPackageSource = packageSources.Contains (registeredPackageRepositories.PackageSources [1]);
- Assert.IsFalse (containsDisabledPackageSource);
- Assert.IsTrue (containsEnabledPackageSource);
- }
-
- [Test]
- public void IsInstallAllPackagesEnabled_RepositoryHasTwoPackages_ReturnsFalse ()
- {
- CreateViewModel ();
- var package1 = new FakePackage ("Test", "0.1.0.0");
- var package2 = new FakePackage ("Test", "0.2.0.0");
- var packages = new FakePackage[] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- bool enabled = viewModel.IsUpdateAllPackagesEnabled;
-
- Assert.IsFalse (enabled);
- }
-
- [Test]
- public void ShowPrerelease_ByDefault_ReturnsTrue ()
- {
- CreateViewModel ();
-
- bool show = viewModel.ShowPrerelease;
-
- Assert.IsTrue (show);
- }
-
- [Test]
- public void ReadPackages_RepositoryHasPrereleasePackageAndIncludePrereleaseIsTrue_HasPrereleasePackageInList ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- viewModel.IncludePrerelease = true;
- var prereleasePackage = new FakePackage ("Test", "1.1.0-alpha") {
- IsLatestVersion = false,
- IsAbsoluteLatestVersion = true
- };
- var expectedPackages = new FakePackage[] { prereleasePackage };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (expectedPackages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_RepositoryHasThreePrereleasePackagesWithSameIdButDifferentVersionsAndIncludePrereleaseIsTrue_HasLatestPreleasePackageVersionOnly ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- viewModel.IncludePrerelease = true;
- var package1 = new FakePackage ("Test", "0.1.0.0-alpha") { IsLatestVersion = false };
- var package2 = new FakePackage ("Test", "0.2.0.0-alpha") { IsLatestVersion = false };
- var package3 = new FakePackage ("Test", "0.3.0.0-alpha") { IsLatestVersion = false, IsAbsoluteLatestVersion = true };
- var packages = new FakePackage[] {
- package1, package2, package3
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package3
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void PackageViewModels_GetParentOfPackageViewModel_ReturnsAvailablePackagesViewModel ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("Test", "0.1.0.0");
- var package2 = new FakePackage ("Test", "0.2.0.0");
- var packages = new FakePackage[] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- PackageViewModel childViewModel = viewModel.PackageViewModels.First ();
-
- IPackageViewModelParent parent = childViewModel.GetParent ();
-
- Assert.AreEqual (viewModel, parent);
- }
-
- [Test]
- public void GetPackagesFromPackageSource_RepositoryIsServiceBasedRepository_ServiceBasedRepositorySearchUsed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package = FakePackage.CreatePackageWithVersion ("Test", "0.1.0.0");
- var packages = new FakePackage[] { package };
- var repository = new FakeServiceBasedRepository ();
- repository.PackagesToReturnForSearch ("id:test", false, packages);
- registeredPackageRepositories.FakeActiveRepository = repository;
- viewModel.SearchTerms = "id:test";
- viewModel.IncludePrerelease = false;
- viewModel.ReadPackages ();
-
- IList<IPackage> allPackages = viewModel.GetPackagesFromPackageSource ().ToList ();
-
- var expectedPackages = new FakePackage[] { package };
- PackageCollectionAssert.AreEqual (expectedPackages, allPackages);
- }
-
- [Test]
- public void GetPackagesFromPackageSource_RepositoryIsServiceBasedRepositoryAndPrereleaseIncluded_ServiceBasedRepositorySearchUsed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package = FakePackage.CreatePackageWithVersion ("Test", "0.1.0.0");
- package.IsAbsoluteLatestVersion = true;
- var packages = new FakePackage[] { package };
- var repository = new FakeServiceBasedRepository ();
- repository.PackagesToReturnForSearch ("id:test", true, packages);
- registeredPackageRepositories.FakeActiveRepository = repository;
- viewModel.SearchTerms = "id:test";
- viewModel.IncludePrerelease = true;
- viewModel.ReadPackages ();
-
- IList<IPackage> allPackages = viewModel.GetPackagesFromPackageSource ().ToList ();
-
- var expectedPackages = new FakePackage[] { package };
- PackageCollectionAssert.AreEqual (expectedPackages, allPackages);
- }
-
- [Test]
- public void GetPackagesFromPackageSource_RepositoryHasThreePackagesWithSameIdButDifferentVersionsAndSearchIncludesPrerelease_AbsoluteLatestPackageVersionOnlyRequestedFromPackageSource ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("Test", "0.1.0.0") { IsAbsoluteLatestVersion = false };
- var package2 = new FakePackage ("Test", "0.2.0.0") { IsAbsoluteLatestVersion = false };
- var package3 = new FakePackage ("Test", "0.3.0.0") { IsAbsoluteLatestVersion = true };
- var packages = new FakePackage[] {
- package1, package2, package3
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- viewModel.IncludePrerelease = true;
- viewModel.ReadPackages ();
-
- IList<IPackage> allPackages = viewModel.GetPackagesFromPackageSource ().ToList ();
-
- var expectedPackages = new FakePackage[] {
- package3
- };
- PackageCollectionAssert.AreEqual (expectedPackages, allPackages);
- }
-
- [Test]
- public void ReadPackages_ActiveRepositoryChangedWhichUsesInvalidUrl_InvalidUrlExceptionIsShownAsErrorMessage ()
- {
- CreateExceptionThrowingRegisteredPackageRepositories ();
- CreateViewModel (exceptionThrowingRegisteredPackageRepositories);
- exceptionThrowingRegisteredPackageRepositories.ActivePackageSource = new PackageSource ("test");
- var package = new FakePackage ("Test", "0.1.0.0");
- exceptionThrowingRegisteredPackageRepositories
- .FakeActiveRepository
- .FakePackages
- .Add (package);
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- taskFactory.ClearAllFakeTasks ();
- exceptionThrowingRegisteredPackageRepositories.ExceptionToThrowWhenActiveRepositoryAccessed =
- new Exception ("Invalid url");
-
- viewModel.ReadPackages ();
- FakeTask<PackagesForSelectedPageResult> task = taskFactory.FirstFakeTaskCreated;
- ApplicationException ex = Assert.Throws<ApplicationException> (() => task.ExecuteTaskButNotContinueWith ());
- task.Exception = new AggregateException (ex);
- task.IsFaulted = true;
- task.ExecuteContinueWith ();
-
- Assert.AreEqual ("Invalid url", ex.Message);
- Assert.IsTrue (viewModel.HasError);
- Assert.AreEqual ("Invalid url", viewModel.ErrorMessage);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersionsWhenThreePackageVersionsAvailable_ShowsOnlyPackagesWithSameIdAndAllVersionsWithHighestVersionFirst ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.3.0.0");
- var package3 = new FakePackage ("A", "0.2.0.0") { IsLatestVersion = false };
- var package4 = new FakePackage ("AA", "0.1.0.0");
- var packages = new FakePackage[] {
- package1, package2, package3, package4
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package2, package3, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersionsWhenThreePackageVersionsAvailableButOneIsPrerelease_ShowsOnlyNonPrereleasePackages ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.2.0.0");
- var package3 = new FakePackage ("A", "0.2.0-alpha") { IsLatestVersion = false };
- var packages = new FakePackage[] {
- package1, package2, package3
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package2, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersionsIncludePrereleaseWhenOneIsPrereleaseAndOneIsRelease_ShowsAllPackages ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.2.0.0");
- var package2 = new FakePackage ("A", "0.2.0-alpha") { IsLatestVersion = false };
- var packages = new FakePackage[] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a");
- viewModel.IncludePrerelease = true;
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package1, package2
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersionsWhenOneRecentPackageIsAvailable_RecentPackagesNotDisplayed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.2.0.0");
- var packages = new FakePackage[] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- var recentPackage = new FakePackage ("A", "0.2.0.0") {
- Description = "A -version"
- };
- recentPackageRepository.AddPackage (recentPackage);
- SearchForAllPackageVersions ("a");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package2, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersions_ShowVersionInsteadOfDownloadCountIsTrueForEachPackageViewModel ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.2.0.0");
- var packages = new FakePackage[] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.PackageViewModels [0].ShowVersionInsteadOfDownloadCount);
- Assert.IsTrue (viewModel.PackageViewModels [1].ShowVersionInsteadOfDownloadCount);
- }
-
- [Test]
- public void ReadPackages_SearchForPackage_ShowVersionInsteadOfDownloadCountIsFalseForEachPackageViewModel ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0");
- var package2 = new FakePackage ("B", "0.2.0.0");
- var packages = new FakePackage[] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- Assert.IsFalse (viewModel.PackageViewModels [0].ShowVersionInsteadOfDownloadCount);
- Assert.IsFalse (viewModel.PackageViewModels [1].ShowVersionInsteadOfDownloadCount);
- }
-
- [Test]
- public void ReadPackages_SearchForSinglePackageVersionWhenThreePackageVersionsAvailable_ShowsSinglePackagesWithSameIdAndSameVersion ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.3.0.0");
- var package3 = new FakePackage ("A", "0.2.0.0") { IsLatestVersion = false };
- var packages = new FakePackage[] {
- package1, package2, package3
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a", "0.2");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package3
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersionsUsingAsteriskWhenThreePackageVersionsAvailable_HasAllPackageVersions ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.3.0.0");
- var package3 = new FakePackage ("A", "0.2.0.0") { IsLatestVersion = false };
- var packages = new FakePackage[] {
- package1, package2, package3
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a", "*");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package2, package3, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllOnePointZeroPackageVersionsUsingVersionOne_ReturnsAllOnePointZeroVersions ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "2.1.0.0");
- var package3 = new FakePackage ("A", "2.0.0.0") { IsLatestVersion = false };
- var package4 = new FakePackage ("A", "1.1.0.0") { IsLatestVersion = false };
- var package5 = new FakePackage ("A", "1.9.0.0") { IsLatestVersion = false };
- var package6 = new FakePackage ("A", "1.2.0.0") { IsLatestVersion = false };
- var package7 = new FakePackage ("A", "1.3.0.0") { IsLatestVersion = false };
- var package8 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var packages = new FakePackage[] {
- package1, package2, package3, package4, package5, package6, package7, package8
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("a", "1");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package5, package7, package6, package4, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_ActivePackageSourceIsAggregatePackageRepositoryWithOneFailingRepository_HasErrorIsTrueAndErrorMessageHasWarning ()
- {
- CreateRegisteredPackageRepositories ();
- AddAggregateRepositoryWithOneFailingRepository ();
- CreateViewModel (registeredPackageRepositories);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.HasError);
- Assert.That (viewModel.ErrorMessage, Contains.Substring ("Some package sources could not be reached."));
- }
-
- [Test]
- public void ReadPackages_ActivePackageSourceIsAggregatePackageRepositoryWithAllRepositoriesFailing_HasErrorIsTrueAndErrorMessageHasWarning ()
- {
- CreateRegisteredPackageRepositories ();
- AddAggregateRepositoryWithJustFailingRepositories ();
- CreateViewModel (registeredPackageRepositories);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.HasError);
- Assert.That (viewModel.ErrorMessage, Contains.Substring ("All package sources could not be reached."));
- }
-
- [Test]
- public void ReadPackages_ActivePackageSourceIsAggregatePackageRepositoryWithAllRepositoriesFailing_RepositoryErrorIsDisplayed ()
- {
- CreateRegisteredPackageRepositories ();
- var exception1 = new Exception ("Error1");
- var exception2 = new Exception ("Error2");
- AddAggregateRepositoryWithTwoFailingRepositories (exception1, exception2);
- CreateViewModel (registeredPackageRepositories);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.HasError);
- Assert.That (viewModel.ErrorMessage, Contains.Substring ("Error1"));
- Assert.That (viewModel.ErrorMessage, Contains.Substring ("Error2"));
- }
-
- [Test]
- public void ReadPackages_ActivePackageSourceIsAggregatePackageRepositoryWithOneFailingRepository_RepositoryErrorIsDisplayed ()
- {
- CreateRegisteredPackageRepositories ();
- var repository = new ExceptionThrowingPackageRepository (new Exception ("Error1"));
- AddAggregateRepository (new FakePackageRepository (), repository);
- CreateViewModel (registeredPackageRepositories);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.HasError);
- Assert.That (viewModel.ErrorMessage, Contains.Substring ("Error1"));
- }
-
- [Test]
- public void ReadPackages_OneRecentPackageIsAvailable_RecentPackageIsDisplayedBeforeAnyOtherPackages ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.2.0.0");
- var package2 = new FakePackage ("Aa", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- var recentPackage = new FakePackage ("B", "1.0.0.0");
- recentPackageRepository.AddPackage (recentPackage);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- recentPackage, package1, package2
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_OneRecentPackageIsAvailableWhichMatchesPackageFromActiveSource_DuplicatePackageWithSameVersionFromActivePackageSourceIsNotDisplayed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- var recentPackage = new FakePackage ("A", "1.0.0.0");
- recentPackageRepository.AddPackage (recentPackage);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- recentPackage, package2
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_TwoRecentPackageAndSearchTextEntered_RecentPackagesAreFilteredBySearch ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- var recentPackage = new FakePackage ("Aa", "1.0.0.0");
- recentPackageRepository.AddPackage (recentPackage);
- recentPackageRepository.AddPackage (new FakePackage ("Bb", "1.0.0.0"));
- viewModel.SearchTerms = "a";
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- recentPackage, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SolutionHasOnePackageInstalled_SolutionPackageDisplayedBeforeActivePackageSourcePackages ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- FakePackage installedPackage = AddPackageToSolution ("ZZ", "1.0.0.0");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- installedPackage, package1, package2
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SolutionHasOnePackageInstalledAndSecondPageOfPackagesIsReadWhenInfiniteScrollIsEnabled_SolutionPackageIsNotAddedTwice ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var package3 = new FakePackage ("C", "0.1.0.0");
- var package4 = new FakePackage ("D", "0.1.0.0");
- var packages = new [] {
- package1, package2, package3, package4
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- FakePackage installedPackage = AddPackageToSolution ("ZZ", "1.0.0.0");
- viewModel.PageSize = 2;
- viewModel.ClearPackagesOnPaging = false;
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.ShowNextPage ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- installedPackage, package1, package2, package3, package4
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_OneSolutionPackageMatchesPackageFromActiveSource_DuplicatePackageWithSameVersionFromActiveSourceIsNotDisplayed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- FakePackage installedPackage = AddPackageToSolution ("A", "1.0.0.0");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- installedPackage, package2
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_OneSolutionPackageMatchesRecentPackage_DuplicateSolutionPackageWithSameVersionIsNotDisplayed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- var recentPackage = new FakePackage ("A", "1.0.0.0");
- recentPackageRepository.AddPackage (recentPackage);
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- FakePackage installedPackage = AddPackageToSolution ("A", "1.0.0.0");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- recentPackage, package2
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_SearchForAllPackageVersionsWhenOneSolutionPackageAvailable_SolutionPackageIsNotDisplayed ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "0.1.0.0") { IsLatestVersion = false };
- var package2 = new FakePackage ("A", "0.2.0.0");
- FakePackage installedPackage = AddPackageToSolution ("A", "1.0.0.0");
- var packages = new [] { package1, package2 };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- SearchForAllPackageVersions ("A");
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package2, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_TwoSolutionPackagesAndSearchTextEntered_SolutionPackagesAreFilteredBySearch ()
- {
- CreateViewModel ();
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- FakePackage installedPackage = AddPackageToSolution ("Aa", "1.0.0.0");
- AddPackageToSolution ("Bb", "1.0.0.0");
- viewModel.SearchTerms = "a";
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new [] {
- installedPackage, package1
- };
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_TwoSolutionPackagesAndSecondOneThrowsExceptionWhenBeingReturned_ExceptionHandled ()
- {
- CreateSolution ();
- var solutionPackageRepository = new ExceptionThrowingSolutionPackageRepository {
- ThrowExceptionOnIteration = 1
- };
- solution.SolutionPackageRepository = solutionPackageRepository;
- CreateRegisteredPackageRepositories ();
- CreateViewModel (registeredPackageRepositories, solution);
- AddOnePackageSourceToRegisteredSources ();
- var package1 = new FakePackage ("A", "1.0.0.0");
- var package2 = new FakePackage ("B", "0.3.0.0");
- var packages = new [] {
- package1, package2
- };
- registeredPackageRepositories.FakeActiveRepository.FakePackages.AddRange (packages);
- AddPackageToSolution ("Aa", "1.0.0.0");
- AddPackageToSolution ("Bb", "1.0.0.0");
-
- viewModel.ReadPackages ();
- Assert.DoesNotThrow (() => CompleteReadPackagesTask ());
-
- PackageCollectionAssert.AreEqual (packages, viewModel.PackageViewModels);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/BackgroundPackageActionRunnerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/BackgroundPackageActionRunnerTests.cs index 34e787f129..5c56b2071b 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/BackgroundPackageActionRunnerTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/BackgroundPackageActionRunnerTests.cs @@ -27,10 +27,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using MonoDevelop.PackageManagement;
using MonoDevelop.PackageManagement.Tests.Helpers;
using NUnit.Framework;
using NuGet;
+using NuGet.PackageManagement;
using MonoDevelop.Core;
namespace MonoDevelop.PackageManagement.Tests
@@ -41,11 +41,10 @@ namespace MonoDevelop.PackageManagement.Tests TestableBackgroundPackageActionRunner runner;
FakeProgressMonitorFactory progressMonitorFactory;
PackageManagementEvents packageManagementEvents;
- PackageManagementProgressProvider progressProvider;
List<IPackageAction> actions;
ProgressMonitorStatusMessage progressMessage;
FakeProgressMonitor progressMonitor;
- FakePackageRepositoryFactoryEvents repositoryFactoryEvents;
+ TestableInstrumentationService instrumentationService;
void CreateRunner ()
{
@@ -54,15 +53,12 @@ namespace MonoDevelop.PackageManagement.Tests packageManagementEvents = new PackageManagementEvents ();
progressMonitorFactory = new FakeProgressMonitorFactory ();
progressMonitor = progressMonitorFactory.ProgressMonitor;
- repositoryFactoryEvents = new FakePackageRepositoryFactoryEvents ();
- progressProvider = new PackageManagementProgressProvider (repositoryFactoryEvents, handler => {
- handler.Invoke ();
- });
+ instrumentationService = new TestableInstrumentationService ();
runner = new TestableBackgroundPackageActionRunner (
progressMonitorFactory,
packageManagementEvents,
- progressProvider);
+ instrumentationService);
}
void Run ()
@@ -76,81 +72,104 @@ namespace MonoDevelop.PackageManagement.Tests runner.Run (progressMessage, actions);
}
- FakeInstallPackageAction AddInstallAction ()
+ TestableInstallNuGetPackageAction AddInstallAction ()
{
- var action = new FakeInstallPackageAction (new FakePackageManagementProject (), packageManagementEvents);
- action.Operations = new List <PackageOperation> ();
- action.Logger = new FakeLogger ();
+ var action = new TestableInstallNuGetPackageAction (
+ new FakeSourceRepositoryProvider ().Repositories,
+ new FakeSolutionManager (),
+ new FakeDotNetProject ());
+
+ action.PackageId = "Test";
+
actions.Add (action);
+
return action;
}
- FakeInstallPackageAction AddInstallActionWithPowerShellScript (string packageId = "Test")
+ TestableUpdateNuGetPackageAction AddUpdateAction ()
{
- FakeInstallPackageAction action = AddInstallAction ();
- var package = new FakePackage (packageId);
- package.AddFile (@"tools\install.ps1");
- var operations = new List<PackageOperation> ();
- operations.Add (new PackageOperation (package, PackageAction.Install));
- action.Operations = operations;
- action.Package = package;
+ var action = new TestableUpdateNuGetPackageAction (
+ new FakeSolutionManager (),
+ new FakeDotNetProject ()
+ );
+ action.PackageId = "Test";
+
+ actions.Add (action);
+
return action;
}
- void AddInstallActionWithLicenseToAccept (string packageId = "Test")
+ void AddInstallActionWithMissingPackageId ()
{
- FakeInstallPackageAction action = AddInstallAction ();
- var package = new FakePackage (packageId) {
- RequireLicenseAcceptance = true
- };
- var operations = new List<PackageOperation> ();
- operations.Add (new PackageOperation (package, PackageAction.Install));
- action.Operations = operations;
- action.Package = package;
- action.LicensesMustBeAccepted = false;
+ var action = AddInstallAction ();
+ action.PackageId = null;
+ }
+
+ void AddInstallActionWithCustomExecuteAction (Action executionAction)
+ {
+ var action = AddInstallAction ();
+ action.PackageManager.BeforeExecuteAction = executionAction;
+ var projectAction = new FakeNuGetProjectAction ("Test", "1.2", NuGetProjectActionType.Install);
+ action.PackageManager.InstallActions.Add (projectAction);
}
- void AddInstallActionWithMissingPackageId (string packageId = "Unknown")
+ TestableUninstallNuGetPackageAction AddUninstallAction ()
{
- var action = new InstallPackageAction (new FakePackageManagementProject (), packageManagementEvents);
- action.PackageId = packageId;
+ var action = new TestableUninstallNuGetPackageAction (
+ new FakeSolutionManager (),
+ new FakeDotNetProject ());
+
+ action.PackageId = "Test";
+
actions.Add (action);
+
+ return action;
}
- void AddInstallActionWithCustomExecuteAction (Action executeAction)
+ void AssertInstallCounterIncrementedForPackage (string packageId, string packageVersion)
{
- FakeInstallPackageAction action = AddInstallAction ();
- action.ExecuteAction = executeAction;
+ AssertCounterIncrementedForPackage (instrumentationService.InstallPackageMetadata, packageId, packageVersion);
}
- FakeUninstallPackageAction AddUninstallAction ()
+ static void AssertCounterIncrementedForPackage (
+ IDictionary<string, string> metadata,
+ string packageId,
+ string packageVersion)
{
- var action = new FakeUninstallPackageAction (new FakePackageManagementProject ());
- action.Package = new FakePackage ();
- action.Logger = new FakeLogger ();
- actions.Add (action);
- return action;
+ string fullInfo = packageId + " v" + packageVersion;
+ Assert.AreEqual (packageId, metadata["PackageId"]);
+ Assert.AreEqual (fullInfo, metadata["Package"]);
}
- FakeInstallPackageAction AddInstallActionWithMSBuildTargetsFile (
- string packageId = "Test",
- PackageAction packageAction = PackageAction.Install)
+ void AssertUninstallCounterIncrementedForPackage (string packageId, string packageVersion)
{
- FakeInstallPackageAction action = AddInstallAction ();
- var package = new FakePackage (packageId);
- package.AddFile (@"build\net40\" + packageId + ".targets");
- var operations = new List<PackageOperation> ();
- operations.Add (new PackageOperation (package, packageAction));
- action.Operations = operations;
- action.Package = package;
- return action;
+ AssertCounterIncrementedForPackage (instrumentationService.UninstallPackageMetadata, packageId, packageVersion);
+ }
+
+ void AssertUninstallCounterIncrementedForPackage (string packageId)
+ {
+ Assert.AreEqual (packageId, instrumentationService.UninstallPackageMetadata["PackageId"]);
+ Assert.IsFalse (instrumentationService.UninstallPackageMetadata.ContainsKey ("PackageVersion"));
+ Assert.IsFalse (instrumentationService.UninstallPackageMetadata.ContainsKey ("Package"));
+ }
+
+ void AddInstallPackageIntoProjectAction (FakeNuGetPackageManager packageManager, string packageId, string version)
+ {
+ var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Install);
+ packageManager.InstallActions.Add (projectAction);
+ }
+
+ void AddUninstallPackageIntoProjectAction (FakeNuGetPackageManager packageManager, string packageId, string version)
+ {
+ var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Uninstall);
+ packageManager.InstallActions.Add (projectAction);
}
[Test]
public void Run_OneInstallActionAndOneUninstallActionAndRunNotCompleted_InstallActionMarkedAsPending ()
{
CreateRunner ();
- InstallPackageAction expectedAction = AddInstallAction ();
+ var expectedAction = AddInstallAction ();
AddUninstallAction ();
RunWithoutBackgroundDispatch ();
@@ -162,8 +181,8 @@ namespace MonoDevelop.PackageManagement.Tests public void Run_OneInstallActionAndRunNotCompleted_PackageOperationsStartedEventRaisedAfterInstallActionMarkedAsPending ()
{
CreateRunner ();
- InstallPackageAction expectedAction = AddInstallAction ();
- List<InstallPackageAction> actions = null;
+ var expectedAction = AddInstallAction ();
+ List<IInstallNuGetPackageAction> actions = null;
packageManagementEvents.PackageOperationsStarting += (sender, e) => {
actions = runner.PendingInstallActions.ToList ();
};
@@ -189,7 +208,7 @@ namespace MonoDevelop.PackageManagement.Tests {
CreateRunner ();
AddInstallAction ();
- List<InstallPackageAction> actions = null;
+ List<IInstallNuGetPackageAction> actions = null;
packageManagementEvents.PackageOperationsFinished += (sender, e) => {
actions = runner.PendingInstallActions.ToList ();
};
@@ -237,13 +256,13 @@ namespace MonoDevelop.PackageManagement.Tests public void Run_TwoActions_BothActionsExecuted ()
{
CreateRunner ();
- FakeInstallPackageAction action1 = AddInstallAction ();
- FakeUninstallPackageAction action2 = AddUninstallAction ();
+ var action1 = AddInstallAction ();
+ var action2 = AddUninstallAction ();
Run ();
- Assert.IsTrue (action1.IsExecuteCalled);
- Assert.IsTrue (action2.IsExecuted);
+ Assert.IsNotNull (action1.PackageManager.PreviewInstallProject);
+ Assert.IsNotNull (action2.PackageManager.PreviewUninstallProject);
}
[Test]
@@ -271,54 +290,10 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void Run_OneInstallActionWithPowerShellScripts_WarningNotReportedToProgressMonitor ()
- {
- CreateRunner ();
- AddInstallActionWithPowerShellScript ();
-
- Run ();
-
- Assert.IsNull (progressMonitor.ReportedWarningMessage);
- }
-
- [Test]
- public void Run_OneInstallActionWithPowerShellScripts_WarningMessageLoggedInPackageConsole ()
- {
- CreateRunner ();
- AddInstallActionWithPowerShellScript ("Test");
-
- Run ();
-
- progressMonitor.AssertMessageIsLogged ("WARNING: Test Package contains PowerShell scripts which will not be run.");
- }
-
- [Test]
- public void Run_OneInstallActionWithLicenseToAccept_WarningReportedToProgressMonitor ()
- {
- CreateRunner ();
- AddInstallActionWithLicenseToAccept ();
-
- Run ();
-
- Assert.AreEqual ("Warning", progressMonitor.ReportedWarningMessage);
- }
-
- [Test]
- public void Run_OneInstallActionWithLicenseToAccept_WarningMessageLoggedInPackageConsole ()
- {
- CreateRunner ();
- AddInstallActionWithLicenseToAccept ("Test");
-
- Run ();
-
- progressMonitor.AssertMessageIsLogged ("The Test package has a license agreement");
- }
-
- [Test]
public void Run_OneInstallActionWithMissingPackageId_ErrorReportedToProgressMonitor ()
{
CreateRunner ();
- AddInstallActionWithMissingPackageId ("Unknown");
+ AddInstallActionWithMissingPackageId ();
Run ();
@@ -329,18 +304,18 @@ namespace MonoDevelop.PackageManagement.Tests public void Run_OneInstallActionWithMissingPackageId_ErrorLoggedInPackageConsole ()
{
CreateRunner ();
- AddInstallActionWithMissingPackageId ("Unknown");
+ AddInstallActionWithMissingPackageId ();
Run ();
- progressMonitor.AssertMessageIsLogged ("Unable to find package 'Unknown'.");
+ progressMonitor.AssertMessageIsLogged ("Value cannot be null.");
}
[Test]
public void Run_OneInstallActionWithMissingPackageId_PackageOperationsFinishedEventFired ()
{
CreateRunner ();
- AddInstallActionWithMissingPackageId ("Unknown");
+ AddInstallActionWithMissingPackageId ();
bool eventFired = false;
packageManagementEvents.PackageOperationsFinished += (sender, e) => {
eventFired = true;
@@ -355,22 +330,22 @@ namespace MonoDevelop.PackageManagement.Tests public void Run_OneInstallActionWithMissingPackageId_PackageOperationErrorEventFired ()
{
CreateRunner ();
- AddInstallActionWithMissingPackageId ("Unknown");
+ AddInstallActionWithMissingPackageId ();
string exceptionMessage = null;
packageManagementEvents.PackageOperationError += (sender, e) => {
- exceptionMessage = e.Exception.Message;
+ exceptionMessage = e.Exception.GetBaseException ().Message;
};
Run ();
- Assert.AreEqual ("Unable to find package 'Unknown'.", exceptionMessage);
+ Assert.IsTrue (exceptionMessage.Contains ("Value cannot be null."));
}
[Test]
public void Run_OneInstallActionWithMissingPackageId_PackageConsoleDisplayedDueToError ()
{
CreateRunner ();
- AddInstallActionWithMissingPackageId ("Unknown");
+ AddInstallActionWithMissingPackageId ();
Run ();
@@ -382,7 +357,7 @@ namespace MonoDevelop.PackageManagement.Tests public void Run_OneInstallActionWithMissingPackageId_InstallPackageOperationsRemovedFromPendingListWhenPackageOperationErrorEventFired ()
{
CreateRunner ();
- AddInstallActionWithMissingPackageId ("Unknown");
+ AddInstallActionWithMissingPackageId ();
int pendingInstallActionsCount = -1;
packageManagementEvents.PackageOperationError += (sender, e) => {
pendingInstallActionsCount = runner.PendingInstallActions.Count ();
@@ -426,147 +401,149 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void Run_ActionDownloadsTwoPackages_DownloadingMessageLoggedOnceForEachDownloadOperationByProgressMonitor ()
+ public void IsRunning_NothingRunning_IsRunningIsFalse ()
{
CreateRunner ();
- AddInstallActionWithCustomExecuteAction (() => {
- var repository = new FakePackageRepository ();
- repositoryFactoryEvents.RaiseRepositoryCreatedEvent (new PackageRepositoryFactoryEventArgs (repository));
- var progress = new ProgressEventArgs ("Download1", 100);
- repository.RaiseProgressAvailableEvent (progress);
-
- progress = new ProgressEventArgs ("Download2", 50);
- repository.RaiseProgressAvailableEvent (progress);
+ Assert.IsFalse (runner.IsRunning);
+ }
- progress = new ProgressEventArgs ("Download2", 100);
- repository.RaiseProgressAvailableEvent (progress);
- });
+ [Test]
+ public void IsRunning_OneUninstallActionAndRunNotCompleted_IsRunningIsTrue ()
+ {
+ CreateRunner ();
+ AddUninstallAction ();
- Run ();
+ RunWithoutBackgroundDispatch ();
- progressMonitor.AssertMessageIsLogged ("Download1");
- progressMonitor.AssertMessageIsLogged ("Download2");
- progressMonitor.AssertMessageIsNotLogged ("Download2" + Environment.NewLine + "Download2");
+ Assert.IsTrue (runner.IsRunning);
}
[Test]
- public void Run_OneInstallActionWithPackageOperationWithCustomMSBuildTask_TypeSystemIsRefreshed ()
+ public void IsRunning_OneUninstallActionAndRunCompleted_IsRunningIsFalse ()
{
CreateRunner ();
- FakeInstallPackageAction action = AddInstallActionWithMSBuildTargetsFile ();
- action.ExecuteAction = () => {
- packageManagementEvents.OnParentPackageInstalled (action.Package, action.Project, action.Operations);
- };
+ AddUninstallAction ();
Run ();
- Assert.IsTrue (runner.EventsMonitor.IsTypeSystemRefreshed);
- Assert.AreEqual (action.Project, runner.EventsMonitor.ProjectsPassedToReconnectAssemblyReferences [0]);
- Assert.IsNotNull (action.Project);
+ Assert.IsFalse (runner.IsRunning);
}
[Test]
- public void Run_OneUninstallActionWithPackageOperationWithCustomMSBuildTask_TypeSystemIsNotRefreshed ()
+ public void IsRunning_TwoRunsAndOneCompletes_IsRunningIsTrue ()
{
CreateRunner ();
- FakeInstallPackageAction action = AddInstallActionWithMSBuildTargetsFile ("Test", PackageAction.Uninstall);
- action.ExecuteAction = () => {
- packageManagementEvents.OnParentPackageInstalled (action.Package, action.Project, action.Operations);
- };
+ AddUninstallAction ();
+ RunWithoutBackgroundDispatch ();
+ actions.Clear ();
+ AddInstallAction ();
+ RunWithoutBackgroundDispatch ();
- Run ();
+ runner.ExecuteSingleBackgroundDispatch ();
- Assert.IsFalse (runner.EventsMonitor.IsTypeSystemRefreshed);
+ Assert.IsTrue (runner.IsRunning);
}
[Test]
- public void Run_OneInstallActionNoCustomMSBuildTask_TypeSystemIsNotRefreshed ()
+ public void IsRunning_TwoRunsAndBothComplete_IsRunningIsFalse ()
{
CreateRunner ();
- FakeInstallPackageAction action = AddInstallActionWithPowerShellScript ();
- action.ExecuteAction = () => {
- packageManagementEvents.OnParentPackageInstalled (action.Package, action.Project, action.Operations);
- };
+ AddUninstallAction ();
+ RunWithoutBackgroundDispatch ();
+ actions.Clear ();
+ AddInstallAction ();
+ RunWithoutBackgroundDispatch ();
- Run ();
+ runner.ExecuteSingleBackgroundDispatch ();
+ runner.ExecuteSingleBackgroundDispatch ();
- Assert.IsFalse (runner.EventsMonitor.IsTypeSystemRefreshed);
+ Assert.IsFalse (runner.IsRunning);
}
[Test]
- public void IsRunning_NothingRunning_IsRunningIsFalse ()
+ public void IsRunning_ExceptionThrownRunningBackgroundDispatcher_IsRunningIsFalse ()
{
CreateRunner ();
+ AddUninstallAction ();
+ runner.CreateEventMonitorAction = (monitor, packageManagementEvents) => {
+ throw new ApplicationException ("Error");
+ };
+
+ Run ();
Assert.IsFalse (runner.IsRunning);
}
[Test]
- public void IsRunning_OneUninstallActionAndRunNotCompleted_IsRunningIsTrue ()
+ public void Instrumentation_OnePackageUninstalled_UninstallCounterIncremented ()
{
CreateRunner ();
- AddUninstallAction ();
+ var action = AddUninstallAction ();
+ var projectAction = new FakeNuGetProjectAction ("Test", "1.2", NuGetProjectActionType.Uninstall);
+ action.PackageManager.UninstallActions.Add (projectAction);
- RunWithoutBackgroundDispatch ();
+ Run ();
- Assert.IsTrue (runner.IsRunning);
+ AssertUninstallCounterIncrementedForPackage ("Test", "1.2");
}
[Test]
- public void IsRunning_OneUninstallActionAndRunCompleted_IsRunningIsFalse ()
+ public void Instrumentation_OnePackageUninstalledWithNoVersion_UninstallCounterIncremented ()
{
CreateRunner ();
- AddUninstallAction ();
+ var action = AddUninstallAction ();
+ var projectAction = new FakeNuGetProjectAction ("Test", null, NuGetProjectActionType.Uninstall);
+ action.PackageManager.UninstallActions.Add (projectAction);
Run ();
- Assert.IsFalse (runner.IsRunning);
+ AssertUninstallCounterIncrementedForPackage ("Test");
}
[Test]
- public void IsRunning_TwoRunsAndOneCompletes_IsRunningIsTrue ()
+ public void Instrumentation_OnePackageInstalledWithTwoPackageOperations_UninstallCounterIncremented ()
{
CreateRunner ();
- AddUninstallAction ();
- RunWithoutBackgroundDispatch ();
- actions.Clear ();
- AddInstallAction ();
- RunWithoutBackgroundDispatch ();
+ var action = AddInstallAction ();
+ AddInstallPackageIntoProjectAction (action.PackageManager, "Bar", "1.3");
+ AddUninstallPackageIntoProjectAction (action.PackageManager, "Foo", "1.1");
- runner.ExecuteSingleBackgroundDispatch ();
+ Run ();
- Assert.IsTrue (runner.IsRunning);
+ AssertUninstallCounterIncrementedForPackage ("Foo", "1.1");
+ AssertInstallCounterIncrementedForPackage ("Bar", "1.3");
}
[Test]
- public void IsRunning_TwoRunsAndBothComplete_IsRunningIsFalse ()
+ public void Instrumentation_OnePackageUpdatedWithTwoPackageOperations_UninstallCounterIncremented ()
{
CreateRunner ();
- AddUninstallAction ();
- RunWithoutBackgroundDispatch ();
- actions.Clear ();
- AddInstallAction ();
- RunWithoutBackgroundDispatch ();
+ var action = AddUpdateAction ();
+ var projectAction = new FakeNuGetProjectAction ("Bar", "1.3", NuGetProjectActionType.Install);
+ action.PackageManager.UpdateActions.Add (projectAction);
+ projectAction = new FakeNuGetProjectAction ("Foo", "1.1", NuGetProjectActionType.Uninstall);
+ action.PackageManager.UpdateActions.Add (projectAction);
- runner.ExecuteSingleBackgroundDispatch ();
- runner.ExecuteSingleBackgroundDispatch ();
+ Run ();
- Assert.IsFalse (runner.IsRunning);
+ AssertUninstallCounterIncrementedForPackage ("Foo", "1.1");
+ AssertInstallCounterIncrementedForPackage ("Bar", "1.3");
}
[Test]
- public void IsRunning_ExceptionThrownRunningBackgroundDispatcher_IsRunningIsFalse ()
+ public void Instrumentation_OnePackageInstalledWithOneInstallAndOneUninstallPackageActions_BothCountersIncremented ()
{
CreateRunner ();
- AddUninstallAction ();
- runner.CreateEventMonitorAction = (monitor, packageManagementEvents, progressProvider) => {
- throw new ApplicationException ("Error");
- };
+ var action = AddInstallAction ();
+ AddInstallPackageIntoProjectAction (action.PackageManager, "Bar", "1.3");
+ AddUninstallPackageIntoProjectAction (action.PackageManager, "Foo", "1.1");
+ actions.Add (action);
Run ();
- Assert.IsFalse (runner.IsRunning);
+ AssertUninstallCounterIncrementedForPackage ("Foo", "1.1");
+ AssertInstallCounterIncrementedForPackage ("Bar", "1.3");
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/DotNetProjectExtensionsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/DotNetProjectExtensionsTests.cs index 338491bd76..c92c7b099b 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/DotNetProjectExtensionsTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/DotNetProjectExtensionsTests.cs @@ -130,6 +130,38 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsTrue (result);
}
+
+ [Test]
+ public void HasPackagesConfig_PackagesConfigFileDoesNotExist_ReturnsFalse ()
+ {
+ CreateProject (@"d:\projects\MyProject.csproj", "MyProject");
+
+ bool result = project.HasPackagesConfig ();
+
+ Assert.IsFalse (result);
+ }
+
+ [Test]
+ public void HasPackagesConfig_PackagesConfigFileExistsInProjectDirectory_ReturnsTrue ()
+ {
+ CreateProject (@"d:\projects\MyProject.csproj", "MyProject");
+ AddExistingFile (@"d:\projects\packages.config");
+
+ bool result = project.HasPackagesConfig ();
+
+ Assert.IsTrue (result);
+ }
+
+ [Test]
+ public void HasPackages_PackagesJsonFileExistsInProjectDirectory_ReturnsTrue ()
+ {
+ CreateProject (@"d:\projects\MyProject.csproj", "MyProject");
+ AddExistingFile (@"d:\projects\project.json");
+
+ bool result = project.HasPackages ();
+
+ Assert.IsTrue (result);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/EnsureNuGetPackageBuildImportsTargetUpdaterTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/EnsureNuGetPackageBuildImportsTargetUpdaterTests.cs index 10d81693ac..76db78e22c 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/EnsureNuGetPackageBuildImportsTargetUpdaterTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/EnsureNuGetPackageBuildImportsTargetUpdaterTests.cs @@ -77,7 +77,6 @@ namespace MonoDevelop.PackageManagement.Tests SaveProject ();
- MSBuildTarget target = msbuildProject.Targets.FirstOrDefault ();
Assert.AreEqual (1, targetCountBeforeSave);
Assert.AreEqual (0, msbuildProject.Targets.Count ());
}
@@ -100,7 +99,6 @@ namespace MonoDevelop.PackageManagement.Tests SaveProject ();
- MSBuildTarget target = msbuildProject.Targets.FirstOrDefault ();
Assert.AreEqual (1, targetCountBeforeSave);
Assert.AreEqual (0, msbuildProject.Targets.Count ());
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/FakePackageFeed.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/FakePackageFeed.cs new file mode 100644 index 0000000000..1fd176a313 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/FakePackageFeed.cs @@ -0,0 +1,94 @@ +// +// FakePackageFeed.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.PackageManagement.UI; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement.Tests +{ + class FakePackageFeed : IPackageFeed + { + public bool IsMultiSource { + get { return true; } + } + + public List<PackageIdentity> Packages = new List<PackageIdentity> (); + + public void AddPackage (string id, string version) + { + var package = new PackageIdentity (id, new NuGetVersion (version)); + Packages.Add (package); + } + + public string SearchText; + public SearchFilter SearchFilter; + + public Task<SearchResult<IPackageSearchMetadata>> SearchAsync (string searchText, SearchFilter filter, CancellationToken cancellationToken) + { + var results = new SearchResult<IPackageSearchMetadata> { + RefreshToken = new RefreshToken { }, + SourceSearchStatus = new Dictionary<string, LoadingStatus> { + { "Test", LoadingStatus.Loading } + } + }; + + SearchText = searchText; + SearchFilter = filter; + + return Task.FromResult (results); + } + + public Task<SearchResult<IPackageSearchMetadata>> RefreshSearchAsync (RefreshToken refreshToken, CancellationToken cancellationToken) + { + var items = Packages + .Select (package => PackageSearchMetadataBuilder.FromIdentity (package).Build ()) + .ToArray (); + + var results = SearchResult.FromItems (items); + results.NextToken = new ContinuationToken { }; + results.SourceSearchStatus = new Dictionary<string, LoadingStatus> { + { "Test", LoadingStatus.Ready } + }; + return Task.FromResult (results); + } + + public Task<SearchResult<IPackageSearchMetadata>> ContinueSearchAsync (ContinuationToken continuationToken, CancellationToken cancellationToken) + { + var results = new SearchResult<IPackageSearchMetadata> (); + results.SourceSearchStatus = new Dictionary<string, LoadingStatus> { + { "Test", LoadingStatus.NoMoreItems } + }; + return Task.FromResult (results); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/IPackageExtensionsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/IPackageExtensionsTests.cs deleted file mode 100644 index 385c39fd42..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/IPackageExtensionsTests.cs +++ /dev/null @@ -1,114 +0,0 @@ -//
-// IPackageExtensionsTests.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 MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class IPackageExtensionsTests
- {
- FakePackage package;
-
- void CreatePackageWithSummary (string summary)
- {
- package = new FakePackage { Summary = summary };
- }
-
- void CreatePackageWithTitle (string title)
- {
- package = new FakePackage { Title = title };
- }
-
- [Test]
- public void SummaryOrDescription_PackageHasSummary_ReturnsSummary ()
- {
- CreatePackageWithSummary ("summary");
-
- string result = package.SummaryOrDescription ();
-
- Assert.AreEqual ("summary", result);
- }
-
- [Test]
- public void SummaryOrDescription_PackageHasDescriptionButNullSummary_ReturnsDescription ()
- {
- CreatePackageWithSummary (null);
- package.Description = "description";
-
- string result = package.SummaryOrDescription ();
-
- Assert.AreEqual ("description", result);
- }
-
- [Test]
- public void SummaryOrDescription_PackageHasDescriptionButEmptySummary_ReturnsDescription ()
- {
- CreatePackageWithSummary (String.Empty);
- package.Description = "description";
-
- string result = package.SummaryOrDescription ();
-
- Assert.AreEqual ("description", result);
- }
-
- [Test]
- public void GetName_PackageHasTitle_ReturnsTitle ()
- {
- CreatePackageWithTitle ("title");
-
- string result = package.GetName ();
-
- Assert.AreEqual ("title", result);
- }
-
- [Test]
- public void GetName_PackageHasNullTitle_ReturnsPackageId ()
- {
- CreatePackageWithTitle (null);
- package.Id = "Id";
-
- string result = package.GetName ();
-
- Assert.AreEqual ("Id", result);
- }
-
- [Test]
- public void GetName_PackageHasEmptyStringTitle_ReturnsPackageId ()
- {
- CreatePackageWithTitle (String.Empty);
- package.Id = "Id";
-
- string result = package.GetName ();
-
- Assert.AreEqual ("Id", result);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallNuGetPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallNuGetPackageActionTests.cs new file mode 100644 index 0000000000..0904a682fd --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallNuGetPackageActionTests.cs @@ -0,0 +1,424 @@ +// +// InstallNuGetPackageActionTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using MonoDevelop.PackageManagement.Tests.Helpers; +using MonoDevelop.Projects; +using NuGet.Configuration; +using NuGet.PackageManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Resolver; +using NuGet.Versioning; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class InstallNuGetPackageActionTests + { + TestableInstallNuGetPackageAction action; + FakeSolutionManager solutionManager; + FakeDotNetProject project; + FakeNuGetProject nugetProject; + List<SourceRepository> primaryRepositories; + FakeNuGetPackageManager packageManager; + FakePackageMetadataResource packageMetadataResource; + IPackageManagementEvents packageManagementEvents; + FakeFileRemover fileRemover; + + void CreateAction ( + string packageId = "Test", + string version = "2.1") + { + project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj"); + solutionManager = new FakeSolutionManager (); + nugetProject = new FakeNuGetProject (project); + solutionManager.NuGetProjects[project] = nugetProject; + + var metadataResourceProvider = new FakePackageMetadataResourceProvider (); + packageMetadataResource = metadataResourceProvider.PackageMetadataResource; + var source = new PackageSource ("http://test.com"); + var providers = new INuGetResourceProvider[] { + metadataResourceProvider + }; + var sourceRepository = new SourceRepository (source, providers); + primaryRepositories = new [] { + sourceRepository + }.ToList (); + + action = new TestableInstallNuGetPackageAction ( + primaryRepositories, + solutionManager, + project); + + packageManager = action.PackageManager; + packageManagementEvents = action.PackageManagementEvents; + fileRemover = action.FileRemover; + + action.PackageId = packageId; + action.Version = new NuGetVersion (version); + } + + void AddInstallPackageIntoProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Install); + packageManager.InstallActions.Add (projectAction); + } + + [Test] + public void Execute_PackageIdAndVersionIsSet_ActionsResolvedFromNuGetPackageManager () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + + action.Execute (); + + Assert.AreEqual (primaryRepositories, packageManager.PreviewInstallPrimarySources); + Assert.IsNull (packageManager.PreviewInstallSecondarySources); + Assert.AreEqual (nugetProject, packageManager.PreviewInstallProject); + Assert.AreEqual ("Test", packageManager.PreviewInstallPackageIdentity.Id); + Assert.AreEqual ("1.2", packageManager.PreviewInstallPackageIdentity.Version.ToString ()); + Assert.IsFalse (packageManager.PreviewInstallResolutionContext.IncludePrerelease); + Assert.AreEqual (VersionConstraints.None, packageManager.PreviewInstallResolutionContext.VersionConstraints); + Assert.IsTrue (packageManager.PreviewInstallResolutionContext.IncludeUnlisted); + Assert.AreEqual (DependencyBehavior.Lowest, packageManager.PreviewInstallResolutionContext.DependencyBehavior); + } + + [Test] + public void Execute_PackageIdAndVersionIsSet_ActionsAvailableForInstrumentation () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (action.GetNuGetProjectActions(), packageManager.InstallActions); + } + + [Test] + public void Execute_PackageIdAndVersionIsSet_DirectInstallSetAndCleared () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + + action.Execute (); + + Assert.AreEqual ("Test", packageManager.SetDirectInstallPackageIdentity.Id); + Assert.AreEqual ("1.2", packageManager.SetDirectInstallPackageIdentity.Version.ToString ()); + Assert.AreEqual (action.ProjectContext, packageManager.SetDirectInstallProjectContext); + Assert.AreSame (action.ProjectContext, packageManager.ClearDirectInstallProjectContext); + } + + [Test] + public void Execute_PackageIdAndVersionIsSet_InstallsPackageUsingResolvedActions () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddInstallPackageIntoProjectAction ("A", "2.1"); + + action.Execute (); + + Assert.AreEqual (packageManager.InstallActions, packageManager.ExecutedActions); + Assert.AreEqual (nugetProject, packageManager.ExecutedNuGetProject); + Assert.AreEqual (action.ProjectContext, packageManager.ExecutedProjectContext); + } + + [Test] + public void Execute_NoVersionIsSet_LatestVersionUsedWhenResolvingInstallActions () + { + CreateAction (); + action.PackageId = "Test"; + action.Version = null; + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + packageManager.LatestVersion = new NuGetVersion ("1.2.3.4"); + + action.Execute (); + + Assert.AreEqual ("Test", packageManager.PreviewInstallPackageIdentity.Id); + Assert.AreEqual ("1.2.3.4", packageManager.PreviewInstallPackageIdentity.Version.ToString ()); + Assert.AreEqual (nugetProject, packageManager.GetLatestVersionProject); + Assert.AreEqual ("Test", packageManager.GetLatestVersionPackageId); + Assert.AreEqual (primaryRepositories, packageManager.GetLatestVersionSources); + Assert.AreEqual (DependencyBehavior.Lowest, packageManager.GetLatestVersionResolutionContext.DependencyBehavior); + Assert.IsFalse (packageManager.GetLatestVersionResolutionContext.IncludePrerelease); + Assert.IsFalse (packageManager.GetLatestVersionResolutionContext.IncludeUnlisted); + Assert.AreEqual (VersionConstraints.None, packageManager.GetLatestVersionResolutionContext.VersionConstraints); + } + + [Test] + public void Execute_PackageIsSetAndAllowPrereleaseVersionsIsTrue_InstallsPackageAllowingPrereleaseVersions () + { + CreateAction (); + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + action.IncludePrerelease = true; + + action.Execute (); + + Assert.IsTrue (packageManager.PreviewInstallResolutionContext.IncludePrerelease); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_OnAfterExecuteActionsIsCalled () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (packageManager.InstallActions, nugetProject.ActionsPassedToOnAfterExecuteActions); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_PostProcessingIsRun () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.PreserveLocalCopyReferences = false; + + action.Execute (); + + Assert.AreEqual (action.ProjectContext, nugetProject.PostProcessProjectContext); + } + + [Test] + public void LicensesMustBeAccepted_NewAction_IsTrueByDefault () + { + CreateAction (); + + Assert.IsTrue (action.LicensesMustBeAccepted); + } + + [Test] + public void PreserveLocalCopyReferencesd_NewAction_IsTrueByDefault () + { + CreateAction (); + + Assert.IsTrue (action.PreserveLocalCopyReferences); + } + + [Test] + public void Execute_PackageHasALicenseToBeAcceptedWhichIsAccepted_UserPromptedToAcceptLicenses () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = true; + action.LicenseAcceptanceService.AcceptLicensesReturnValue = true; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + + action.Execute (); + + var license = action.LicenseAcceptanceService.PackageLicensesAccepted.Single (); + Assert.AreEqual ("Test", license.PackageId); + Assert.AreEqual (metadata.LicenseUrl, license.LicenseUrl); + Assert.AreEqual (metadata.Authors, license.PackageAuthor); + Assert.AreEqual (metadata.Title, license.PackageTitle); + Assert.AreEqual ("Test", license.PackageIdentity.Id); + Assert.AreEqual ("1.2", license.PackageIdentity.Version.ToString ()); + } + + [Test] + public void Execute_LicensesMustBeAcceptedIsFalseAndPackageHasALicenseToBeAccepted_UserNotPromptedToAcceptLicenses () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.LicenseAcceptanceService.AcceptLicensesReturnValue = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + action.LicenseAcceptanceService.PackageLicensesAccepted = null; + + action.Execute (); + + Assert.IsNull (action.LicenseAcceptanceService.PackageLicensesAccepted); + } + + [Test] + public void Execute_PackageHasALicenseToBeAcceptedWhichIsNotAccepted_ExceptionThrown () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = true; + action.LicenseAcceptanceService.AcceptLicensesReturnValue = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + + Exception ex = Assert.Throws (typeof(AggregateException), () => action.Execute ()); + + Assert.AreEqual ("Licenses not accepted.", ex.GetBaseException ().Message); + } + + [Test] + public void Execute_LicensesMustBeAcceptedButPackageAlreadyInstalled_UserNotPromptedToAcceptLicenses () + { + CreateAction ("Test", "1.2"); + action.LicensesMustBeAccepted = false; + action.LicenseAcceptanceService.AcceptLicensesReturnValue = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + action.LicenseAcceptanceService.PackageLicensesAccepted = null; + packageManager.AddPackageToPackagesFolder ("Test", "1.2"); + + action.Execute (); + + Assert.IsNull (action.LicenseAcceptanceService.PackageLicensesAccepted); + } + + [Test] + public void Execute_PackageAlreadyExistsWhenInstallingItAgainAndReferenceBeingInstalledOriginallyHadLocalCopyFalse_ReferenceAddedHasLocalCopyFalse () + { + CreateAction (); + action.PreserveLocalCopyReferences = true; + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); + Assert.IsTrue (action.PreserveLocalCopyReferences); + } + + [Test] + public void Execute_PreserveLocalCopyReferencesSetToFalse_ReferenceThatOriginallyHadLocalCopyFalseIsAddedHasLocalCopySetToTrue () + { + CreateAction (); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + action.PreserveLocalCopyReferences = false; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsTrue (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_PackagesConfigFileDeletedDuringInstall_FileServicePackagesConfigFileDeletionIsCancelled () + { + CreateAction (); + string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName); + }; + + action.Execute (); + + Assert.AreEqual (expectedFileName, fileRemover.FileRemoved); + Assert.IsFalse (fileRemovedResult.Value); + } + + [Test] + public void Execute_ScriptFileDeletedDuringInstallFileDeletionIsNotCancelled () + { + CreateAction (); + string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName); + }; + + action.Execute (); + + Assert.IsTrue (fileRemovedResult.Value); + Assert.IsNull (fileRemover.FileRemoved); + } + + [Test] + public void Execute_OpenReadmeFileIsFalse_DirectInstallIsNotSetWhichPreventsReadmeFileBeingOpened () + { + CreateAction ("Test", "1.2"); + action.OpenReadmeFile = false; + + action.Execute (); + + Assert.IsNull (packageManager.SetDirectInstallPackageIdentity); + } + + [Test] + public void OpenReadmeFile_NewAction_IsTrueByDefault () + { + CreateAction ("Test", "1.2"); + + Assert.IsTrue (action.OpenReadmeFile); + } + + [Test] + public void Execute_OpenReadmeFileIsTrueAndPackageIsAlreadyInstalledInSolution_DirectInstallIsNotSetWhichPreventsReadmeFileBeingOpened () + { + CreateAction ("Test", "1.2"); + packageManager.AddPackageToPackagesFolder ("Test", "1.2"); + action.OpenReadmeFile = true; + + action.Execute (); + + Assert.IsNull (packageManager.SetDirectInstallPackageIdentity); + } + + [Test] + public void Execute_OpenReadmeFileIsTrueAndPackageIsNotAlreadyInstalledInSolution_DirectInstallIsSetWhichAllowsReadmeFileToBeOpened () + { + CreateAction ("Test", "1.2"); + action.OpenReadmeFile = true; + + action.Execute (); + + Assert.AreEqual ("Test", packageManager.SetDirectInstallPackageIdentity.Id); + Assert.AreEqual ("1.2", packageManager.SetDirectInstallPackageIdentity.Version.ToString ()); + } + } +} + 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 deleted file mode 100644 index bd6a95bf4e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/InstallPackageActionTests.cs +++ /dev/null @@ -1,733 +0,0 @@ -//
-// InstallPackageActionTests.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 System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class InstallPackageActionTests
- {
- PackageManagementEvents packageManagementEvents;
- FakePackageManagementProject fakeProject;
- TestableInstallPackageAction action;
- InstallPackageHelper installPackageHelper;
- FakeFileService fileService;
- FakeFileRemover fileRemover;
-
- void CreateAction ()
- {
- packageManagementEvents = new PackageManagementEvents ();
- fakeProject = new FakePackageManagementProject ();
- fileRemover = new FakeFileRemover ();
- action = new TestableInstallPackageAction (fakeProject, packageManagementEvents, fileRemover);
- installPackageHelper = new InstallPackageHelper (action);
- }
-
- FakePackage AddOnePackageToProjectSourceRepository (string packageId)
- {
- return fakeProject.FakeSourceRepository.AddFakePackage (packageId);
- }
-
- void AddInstallOperationWithFile (string fileName)
- {
- action.Operations =
- PackageOperationHelper.CreateListWithOneInstallOperationWithFile (fileName);
- }
-
- IOpenPackageReadMeMonitor CreateReadMeMonitor (string packageId)
- {
- fileService = new FakeFileService (fakeProject.FakeDotNetProject);
- return new OpenPackageReadMeMonitor (packageId, fakeProject, fileService);
- }
-
- [Test]
- public void Execute_PackageIsSet_InstallsPackageIntoProject ()
- {
- CreateAction ();
- installPackageHelper.InstallTestPackage ();
-
- var actualPackage = fakeProject.PackagePassedToInstallPackage;
- var expectedPackage = installPackageHelper.TestPackage;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackageIsSet_InstallsPackageUsingPackageOperations ()
- {
- CreateAction ();
- var expectedOperations = new List<PackageOperation> ();
- installPackageHelper.PackageOperations = expectedOperations;
- installPackageHelper.InstallTestPackage ();
-
- var actualOperations = fakeProject.PackageOperationsPassedToInstallPackage;
-
- Assert.AreEqual (expectedOperations, actualOperations);
- }
-
- [Test]
- public void Execute_PackageIsSet_InstallsPackageNotIgnoringDependencies ()
- {
- CreateAction ();
- installPackageHelper.IgnoreDependencies = false;
- installPackageHelper.InstallTestPackage ();
-
- bool ignored = fakeProject.IgnoreDependenciesPassedToInstallPackage;
-
- Assert.IsFalse (ignored);
- }
-
- [Test]
- public void Execute_PackageIsSetAndIgnoreDependenciesIsTrue_InstallsPackageIgnoringDependencies ()
- {
- CreateAction ();
- installPackageHelper.IgnoreDependencies = true;
- installPackageHelper.InstallTestPackage ();
-
- bool ignored = fakeProject.IgnoreDependenciesPassedToInstallPackage;
-
- Assert.IsTrue (ignored);
- }
-
- [Test]
- public void Execute_PackageIsSetAndAllowPrereleaseVersionsIsTrue_InstallsPackageAllowingPrereleaseVersions ()
- {
- CreateAction ();
- installPackageHelper.AllowPrereleaseVersions = true;
- installPackageHelper.InstallTestPackage ();
-
- bool allowed = fakeProject.AllowPrereleaseVersionsPassedToInstallPackage;
-
- Assert.IsTrue (allowed);
- }
-
- [Test]
- public void Execute_PackageIsSetAndAllowPrereleaseVersionsIsFalse_InstallsPackageWithoutAllowingPrereleaseVersions ()
- {
- CreateAction ();
- installPackageHelper.AllowPrereleaseVersions = false;
- installPackageHelper.InstallTestPackage ();
-
- bool allowed = fakeProject.AllowPrereleaseVersionsPassedToInstallPackage;
-
- Assert.IsFalse (allowed);
- }
-
- [Test]
- public void IgnoreDependencies_DefaultValue_IsFalse ()
- {
- CreateAction ();
- Assert.IsFalse (action.IgnoreDependencies);
- }
-
- [Test]
- public void AllowPrereleaseVersion_DefaultValue_IsFalse ()
- {
- CreateAction ();
- Assert.IsFalse (action.AllowPrereleaseVersions);
- }
-
- [Test]
- public void Execute_PackageAndPackageRepositoryPassed_PackageInstallNotificationRaisedWithInstalledPackage ()
- {
- CreateAction ();
- IPackage actualPackage = null;
- packageManagementEvents.ParentPackageInstalled += (sender, e) => actualPackage = e.Package;
- installPackageHelper.InstallTestPackage ();
-
- IPackage expectedPackage = installPackageHelper.TestPackage;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackageIdAndSourceAndProjectPassed_PackageOperationsRetrievedFromProject ()
- {
- CreateAction ();
- fakeProject.AddFakeInstallOperation ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- installPackageHelper.InstallPackageById ("PackageId");
-
- var actualOperations = action.Operations;
- var expectedOperations = fakeProject.FakeInstallOperations;
-
- Assert.AreEqual (expectedOperations, actualOperations);
- }
-
- [Test]
- public void Execute_PackageSpecifiedButNoPackageOperations_PackageUsedWhenPackageOperationsRetrievedForProject ()
- {
- CreateAction ();
- installPackageHelper.PackageOperations = null;
- installPackageHelper.InstallTestPackage ();
-
- var expectedPackage = installPackageHelper.TestPackage;
-
- var actualPackage = fakeProject.PackagePassedToGetInstallPackageOperations;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackageIdAndSourceAndProjectPassedAndIgnoreDependenciesIsTrue_DependenciesIgnoredWhenGettingPackageOperations ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- installPackageHelper.IgnoreDependencies = true;
- installPackageHelper.InstallPackageById ("PackageId");
-
- bool result = fakeProject.IgnoreDependenciesPassedToGetInstallPackageOperations;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Execute_PackageIdAndSourceAndProjectPassedAndAllowPrereleaseVersionsIsTrue_PrereleaseVersionsAllowedWhenGettingPackageOperations ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- installPackageHelper.AllowPrereleaseVersions = true;
- installPackageHelper.InstallPackageById ("PackageId");
-
- bool result = fakeProject.AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void InstallPackage_PackageIdAndSourceAndProjectPassedAndIgnoreDependenciesIsFalse_DependenciesNotIgnoredWhenGettingPackageOperations ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- installPackageHelper.IgnoreDependencies = false;
- installPackageHelper.InstallPackageById ("PackageId");
-
- bool result = fakeProject.IgnoreDependenciesPassedToGetInstallPackageOperations;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_PackageIdAndSourceAndProjectPassedAndAllowPrereleaseVersionsIsFalse_PrereleaseVersionsNotAllowedWhenGettingPackageOperations ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- installPackageHelper.AllowPrereleaseVersions = false;
- installPackageHelper.InstallPackageById ("PackageId");
-
- bool result = fakeProject.AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_VersionSpecified_VersionUsedWhenSearchingForPackage ()
- {
- CreateAction ();
-
- var recentPackage = AddOnePackageToProjectSourceRepository ("PackageId");
- recentPackage.Version = new SemanticVersion ("1.2.0");
-
- var oldPackage = AddOnePackageToProjectSourceRepository ("PackageId");
- oldPackage.Version = new SemanticVersion ("1.0.0");
-
- var package = AddOnePackageToProjectSourceRepository ("PackageId");
- var version = new SemanticVersion ("1.1.0");
- package.Version = version;
-
- installPackageHelper.Version = version;
- installPackageHelper.InstallPackageById ("PackageId");
-
- var actualPackage = fakeProject.PackagePassedToInstallPackage;
-
- Assert.AreEqual (package, actualPackage);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasInitPowerShellScript_ReturnsTrue ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- AddInstallOperationWithFile (@"tools\init.ps1".ToNativePath ());
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasNoFiles_ReturnsFalse ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- action.Operations = new List<PackageOperation> ();
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsFalse (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasInitPowerShellScriptInUpperCase_ReturnsTrue ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- AddInstallOperationWithFile (@"tools\INIT.PS1".ToNativePath ());
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasInstallPowerShellScriptInUpperCase_ReturnsTrue ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- AddInstallOperationWithFile (@"tools\INSTALL.PS1".ToNativePath ());
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasUninstallPowerShellScriptInUpperCase_ReturnsTrue ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- AddInstallOperationWithFile (@"tools\UNINSTALL.PS1".ToNativePath ());
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_ProjectHasOnePackageOperation_DoesNotThrowNullReferenceException ()
- {
- CreateAction ();
- FakePackage package = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- var operation = new FakePackageOperation (package, PackageAction.Install);
- action.PackageId = package.Id;
- action.PackageVersion = package.Version;
- fakeProject.FakeInstallOperations.Add (operation);
-
- Assert.DoesNotThrow (() => action.HasPackageScriptsToRun ());
- }
-
- [Test]
- public void HasPackageScriptsToRun_ProjectHasOnePackageOperation_PackageLocated ()
- {
- CreateAction ();
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
-
- action.HasPackageScriptsToRun ();
-
- IPackage actualPackage = action.Package;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_InstallPrereleasePackageAndAllowPreleasePackagesIsFalse_DoesNotFindPreleasePackage ()
- {
- CreateAction ();
- fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Prerelease", "1.0-beta");
- action.PackageId = "Prerelease";
- action.AllowPrereleaseVersions = false;
-
- Exception ex = Assert.Throws (typeof(ApplicationException), () => action.Execute ());
-
- Assert.AreEqual ("Unable to find package 'Prerelease'.", ex.Message);
- }
-
- [Test]
- public void Execute_InstallPrereleasePackageAndAllowPreleasePackagesIsTrue_InstallsPackageIntoProject ()
- {
- CreateAction ();
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Prerelease", "1.0-beta");
- action.PackageId = "Prerelease";
- action.AllowPrereleaseVersions = true;
-
- action.Execute ();
-
- IPackage actualPackage = fakeProject.PackagePassedToInstallPackage;
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_InstallUnlistedPackageWithoutVersion_DoesNotInstallPackageIntoProject ()
- {
- CreateAction ();
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("test", "1.0");
- expectedPackage.Listed = false;
- action.PackageId = "test";
-
- Exception ex = Assert.Throws (typeof(ApplicationException), () => action.Execute ());
-
- Assert.AreEqual ("Unable to find package 'test'.", ex.Message);
- }
-
- [Test]
- public void Execute_PackageIdSpecifiedButDoesNotExistInRepository_ExceptionThrown ()
- {
- CreateAction ();
- action.PackageId = "UnknownId";
-
- Exception ex = Assert.Throws (typeof(ApplicationException), () => action.Execute ());
-
- Assert.AreEqual ("Unable to find package 'UnknownId'.", ex.Message);
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAcceptedAndLicensesMustBeAcceptedIsFalse_AcceptLicensesEventRaised ()
- {
- CreateAction ();
- action.LicensesMustBeAccepted = false;
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- expectedPackage.RequireLicenseAcceptance = true;
- var expectedPackages = new IPackage [] { expectedPackage };
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
- List<IPackage> actualPackages = null;
- packageManagementEvents.AcceptLicenses += (sender, e) => {
- e.IsAccepted = true;
- actualPackages = e.Packages.ToList ();
- };
-
- action.Execute ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, actualPackages);
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAcceptedButPackageInstalledAlreadyAndLicensesMustBeAcceptedIsFalse_NoAcceptLicensesEventIsRaised ()
- {
- CreateAction ();
- action.LicensesMustBeAccepted = false;
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- expectedPackage.RequireLicenseAcceptance = true;
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
- fakeProject.FakePackages.Add (expectedPackage);
- bool acceptLicensesEventRaised = false;
- packageManagementEvents.AcceptLicenses += (sender, e) => {
- acceptLicensesEventRaised = true;
- };
-
- action.Execute ();
-
- Assert.IsFalse (acceptLicensesEventRaised);
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAcceptedAndLicensesNotAcceptedAndLicensesMustBeAcceptedIsFalse_ExceptionThrown ()
- {
- CreateAction ();
- action.LicensesMustBeAccepted = false;
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- expectedPackage.RequireLicenseAcceptance = true;
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
- packageManagementEvents.AcceptLicenses += (sender, e) => {
- e.IsAccepted = false;
- };
-
- Exception ex = Assert.Throws (typeof(ApplicationException), () => action.Execute ());
-
- Assert.AreEqual ("Licenses not accepted.", ex.Message);
- }
-
- [Test]
- public void Execute_PackageBeingInstalledHasPowerShellScripts_MessageAboutPowerShellScriptsIsLogged ()
- {
- CreateAction ();
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- expectedPackage.AddFile (@"tools\init.ps1");
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
- var messagesLogged = new List<string> ();
- packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
- if (e.Message.Level == MessageLevel.Info) {
- messagesLogged.Add (e.Message.ToString ());
- }
- };
-
- action.Execute ();
-
- Assert.That (messagesLogged, Contains.Item ("WARNING: Test Package contains PowerShell scripts which will not be run."));
- }
-
- [Test]
- public void Execute_PackageAndPackageRepositoryPassed_PackageInstallNotificationRaisedWithProject ()
- {
- CreateAction ();
- IPackageManagementProject project = null;
- packageManagementEvents.ParentPackageInstalled += (sender, e) => project = e.Project;
-
- installPackageHelper.InstallTestPackage ();
-
- Assert.AreEqual (fakeProject, project);
- }
-
- [Test]
- public void Execute_InstallHasPackageOperations_PackageInstallNotificationRaisedWithPackageOperations ()
- {
- CreateAction ();
- installPackageHelper.AddPackageInstallOperation ();
- IEnumerable<PackageOperation> actualOperations = null;
- packageManagementEvents.ParentPackageInstalled += (sender, e) => actualOperations = e.Operations;
-
- installPackageHelper.InstallTestPackage ();
-
- CollectionAssert.AreEqual (action.Operations, actualOperations);
- }
-
- [Test]
- public void Execute_PackageAlreadyExistsWhenInstallingItAgainAndReferenceBeingInstalledOriginallyHadLocalCopyFalse_ReferenceAddedHasLocalCopyFalse ()
- {
- CreateAction ();
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Package = new FakePackage ("Test", "1.1");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- fakeProject.InstallPackageAction = (p, a) => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- referenceBeingRemoved.LocalCopy = false;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsFalse (secondReferenceBeingAdded.LocalCopy);
- Assert.IsTrue (action.PreserveLocalCopyReferences);
- }
-
- [Test]
- public void Execute_PreserveLocalCopyReferencesSetToFalse_ReferenceThatOriginallyHadLocalCopyFalseIsAddedHasLocalCopySetToTrue ()
- {
- CreateAction ();
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Package = new FakePackage ("Test", "1.1");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- fakeProject.InstallPackageAction = (p, a) => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- referenceBeingRemoved.LocalCopy = false;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.PreserveLocalCopyReferences = false;
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsTrue (secondReferenceBeingAdded.LocalCopy);
- }
-
- [Test]
- public void Execute_PackageInstalledSuccessfully_OpenPackageReadmeMonitorCreated ()
- {
- CreateAction ();
- installPackageHelper.TestPackage.Id = "Test";
- installPackageHelper.InstallTestPackage();
-
- 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);
- }
-
- [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);
- }
-
- [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);
- }
-
- [Test]
- public void NewInstance_LicensesMustBeAccepted_TrueByDefault ()
- {
- CreateAction ();
-
- Assert.IsTrue (action.LicensesMustBeAccepted);
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAccepted_PackagesPassedToLicenseAcceptanceService ()
- {
- CreateAction ();
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- expectedPackage.RequireLicenseAcceptance = true;
- var expectedPackages = new IPackage [] { expectedPackage };
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
-
- action.Execute ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, action.LicenseAcceptanceService.PackagesAccepted);
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageInstallOperationThatHasALicenseToBeAcceptedAndLicensesNotAccepted_LicenseAcceptanceServiceUsedAndExceptionThrown ()
- {
- CreateAction ();
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.0");
- expectedPackage.RequireLicenseAcceptance = true;
- var expectedPackages = new IPackage [] { expectedPackage };
- var operation = new FakePackageOperation (expectedPackage, PackageAction.Install);
- action.PackageId = expectedPackage.Id;
- action.PackageVersion = expectedPackage.Version;
- fakeProject.FakeInstallOperations.Add (operation);
- action.LicenseAcceptanceService.AcceptLicensesReturnValue = false;
-
- Exception ex = Assert.Throws (typeof(ApplicationException), () => action.Execute ());
-
- Assert.AreEqual ("Licenses not accepted.", ex.Message);
- PackageCollectionAssert.AreEqual (expectedPackages, action.LicenseAcceptanceService.PackagesAccepted);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildProjectExtensionsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildProjectExtensionsTests.cs index 59ed4dd6da..f9b5eb38da 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildProjectExtensionsTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildProjectExtensionsTests.cs @@ -3,7 +3,7 @@ using System; using System.Xml;
using MonoDevelop.PackageManagement;
using MonoDevelop.Projects.MSBuild;
-using NuGet;
+using NuGet.ProjectManagement;
using NUnit.Framework;
using System.Linq;
@@ -21,12 +21,12 @@ namespace MonoDevelop.PackageManagement.Tests void AddImportIfMissingAtBottom (string importFile, string condition = "")
{
- project.AddImportIfMissing (importFile, ProjectImportLocation.Bottom, condition);
+ project.AddImportIfMissing (importFile, ImportLocation.Bottom, condition);
}
void AddImportIfMissingAtTop (string importFile, string condition = "")
{
- project.AddImportIfMissing (importFile, ProjectImportLocation.Top, condition);
+ project.AddImportIfMissing (importFile, ImportLocation.Top, condition);
}
void AssertLastMSBuildImportElementHasProjectAttributeValue (string expectedAttributeValue)
@@ -179,8 +179,10 @@ namespace MonoDevelop.PackageManagement.Tests string import = @"..\packages\Foo.0.1\build\Foo.targets";
AddImportIfMissingAtTop (import);
-
+
+ var firstItem = project.GetAllObjects ().First () as MSBuildImport;
AssertFirstMSBuildImportElementHasProjectAttributeValue (@"..\packages\Foo.0.1\build\Foo.targets");
+ Assert.AreEqual (import, firstItem.Project);
}
[Test]
@@ -193,7 +195,9 @@ namespace MonoDevelop.PackageManagement.Tests AddImportIfMissingAtTop (import, condition);
+ var firstItem = project.GetAllObjects ().First () as MSBuildImport;
AssertFirstMSBuildImportElementHasCondition (condition);
+ Assert.AreEqual (condition, firstItem.Condition);
}
[Test]
@@ -207,5 +211,43 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual (1, project.Imports.Count ());
}
+
+ [Test]
+ public void AddImportIfMissing_AddImportToBottomWhenOtherImportIsNotLastElementInProject_ImportAddedAsLastElementInProject ()
+ {
+ CreateProject ();
+ var itemGroup = project.AddNewItemGroup ();
+ itemGroup.AddNewItem ("File.cs", "File.cs");
+ project.AddNewImport ("test", null, itemGroup);
+ string importFile = @"..\packages\Foo.0.1\build\Foo.targets";
+ string condition = "Exists('..\\packages\\Foo.0.1\\build\\Foo.targets')";
+ var lastItemBeforeAddingNewImport = project.GetAllObjects ().Last () as MSBuildItemGroup;
+
+ AddImportIfMissingAtBottom (importFile, condition);
+
+ var lastItem = project.GetAllObjects ().Last () as MSBuildImport;
+ Assert.IsNotNull (lastItem);
+ Assert.AreEqual (importFile, lastItem.Project);
+ Assert.AreEqual (condition, lastItem.Condition);
+ Assert.IsNotNull (lastItemBeforeAddingNewImport);
+ Assert.AreEqual ("File.cs", lastItemBeforeAddingNewImport.Items.First ().Include);
+ }
+
+ [Test]
+ public void AddImportIfMissing_AddImportToTopOfProjectWhenItemGroupIsFirstChildElementOfProject_ImportAddedAsFirstChildElement ()
+ {
+ CreateProject ();
+ var itemGroup = project.AddNewItemGroup ();
+ itemGroup.AddNewItem ("File.cs", "File.cs");
+ string import = @"..\packages\Foo.0.1\build\Foo.targets";
+ string condition = "Exists('..\\packages\\Foo.0.1\\build\\Foo.targets')";
+
+ AddImportIfMissingAtTop (import, condition);
+
+ var firstItem = project.GetAllObjects ().First () as MSBuildImport;
+ AssertFirstMSBuildImportElementHasCondition (condition);
+ Assert.AreEqual (import, firstItem.Project);
+ Assert.AreEqual (condition, firstItem.Condition);
+ }
}
}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildTargetsRestoredMonitorTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildTargetsRestoredMonitorTests.cs deleted file mode 100644 index eed15ff652..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MSBuildTargetsRestoredMonitorTests.cs +++ /dev/null @@ -1,87 +0,0 @@ -//
-// MSBuildTargetsRestoredMonitorTests.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 MonoDevelop.PackageManagement;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class MSBuildTargetsRestoredMonitorTests
- {
- MSBuildTargetsRestoredMonitor monitor;
- PackageManagementEvents packageEvents;
-
- void CreateMonitor ()
- {
- packageEvents = new PackageManagementEvents ();
- monitor = new MSBuildTargetsRestoredMonitor (packageEvents);
- }
-
- void PackageWithMSBuildTargetsIsRestored ()
- {
- var package = new FakePackage ("MyPackage");
- package.AddFile (@"build\MyPackage.targets");
-
- packageEvents.OnPackageRestored (package);
- }
-
- [Test]
- public void AnyMSBuildTargetsRestored_NoPackagesRestored_ReturnsFalse ()
- {
- CreateMonitor ();
-
- bool result = monitor.AnyMSBuildTargetsRestored;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void AnyMSBuildTargetsRestored_OnePackageWithMSBuildTargetsFileIsRestored_ReturnsTrue ()
- {
- CreateMonitor ();
- PackageWithMSBuildTargetsIsRestored ();
-
- bool result = monitor.AnyMSBuildTargetsRestored;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void AnyMSBuildTargetsRestored_PackageRestoredWithMSBuildTargetsFileAfterMonitorIsDisposed_ReturnsFalse ()
- {
- CreateMonitor ();
- monitor.Dispose ();
- PackageWithMSBuildTargetsIsRestored ();
-
- bool result = monitor.AnyMSBuildTargetsRestored;
-
- Assert.IsFalse (result);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopAggregateRepositoryTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopAggregateRepositoryTests.cs deleted file mode 100644 index b972f4a812..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopAggregateRepositoryTests.cs +++ /dev/null @@ -1,194 +0,0 @@ -//
-// AggregateRepositoryTests.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 NuGet;
-using System.Collections.Generic;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using System.Linq;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class MonoDevelopAggregateRepositoryTests
- {
- MonoDevelopAggregateRepository aggregateRepository;
- List<IPackageRepository> repositories;
-
- [SetUp]
- public void Init ()
- {
- repositories = new List<IPackageRepository> ();
- }
-
- FakePackageRepository AddRepository ()
- {
- var repository = new FakePackageRepository ();
- repositories.Add (repository);
- return repository;
- }
-
- FakePackage AddRepositoryWithOnePackage (string packageId)
- {
- FakePackageRepository repository = AddRepository ();
- return repository.AddFakePackage (packageId);
- }
-
- void CreateAggregateRepository ()
- {
- aggregateRepository = new MonoDevelopAggregateRepository (repositories);
- aggregateRepository.IgnoreFailingRepositories = true;
- }
-
- ExceptionThrowingPackageRepository AddFailingPackageRepository ()
- {
- return AddFailingPackageRepository (new Exception ("Error"));
- }
-
- ExceptionThrowingPackageRepository AddFailingPackageRepository (Exception exception)
- {
- var repository = new ExceptionThrowingPackageRepository {
- GetPackagesException = exception
- };
- repositories.Add (repository);
- return repository;
- }
-
- List<IPackage> Search ()
- {
- return aggregateRepository.Search (null, false).ToList ();
- }
-
- [Test]
- public void Search_IgnoreFailingRepositoriesAndOnePackageSourceFails_ErrorFromFailingRepositoryIsSupressed ()
- {
- FakePackage package1 = AddRepositoryWithOnePackage ("Package1");
- FakePackage package2 = AddRepositoryWithOnePackage ("Package2");
- AddFailingPackageRepository ();
- CreateAggregateRepository ();
- aggregateRepository.IgnoreFailingRepositories = true;
-
- List<IPackage> packages = Search ();
-
- Assert.AreEqual (2, packages.Count);
- Assert.That (packages, Contains.Item (package1));
- Assert.That (packages, Contains.Item (package2));
- }
-
- [Test]
- public void Search_TwoPackageRepositoriesOneFailingWhenGetPackagesCalled_AnyFailuresReturnsTrueAndAllFailedReturnsFalse ()
- {
- AddRepository ();
- AddFailingPackageRepository ();
- CreateAggregateRepository ();
- Search ();
-
- bool failures = aggregateRepository.AnyFailures ();
- bool allFailed = aggregateRepository.AllFailed ();
-
- Assert.IsTrue (failures);
- Assert.IsFalse (allFailed);
- }
-
- [Test]
- public void Search_TwoPackageRepositoriesBothFailingWhenGetPackagesCalled_AllFailedReturnsTrue ()
- {
- AddFailingPackageRepository ();
- AddFailingPackageRepository ();
- CreateAggregateRepository ();
- Search ();
-
- bool failures = aggregateRepository.AnyFailures ();
- bool allFailed = aggregateRepository.AllFailed ();
-
- Assert.IsTrue (failures);
- Assert.IsTrue (allFailed);
- }
-
- [Test]
- public void Search_TwoPackageRepositoriesNoneFailingWhenGetPackagesCalled_AnyFailuresAndAllFailedReturnFalse ()
- {
- AddRepository ();
- AddRepository ();
- CreateAggregateRepository ();
- Search ();
-
- bool failures = aggregateRepository.AnyFailures ();
- bool allFailed = aggregateRepository.AllFailed ();
-
- Assert.IsFalse (failures);
- Assert.IsFalse (allFailed);
- }
-
- [Test]
- public void Search_TwoPackageRepositoriesOneFailingWhenGetPackagesCalled_GetAggregateExceptionIncludesRepositoryException ()
- {
- AddRepository ();
- var exception = new Exception ("Error");
- AddFailingPackageRepository (exception);
- CreateAggregateRepository ();
- Search ();
-
- AggregateException aggregateException = aggregateRepository.GetAggregateException ();
-
- Assert.That (aggregateException.InnerExceptions, Contains.Item (exception));
- }
-
- [Test]
- public void Search_TwoPackageRepositoriesBothFailingWhenGetPackagesCalled_GetAggregateExceptionIncludesBothRepositoryExceptions ()
- {
- var exception1 = new Exception ("Error1");
- AddFailingPackageRepository (exception1);
- var exception2 = new Exception ("Error2");
- AddFailingPackageRepository (exception2);
- CreateAggregateRepository ();
- Search ();
-
- AggregateException aggregateException = aggregateRepository.GetAggregateException ();
-
- Assert.That (aggregateException.InnerExceptions, Contains.Item (exception1));
- Assert.That (aggregateException.InnerExceptions, Contains.Item (exception2));
- }
-
- [Test]
- public void Search_TwoPackageRepositoriesBothFailingWhenGetPackagesCalledFirstThenSecondTimeNewRepositoryAddedToRepositories_AllFailedReturnsFalseSecondTime ()
- {
- AddFailingPackageRepository ();
- AddFailingPackageRepository ();
- CreateAggregateRepository ();
- Search ();
- AddRepository ();
-
- bool failures = aggregateRepository.AnyFailures ();
- bool allFailed = aggregateRepository.AllFailed ();
-
- Assert.IsTrue (failures);
- Assert.IsFalse (allFailed);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopPackageManagerFactoryTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopPackageManagerFactoryTests.cs deleted file mode 100644 index c64ab3283c..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopPackageManagerFactoryTests.cs +++ /dev/null @@ -1,141 +0,0 @@ -//
-// MonoDevelopPackageManagerFactoryTests.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 MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class MonoDevelopPackageManagerFactoryTests
- {
- MonoDevelopPackageManagerFactory factory;
- IPackageManager packageManager;
- FakePackageRepository fakePackageRepository;
- FakeDotNetProject testProject;
- PackageManagementOptions options;
- FakePackageRepositoryFactory fakePackageRepositoryFactory;
- FakeProjectSystemFactory fakeProjectSystemFactory;
-
- void CreateFactory ()
- {
- options = new TestablePackageManagementOptions ();
- fakePackageRepositoryFactory = new FakePackageRepositoryFactory ();
- fakeProjectSystemFactory = new FakeProjectSystemFactory ();
- factory = new MonoDevelopPackageManagerFactory (fakePackageRepositoryFactory, fakeProjectSystemFactory, options);
- }
-
- void CreateTestProject ()
- {
- testProject = ProjectHelper.CreateTestProject ();
- var solution = new FakeSolution {
- BaseDirectory = @"c:\projects\MyProject\".ToNativePath ()
- };
- testProject.ParentSolution = solution;
- }
-
- void CreatePackageManager ()
- {
- fakePackageRepository = new FakePackageRepository ();
- packageManager = factory.CreatePackageManager (fakePackageRepository, testProject);
- }
-
- [Test]
- public void CreatePackageManager_ProjectAndSolutionHaveDifferentFolders_PackageManagerLocalRepositoryIsSharedRepository ()
- {
- CreateFactory ();
- CreateTestProject ();
- CreatePackageManager ();
- ISharedPackageRepository sharedRepository = packageManager.LocalRepository as ISharedPackageRepository;
-
- Assert.IsNotNull (sharedRepository);
- }
-
- [Test]
- public void CreatePackageManager_PackagesSolutionFolderDefinedInOptions_SharedLocalRepositoryFileSystemRootIsSolutionFolder ()
- {
- CreateFactory ();
- CreateTestProject ();
- options.PackagesDirectory = "MyPackages";
- CreatePackageManager ();
-
- string expectedRoot = @"c:\projects\MyProject\MyPackages".ToNativePath ();
- string actualRoot = fakePackageRepositoryFactory.FileSystemPassedToCreateSharedRepository.Root;
- Assert.AreEqual (expectedRoot, actualRoot);
- }
-
- [Test]
- public void CreatePackageManager_PackagesSolutionFolderDefinedInOptions_SharedLocalRepositoryPackagePathResolverCreatedWithPackagesFolderInsideSolutionFolder ()
- {
- CreateFactory ();
- CreateTestProject ();
- options.PackagesDirectory = "MyPackages";
- CreatePackageManager ();
-
- FakePackage package = new FakePackage ("Test.Package");
- package.Version = new SemanticVersion (1, 0, 0, 0);
- string expectedDirectory = @"c:\projects\MyProject\MyPackages\Test.Package.1.0.0.0".ToNativePath ();
- string actualDirectory =
- fakePackageRepositoryFactory
- .PathResolverPassedToCreateSharedRepository
- .GetInstallPath (package);
-
- Assert.AreEqual (expectedDirectory, actualDirectory);
- }
-
- [Test]
- public void CreatePackageManager_PackagesSolutionFolderDefinedInOptions_LocalRepositoryFileSystemIsPackageManagerFileSystem ()
- {
- CreateFactory ();
- CreateTestProject ();
- CreatePackageManager ();
-
- Assert.AreEqual (packageManager.FileSystem, fakePackageRepositoryFactory.FileSystemPassedToCreateSharedRepository);
- }
-
- [Test]
- public void CreatePackageManager_PackagesSolutionFolderDefinedInOptions_PackageManagerPathResolverUsesPackagesFolderInsideSolutionFolder ()
- {
- CreateFactory ();
- CreateTestProject ();
- options.PackagesDirectory = "packages";
- CreatePackageManager ();
-
- var package = new FakePackage ("TestPackage", "1.0.0.0");
-
- string expectedDirectory = @"c:\projects\MyProject\packages\TestPackage.1.0.0.0".ToNativePath ();
-
- MonoDevelopPackageManager monoDevelopPackageManager = packageManager as MonoDevelopPackageManager;
- string actualDirectory = monoDevelopPackageManager.PathResolver.GetInstallPath (package);
-
- Assert.AreEqual (expectedDirectory, actualDirectory);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopPackageManagerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopPackageManagerTests.cs deleted file mode 100644 index cc50fb5172..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopPackageManagerTests.cs +++ /dev/null @@ -1,1274 +0,0 @@ -//
-// MonoDevelopPackageManagerTests.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 System.Linq;
-using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class MonoDevelopPackageManagerTests
- {
- MonoDevelopPackageManager packageManager;
- FakePackageRepository fakeFeedSourceRepository;
- FakeSharedPackageRepository fakeSolutionSharedRepository;
- FakeProject project;
- PackageManagementOptions options;
- SolutionPackageRepositoryPath repositoryPaths;
- PackageReferenceRepositoryHelper packageRefRepositoryHelper;
- TestableProjectManager testableProjectManager;
- FakeFileSystem fakeFileSystem;
- FakePackageOperationResolverFactory fakePackageOperationResolverFactory;
- FakePackageOperationResolver fakePackageOperationResolver;
-
- void CreatePackageManager (IProject project, PackageReferenceRepositoryHelper packageRefRepositoryHelper)
- {
- CreatePackageManager (project, packageRefRepositoryHelper, new FakePackageRepository ());
- }
-
- void CreatePackageManager (
- IProject project,
- PackageReferenceRepositoryHelper packageRefRepositoryHelper,
- IPackageRepository sourceRepository)
- {
- options = new TestablePackageManagementOptions ();
- options.PackagesDirectory = "packages";
-
- repositoryPaths = new SolutionPackageRepositoryPath (project, options);
- var pathResolver = new DefaultPackagePathResolver (repositoryPaths.PackageRepositoryPath);
-
- fakeFileSystem = new FakeFileSystem ();
-
- fakeFeedSourceRepository = sourceRepository as FakePackageRepository;
- fakeSolutionSharedRepository = packageRefRepositoryHelper.FakeSharedSourceRepository;
-
- fakePackageOperationResolverFactory = new FakePackageOperationResolverFactory ();
- fakePackageOperationResolver = fakePackageOperationResolverFactory.FakeInstallPackageOperationResolver;
-
- var fakeSolutionPackageRepository = new FakeSolutionPackageRepository ();
- fakeSolutionPackageRepository.FileSystem = fakeFileSystem;
- fakeSolutionPackageRepository.PackagePathResolver = pathResolver;
- fakeSolutionPackageRepository.FakeSharedRepository = fakeSolutionSharedRepository;
-
- packageManager = new MonoDevelopPackageManager (sourceRepository,
- packageRefRepositoryHelper.FakeProjectSystem,
- fakeSolutionPackageRepository,
- fakePackageOperationResolverFactory);
- }
-
- void CreatePackageManager ()
- {
- CreatePackageManager (new FakePackageRepository ());
- }
-
- void CreatePackageManager (IPackageRepository sourceRepository)
- {
- CreateTestProject ();
- CreatePackageReferenceRepositoryHelper ();
- CreatePackageManager (project, packageRefRepositoryHelper, sourceRepository);
- }
-
- void CreatePackageReferenceRepositoryHelper ()
- {
- packageRefRepositoryHelper = new PackageReferenceRepositoryHelper ();
- }
-
- void CreateTestProject ()
- {
- var solution = new FakeSolution (@"c:\projects\Test\MyProject\MySolution.sln");
- solution.BaseDirectory = @"c:\projects\Test\MyProject";
- project = new FakeProject ();
- project.ParentSolution = solution;
- }
-
- void CreateTestableProjectManager ()
- {
- testableProjectManager = new TestableProjectManager ();
- packageManager.ProjectManager = testableProjectManager;
- }
-
- FakePackage CreateFakePackage (string id = "Test", string version = "1.0.0.0")
- {
- return new FakePackage (id, version);
- }
-
- FakePackage InstallPackage ()
- {
- FakePackage package = CreateFakePackage ();
- packageManager.InstallPackage (package);
- return package;
- }
-
- FakePackage InstallPackageWithNoPackageOperations ()
- {
- return InstallPackageWithNoPackageOperations (ignoreDependencies: false);
- }
-
- FakePackage InstallPackageWithNoPackageOperationsAndIgnoreDependencies ()
- {
- return InstallPackageWithNoPackageOperations (ignoreDependencies: true);
- }
-
- FakePackage InstallPackageWithNoPackageOperationsAndAllowPrereleaseVersions ()
- {
- return InstallPackageWithNoPackageOperations (ignoreDependencies: false, allowPrereleaseVersions: true);
- }
-
- FakePackage InstallPackageWithNoPackageOperations (bool ignoreDependencies)
- {
- return InstallPackageWithNoPackageOperations (ignoreDependencies, allowPrereleaseVersions: false);
- }
-
- FakePackage InstallPackageWithNoPackageOperations (bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- FakePackage package = CreateFakePackage ();
- var operations = new List<PackageOperation> ();
- var installAction = new FakeInstallPackageAction ();
- installAction.IgnoreDependencies = ignoreDependencies;
- installAction.AllowPrereleaseVersions = allowPrereleaseVersions;
- installAction.Operations = operations;
- packageManager.InstallPackage (package, installAction);
- return package;
- }
-
- FakePackage InstallPackageWithPackageOperations (PackageOperation operation)
- {
- var operations = new PackageOperation[] {
- operation
- };
- FakePackage package = CreateFakePackage ();
- var installAction = new FakeInstallPackageAction ();
- installAction.Operations = operations;
- packageManager.InstallPackage (package, installAction);
- return package;
- }
-
- FakePackage InstallPackageAndIgnoreDependencies ()
- {
- return InstallPackageWithParameters (true, false);
- }
-
- FakePackage InstallPackageWithParameters (bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- FakePackage package = CreateFakePackage ();
- packageManager.InstallPackage (package, ignoreDependencies, allowPrereleaseVersions);
- return package;
- }
-
- FakePackage InstallPackageAndAllowPrereleaseVersions ()
- {
- return InstallPackageWithParameters (false, true);
- }
-
- FakePackage InstallPackageAndDoNotAllowPrereleaseVersions ()
- {
- return InstallPackageWithParameters (false, false);
- }
-
- FakePackage InstallPackageAndDoNotIgnoreDependencies ()
- {
- return InstallPackageWithParameters (false, false);
- }
-
- FakePackage UninstallPackage ()
- {
- FakePackage package = CreateFakePackage ();
- testableProjectManager.FakeLocalRepository.FakePackages.Add (package);
-
- packageManager.UninstallPackage (package);
- return package;
- }
-
- FakePackage UninstallPackageAndForceRemove ()
- {
- FakePackage package = CreateFakePackage ();
- testableProjectManager.FakeLocalRepository.FakePackages.Add (package);
-
- bool removeDependencies = false;
- bool forceRemove = true;
- packageManager.UninstallPackage (package, forceRemove, removeDependencies);
-
- return package;
- }
-
- FakePackage UninstallPackageAndRemoveDependencies ()
- {
- FakePackage package = CreateFakePackage ();
- testableProjectManager.FakeLocalRepository.FakePackages.Add (package);
-
- bool removeDependencies = true;
- bool forceRemove = false;
- packageManager.UninstallPackage (package, forceRemove, removeDependencies);
-
- return package;
- }
-
- PackageOperation CreateOneInstallPackageOperation (string id = "PackageToInstall", string version = "1.0")
- {
- FakePackage package = CreateFakePackage (id, version);
- return new PackageOperation (package, PackageAction.Install);
- }
-
- IEnumerable<PackageOperation> GetInstallPackageOperations (FakePackage package)
- {
- return GetInstallPackageOperations (package, false, false);
- }
-
- IEnumerable<PackageOperation> GetInstallPackageOperationsAndIgnoreDependencies (FakePackage package)
- {
- return GetInstallPackageOperations (package, true, false);
- }
-
- IEnumerable<PackageOperation> GetInstallPackageOperationsAndAllowPrereleaseVersions (FakePackage package)
- {
- return GetInstallPackageOperations (package, false, true);
- }
-
- IEnumerable<PackageOperation> GetInstallPackageOperations (
- FakePackage package,
- bool ignoreDependencies,
- bool allowPrereleaseVersions)
- {
- var fakeInstallAction = new FakeInstallPackageAction ();
- fakeInstallAction.IgnoreDependencies = ignoreDependencies;
- fakeInstallAction.AllowPrereleaseVersions = allowPrereleaseVersions;
- return packageManager.GetInstallPackageOperations (package, fakeInstallAction);
- }
-
- FakePackage UpdatePackageWithNoPackageOperations ()
- {
- FakePackage package = CreateFakePackage ();
- var updateAction = new FakeUpdatePackageAction ();
- updateAction.Operations = new List<PackageOperation> ();
- updateAction.UpdateDependencies = true;
- packageManager.UpdatePackage (package, updateAction);
- return package;
- }
-
- FakePackage UpdatePackageWithPackageOperations (PackageOperation operation)
- {
- var operations = new PackageOperation[] {
- operation
- };
- FakePackage package = CreateFakePackage ();
- var updateAction = new FakeUpdatePackageAction ();
- updateAction.Operations = operations;
- updateAction.UpdateDependencies = true;
- packageManager.UpdatePackage (package, updateAction);
- return package;
- }
-
- FakePackage UpdatePackageWithNoPackageOperationsAndDoNotUpdateDependencies ()
- {
- return UpdatePackageWithNoPackageOperations (false, false);
- }
-
- FakePackage UpdatePackageWithNoPackageOperationsAndAllowPrereleaseVersions ()
- {
- return UpdatePackageWithNoPackageOperations (false, true);
- }
-
- FakePackage UpdatePackageWithNoPackageOperations (bool updateDependencies, bool allowPrereleaseVersions)
- {
- FakePackage package = CreateFakePackage ();
- var updateAction = new FakeUpdatePackageAction ();
- updateAction.Operations = new List<PackageOperation> ();
- updateAction.UpdateDependencies = updateDependencies;
- updateAction.AllowPrereleaseVersions = allowPrereleaseVersions;
- packageManager.UpdatePackage (package, updateAction);
- return package;
- }
-
- UpdatePackagesAction CreateUpdatePackagesAction ()
- {
- return new UpdatePackagesAction (new FakePackageManagementProject (), null);
- }
-
- UpdatePackagesAction CreateUpdatePackagesActionWithPackages (params IPackageFromRepository[] packages)
- {
- UpdatePackagesAction action = CreateUpdatePackagesAction ();
- action.AddPackages (packages);
- return action;
- }
-
- UpdatePackagesAction CreateUpdatePackagesActionWithOperations (params PackageOperation[] operations)
- {
- UpdatePackagesAction action = CreateUpdatePackagesAction ();
- action.AddOperations (operations);
- return action;
- }
-
- PackageOperation AddInstallOperationForPackage (IPackage package)
- {
- var operation = new PackageOperation (package, PackageAction.Install);
- AddInstallOperationsForPackage (package, operation);
- return operation;
- }
-
- void AddInstallOperationsForPackage (IPackage package, params PackageOperation[] operations)
- {
- fakePackageOperationResolver.AddOperations (package, operations);
- }
-
- void CreateFakePackageResolverForUpdatePackageOperations ()
- {
- fakePackageOperationResolver = new FakePackageOperationResolver ();
- fakePackageOperationResolverFactory.UpdatePackageOperationsResolver = fakePackageOperationResolver;
- }
-
- void RaisePackageRemovedEventWhenPackageReferenceUpdated (
- FakeProjectManager projectManager,
- FakePackage updatedPackage,
- params PackageOperationEventArgs[] eventArgs)
- {
- projectManager.WhenUpdatePackageReferenceCalled (
- updatedPackage.Id,
- updatedPackage.Version,
- () => eventArgs.ToList ().ForEach (eventArg => projectManager.FirePackageReferenceRemoved (eventArg)));
- }
-
- void RaisePackageAddedEventWhenPackageReferenceUpdated (
- FakeProjectManager projectManager,
- FakePackage updatedPackage,
- params PackageOperationEventArgs[] eventArgs)
- {
- projectManager.WhenUpdatePackageReferenceCalled (
- updatedPackage.Id,
- updatedPackage.Version,
- () => eventArgs.ToList ().ForEach (eventArg => projectManager.FirePackageReferenceAdded (eventArg)));
- }
-
- void RaisePackageRemovedEventWhenPackageReferenceAdded (
- FakeProjectManager projectManager,
- FakePackage newPackage,
- params PackageOperationEventArgs[] eventArgs)
- {
- projectManager.WhenAddPackageReferenceCalled (
- newPackage.Id,
- newPackage.Version,
- () => eventArgs.ToList ().ForEach (eventArg => projectManager.FirePackageReferenceRemoved (eventArg)));
- }
-
- void RaisePackageAddedEventWhenPackageReferenceAdded (
- FakeProjectManager projectManager,
- FakePackage newPackage,
- params PackageOperationEventArgs[] eventArgs)
- {
- projectManager.WhenAddPackageReferenceCalled (
- newPackage.Id,
- newPackage.Version,
- () => eventArgs.ToList ().ForEach (eventArg => projectManager.FirePackageReferenceAdded (eventArg)));
- }
-
- [Test]
- public void ProjectManager_InstanceCreated_SourceRepositoryIsAggregrateRepositoryContainingSharedRepositoryPassedToPackageManager ()
- {
- CreatePackageManager ();
-
- var aggregateRepository = packageManager.ProjectManager.SourceRepository as AggregateRepository;
- var secondaryRepository = aggregateRepository.Repositories.Last () as FakePackageRepository;
- Assert.AreEqual (2, aggregateRepository.Repositories.Count ());
- Assert.AreEqual (fakeSolutionSharedRepository, aggregateRepository.Repositories.First ());
- Assert.IsTrue (secondaryRepository.IsCloneOf (fakeFeedSourceRepository));
- }
-
- [Test]
- public void ProjectManager_LocalRepositoryIsFallbackRepository_SourceRepositoryIsFallbackContainingSharedRepositoryPassedToPackageManager ()
- {
- var primaryRepository = new FakePackageRepository ();
- var dependencyResolver = new FakePackageRepository ();
- var fallbackRepository = new FallbackRepository (primaryRepository, dependencyResolver);
- CreatePackageManager (fallbackRepository);
-
- var sourceRepository = packageManager.ProjectManager.SourceRepository as FallbackRepository;
- var aggregateRepository = sourceRepository.SourceRepository as AggregateRepository;
- Assert.AreEqual (dependencyResolver, sourceRepository.DependencyResolver);
- var secondaryRepository = aggregateRepository.Repositories.Last () as FakePackageRepository;
- Assert.AreEqual (2, aggregateRepository.Repositories.Count ());
- Assert.AreEqual (fakeSolutionSharedRepository, aggregateRepository.Repositories.First ());
- Assert.IsTrue (secondaryRepository.IsCloneOf (primaryRepository));
- }
-
- [Test]
- public void ProjectManager_InstanceCreated_LocalRepositoryIsPackageReferenceRepository ()
- {
- CreatePackageManager ();
- PackageReferenceRepository packageRefRepository = packageManager.ProjectManager.LocalRepository as PackageReferenceRepository;
- Assert.IsNotNull (packageRefRepository);
- }
-
- [Test]
- public void ProjectManager_InstanceCreated_LocalRepositoryIsRegisteredWithSharedRepository ()
- {
- CreateTestProject ();
- CreatePackageReferenceRepositoryHelper ();
-
- string expectedPath = @"c:\projects\Test\MyProject";
- packageRefRepositoryHelper.FakeProjectSystem.PathToReturnFromGetFullPath = expectedPath;
-
- CreatePackageManager (project, packageRefRepositoryHelper);
-
- string actualPath = fakeSolutionSharedRepository.PathPassedToRegisterRepository;
-
- Assert.AreEqual (expectedPath, actualPath);
- }
-
- [Test]
- public void ProjectManager_InstanceCreated_PathResolverIsPackageManagerPathResolver ()
- {
- CreatePackageManager ();
-
- Assert.AreEqual (packageManager.PathResolver, packageManager.ProjectManager.PathResolver);
- }
-
- [Test]
- public void InstallPackage_PackageInstancePassed_AddsReferenceToProject ()
- {
- CreatePackageManager ();
- FakePackage package = InstallPackage ();
-
- Assert.AreEqual (package, testableProjectManager.PackagePassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstancePassed_DependenciesNotIgnoredWhenAddingReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackage ();
-
- Assert.IsFalse (testableProjectManager.IgnoreDependenciesPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstancePassed_PrereleaseVersionsNotAllowedWhenAddingReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackage ();
-
- Assert.IsFalse (testableProjectManager.AllowPrereleaseVersionsPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstanceAndPackageOperationsPassed_AddsReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = InstallPackageWithNoPackageOperations ();
-
- Assert.AreEqual (package, testableProjectManager.PackagePassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstanceAndPackageOperationsPassed_DoNotIgnoreDependenciesWhenAddingReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageWithNoPackageOperations ();
-
- Assert.IsFalse (testableProjectManager.IgnoreDependenciesPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstanceAndPackageOperationsPassed_DoNotAllowPrereleaseVersionsWhenAddingReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageWithNoPackageOperations ();
-
- Assert.IsFalse (testableProjectManager.AllowPrereleaseVersionsPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstanceAndPackageOperationsPassedAndIgnoreDependenciesIsTrue_IgnoreDependenciesWhenAddingReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageWithNoPackageOperationsAndIgnoreDependencies ();
-
- Assert.IsTrue (testableProjectManager.IgnoreDependenciesPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstanceAndPackageOperationsPassedAndAllowPrereleaseVersionsIsTrue_PrereleaseVersionsallowedWhenAddingReferenceToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageWithNoPackageOperationsAndAllowPrereleaseVersions ();
-
- Assert.IsTrue (testableProjectManager.AllowPrereleaseVersionsPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageInstanceAndOneInstallPackageOperationPassed_PackageDefinedInOperationIsInstalledInLocalRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- PackageOperation operation = CreateOneInstallPackageOperation ();
- InstallPackageWithPackageOperations (operation);
-
- Assert.AreEqual (operation.Package, fakeSolutionSharedRepository.FirstPackageAdded);
- }
-
- [Test]
- public void InstallPackage_PackageDependenciesIgnored_IgnoreDependenciesPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageAndIgnoreDependencies ();
-
- Assert.IsTrue (testableProjectManager.IgnoreDependenciesPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_AllowPrereleaseVersions_AllowPrereleaseVersionsPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageAndAllowPrereleaseVersions ();
-
- Assert.IsTrue (testableProjectManager.AllowPrereleaseVersionsPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageDependenciesIgnored_AddsReferenceToPackage ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = InstallPackageAndIgnoreDependencies ();
-
- Assert.AreEqual (package, testableProjectManager.PackagePassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageDependenciesNotIgnored_IgnoreDependenciesPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- InstallPackageAndDoNotIgnoreDependencies ();
-
- Assert.IsFalse (testableProjectManager.IgnoreDependenciesPassedToAddPackageReference);
- }
-
- [Test]
- public void InstallPackage_PackageDependenciesNotIgnored_AddsReferenceToPackage ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = InstallPackageAndDoNotIgnoreDependencies ();
-
- Assert.AreEqual (package, testableProjectManager.PackagePassedToAddPackageReference);
- }
-
- [Test]
- public void UninstallPackage_PackageInProjectLocalRepository_RemovesReferenceFromProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = UninstallPackage ();
-
- Assert.AreEqual (package.Id, testableProjectManager.PackagePassedToRemovePackageReference.Id);
- }
-
- [Test]
- public void UninstallPackage_PackageInProjectLocalRepository_DoesNotRemoveReferenceForcefullyFromProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- UninstallPackage ();
-
- Assert.IsFalse (testableProjectManager.ForcePassedToRemovePackageReference);
- }
-
- [Test]
- public void UninstallPackage_PackageInProjectLocalRepository_DependenciesNotRemovedWhenPackageReferenceRemovedFromProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- UninstallPackage ();
-
- Assert.IsFalse (testableProjectManager.RemoveDependenciesPassedToRemovePackageReference);
- }
-
- [Test]
- public void UninstallPackage_PassingForceRemove_ReferenceForcefullyRemovedFromProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- UninstallPackageAndForceRemove ();
-
- Assert.IsTrue (testableProjectManager.ForcePassedToRemovePackageReference);
- }
-
- [Test]
- public void UninstallPackage_PassingRemoveDependencies_DependenciesRemovedWhenPackageReferenceRemovedFromProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- UninstallPackageAndRemoveDependencies ();
-
- Assert.IsTrue (testableProjectManager.RemoveDependenciesPassedToRemovePackageReference);
- }
-
- [Test]
- public void UninstallPackage_ProjectLocalRepositoryHasPackage_PackageRemovedFromProjectRepositoryBeforeSolutionRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- FakePackage package = CreateFakePackage ();
- package.Id = "Test";
-
- testableProjectManager.FakeLocalRepository.FakePackages.Add (package);
-
- IPackage packageRemovedFromProject = null;
- packageManager.PackageUninstalled += (sender, e) => {
- packageRemovedFromProject = testableProjectManager.PackagePassedToRemovePackageReference;
- };
- packageManager.UninstallPackage (package);
-
- Assert.AreEqual ("Test", packageRemovedFromProject.Id);
- }
-
- [Test]
- public void UninstallPackage_PackageReferencedByNoProjects_PackageIsRemovedFromSharedSolutionRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- FakePackage package = CreateFakePackage ();
- package.Id = "MyPackageId";
-
- testableProjectManager.FakeLocalRepository.FakePackages.Add (package);
- fakeSolutionSharedRepository.FakePackages.Add (package);
-
- packageManager.UninstallPackage (package);
-
- bool containsPackage = fakeSolutionSharedRepository.FakePackages.Contains (package);
-
- Assert.IsFalse (containsPackage);
- }
-
- [Test]
- public void UninstallPackage_PackageReferencedByTwoProjects_PackageIsNotRemovedFromSharedSolutionRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- var package = new FakePackage ("MyPackageId", "1.4.5.2");
-
- testableProjectManager.FakeLocalRepository.FakePackages.Add (package);
- fakeSolutionSharedRepository.FakePackages.Add (package);
- fakeSolutionSharedRepository.PackageIdsReferences.Add ("MyPackageId");
-
- packageManager.UninstallPackage (package);
-
- bool containsPackage = fakeSolutionSharedRepository.FakePackages.Contains (package);
-
- Assert.IsTrue (containsPackage);
- Assert.AreEqual ("MyPackageId", fakeSolutionSharedRepository.PackageIdPassedToIsReferenced);
- Assert.AreEqual (package.Version, fakeSolutionSharedRepository.VersionPassedToIsReferenced);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackageOperationResolverFactoryUsed_PackageOperationsReturnedFromPackageOperationsResolverCreated ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- var expectedOperations = new PackageOperation [] {
- new PackageOperation (package, PackageAction.Install)
- };
- fakePackageOperationResolver.AddOperations (package, expectedOperations);
-
- IEnumerable<PackageOperation> operations = GetInstallPackageOperations (package);
-
- Assert.AreEqual (expectedOperations, operations);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesLocalRepositoryWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperations (package);
-
- IPackageRepository expectedRepository = packageManager.LocalRepository;
- IPackageRepository actualRepository = fakePackageOperationResolverFactory.LocalRepositoryPassedToCreateInstallPackageOperationsResolver;
-
- Assert.AreEqual (expectedRepository, actualRepository);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesSourceRepositoryWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperations (package);
-
- IPackageRepository expectedRepository = packageManager.SourceRepository;
- IPackageRepository actualRepository = fakePackageOperationResolverFactory.SourceRepositoryPassedToCreateInstallPackageOperationsResolver;
-
- Assert.AreEqual (expectedRepository, actualRepository);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackageOperationResolverFactoryUsed_DependenciesNotIgnored ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperations (package);
-
- bool result = fakePackageOperationResolverFactory.IgnoreDependenciesPassedToCreateInstallPackageOperationResolver;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesLoggerWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperations (package);
-
- ILogger expectedLogger = packageManager.Logger;
- ILogger actualLogger = fakePackageOperationResolverFactory.LoggerPassedToCreateInstallPackageOperationResolver;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackageOperationResolverFactoryUsed_PackageUsedWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperations (package);
-
- IPackage actualPackage = fakePackageOperationResolverFactory
- .FakeInstallPackageOperationResolver
- .PackagePassedToResolveOperations;
-
- Assert.AreEqual (package, actualPackage);
- }
-
- [Test]
- public void GetInstallPackageOperations_IgnoreDependenciesIsTrue_PackageOperationResolverIgnoresDependencies ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperationsAndIgnoreDependencies (package);
-
- bool result = fakePackageOperationResolverFactory.IgnoreDependenciesPassedToCreateInstallPackageOperationResolver;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void GetInstallPackageOperations_AllowPrereleaseVersionsIsTrue_PackageOperationResolverAllowsPrereleaseVersions ()
- {
- CreatePackageManager ();
- var package = new FakePackage ();
- AddInstallOperationForPackage (package);
- GetInstallPackageOperationsAndAllowPrereleaseVersions (package);
-
- bool result = fakePackageOperationResolverFactory.AllowPrereleaseVersionsPassedToCreateInstallPackageOperationResolver;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void GetInstallPackageOperations_AllowPrereleaseVersionsIsFalse_PackageOperationResolverDoesNotAllowPrereleaseVersions ()
- {
- CreatePackageManager ();
- var package = new FakePackage ("Test", "1.0");
- AddInstallOperationForPackage (package);
- GetInstallPackageOperations (package);
-
- bool result = fakePackageOperationResolverFactory.AllowPrereleaseVersionsPassedToCreateInstallPackageOperationResolver;
-
- Assert.IsFalse (result);
- }
-
- public void UpdatePackage_PackageInstanceAndNoPackageOperationsPassed_UpdatesReferenceInProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = UpdatePackageWithNoPackageOperations ();
-
- Assert.AreEqual (package, testableProjectManager.PackagePassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackage_PackageInstanceAndNoPackageOperationsPassed_UpdatesDependenciesInProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- UpdatePackageWithNoPackageOperations ();
-
- Assert.IsTrue (testableProjectManager.UpdateDependenciesPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackage_PackageInstanceAndAllowPrereleaseVersionsIsTrue_PrereleaseVersionsAllowedToUpdateProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- UpdatePackageWithNoPackageOperationsAndAllowPrereleaseVersions ();
-
- Assert.IsTrue (testableProjectManager.AllowPrereleaseVersionsPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackage_PackageInstanceAndAllowPrereleaseVersionsIsFalse_PrereleaseVersionsNotAllowedToUpdateProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- UpdatePackageWithNoPackageOperations ();
-
- Assert.IsFalse (testableProjectManager.AllowPrereleaseVersionsPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackage_PackageInstanceAndOneInstallPackageOperationPassed_PackageDefinedInOperationIsInstalledInLocalRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
-
- PackageOperation operation = CreateOneInstallPackageOperation ();
- UpdatePackageWithPackageOperations (operation);
-
- Assert.AreEqual (operation.Package, fakeSolutionSharedRepository.FirstPackageAdded);
- }
-
- [Test]
- public void UpdatePackage_UpdateDependenciesSetToFalse_DependenciesInProjectNotUpdated ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- UpdatePackageWithNoPackageOperationsAndDoNotUpdateDependencies ();
-
- Assert.IsFalse (testableProjectManager.UpdateDependenciesPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_OnePackage_PackageReferencedIsAddedToProject ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction action = CreateUpdatePackagesActionWithPackages (package);
-
- packageManager.UpdatePackages (action);
-
- Assert.AreEqual (package, testableProjectManager.PackagePassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_TwoPackages_PackageReferencedIsAddedToProjectForBothPackages ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package1 = CreateFakePackage ("First", "1.1");
- FakePackage package2 = CreateFakePackage ("Second", "2.0");
- var expectedPackages = new FakePackage[] { package1, package2 };
- UpdatePackagesAction action = CreateUpdatePackagesActionWithPackages (expectedPackages);
-
- packageManager.UpdatePackages (action);
-
- PackageCollectionAssert.AreEqual (expectedPackages, testableProjectManager.PackagesPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_UpdateDependenciesIsTrue_UpdateDependenciesPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction action = CreateUpdatePackagesActionWithPackages (package);
- action.UpdateDependencies = true;
-
- packageManager.UpdatePackages (action);
-
- Assert.IsTrue (testableProjectManager.UpdateDependenciesPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_UpdateDependenciesIsFalse_UpdateDependenciesPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction action = CreateUpdatePackagesActionWithPackages (package);
- action.UpdateDependencies = false;
-
- packageManager.UpdatePackages (action);
-
- Assert.IsFalse (testableProjectManager.UpdateDependenciesPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_AllowPrereleaseVersionsIsTrue_AllowPrereleaseVersionsPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction action = CreateUpdatePackagesActionWithPackages (package);
- action.AllowPrereleaseVersions = true;
-
- packageManager.UpdatePackages (action);
-
- Assert.IsTrue (testableProjectManager.AllowPrereleaseVersionsPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_AllowPrereleaseVersionsIsFalse_AllowPrereleaseVersionsPassedToProjectManager ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction action = CreateUpdatePackagesActionWithPackages (package);
- action.AllowPrereleaseVersions = false;
-
- packageManager.UpdatePackages (action);
-
- Assert.IsFalse (testableProjectManager.AllowPrereleaseVersionsPassedToUpdatePackageReference);
- }
-
- [Test]
- public void UpdatePackages_TwoPackageOperations_BothPackagesInOperationsAddedToSharedRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- PackageOperation operation1 = CreateOneInstallPackageOperation ("First", "1.0");
- PackageOperation operation2 = CreateOneInstallPackageOperation ("Second", "1.0");
- UpdatePackagesAction action = CreateUpdatePackagesActionWithOperations (operation1, operation2);
- var expectedPackages = new FakePackage[] {
- operation1.Package as FakePackage,
- operation2.Package as FakePackage
- };
-
- packageManager.UpdatePackages (action);
-
- PackageCollectionAssert.AreEqual (expectedPackages, fakeSolutionSharedRepository.PackagesAdded);
- }
-
- [Test]
- public void GetUpdatePackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesLoggerWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction updateAction = CreateUpdatePackagesActionWithPackages (package);
- CreateFakePackageResolverForUpdatePackageOperations ();
- AddInstallOperationForPackage (package);
-
- packageManager.GetUpdatePackageOperations (updateAction.Packages, updateAction);
-
- ILogger expectedLogger = packageManager.Logger;
- ILogger actualLogger = fakePackageOperationResolverFactory.LoggerPassedToCreateUpdatePackageOperationResolver;
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void GetUpdatePackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesLocalRepositoryWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction updateAction = CreateUpdatePackagesActionWithPackages (package);
- CreateFakePackageResolverForUpdatePackageOperations ();
- AddInstallOperationForPackage (package);
-
- packageManager.GetUpdatePackageOperations (updateAction.Packages, updateAction);
-
- IPackageRepository expectedRepository = packageManager.LocalRepository;
- IPackageRepository actualRepository = fakePackageOperationResolverFactory.LocalRepositoryPassedToCreateUpdatePackageOperationsResolver;
- Assert.AreEqual (expectedRepository, actualRepository);
- }
-
- [Test]
- public void GetUpdatePackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesSourceRepositoryWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction updateAction = CreateUpdatePackagesActionWithPackages (package);
- CreateFakePackageResolverForUpdatePackageOperations ();
- AddInstallOperationForPackage (package);
-
- packageManager.GetUpdatePackageOperations (updateAction.Packages, updateAction);
-
- IPackageRepository expectedRepository = packageManager.SourceRepository;
- IPackageRepository actualRepository = fakePackageOperationResolverFactory.SourceRepositoryPassedToCreateUpdatePackageOperationsResolver;
- Assert.AreEqual (expectedRepository, actualRepository);
- }
-
- [Test]
- public void GetUpdatePackageOperations_PackageOperationResolverFactoryUsed_PackageManagerUsesUpdatePackageSettingsWhenGettingPackageOperations ()
- {
- CreatePackageManager ();
- FakePackage package = CreateFakePackage ("Test", "1.1");
- UpdatePackagesAction updateAction = CreateUpdatePackagesActionWithPackages (package);
- CreateFakePackageResolverForUpdatePackageOperations ();
- AddInstallOperationForPackage (package);
-
- packageManager.GetUpdatePackageOperations (updateAction.Packages, updateAction);
-
- IUpdatePackageSettings settings = fakePackageOperationResolverFactory.SettingsPassedToCreatePackageOperationResolver;
- Assert.AreEqual (updateAction, settings);
- }
-
- [Test]
- public void GetUpdatePackageOperations_TwoPackages_ReturnsPackageOperationsForBothPackages ()
- {
- CreatePackageManager ();
- CreateFakePackageResolverForUpdatePackageOperations ();
- IPackageFromRepository package1 = CreateFakePackage ("Test", "1.0");
- IPackageFromRepository package2 = CreateFakePackage ("Test2", "1.0");
- PackageOperation operation1 = AddInstallOperationForPackage (package1);
- PackageOperation operation2 = AddInstallOperationForPackage (package2);
- UpdatePackagesAction updateAction = CreateUpdatePackagesActionWithPackages (package1, package2);
-
- List<PackageOperation> operations = packageManager.GetUpdatePackageOperations (updateAction.Packages, updateAction).ToList ();
-
- Assert.AreEqual (2, operations.Count ());
- Assert.IsTrue (operations.Contains (operation1));
- Assert.IsTrue (operations.Contains (operation2));
- }
-
- [Test]
- public void RunPackageOperations_TwoPackageOperations_BothPackagesInOperationsAddedToSharedRepository ()
- {
- CreatePackageManager ();
- CreateTestableProjectManager ();
- PackageOperation operation1 = CreateOneInstallPackageOperation ("First", "1.0");
- PackageOperation operation2 = CreateOneInstallPackageOperation ("Second", "1.0");
- var operations = new PackageOperation[] { operation1, operation2 };
- var expectedPackages = new FakePackage[] {
- operation1.Package as FakePackage,
- operation2.Package as FakePackage
- };
-
- packageManager.RunPackageOperations (operations);
-
- PackageCollectionAssert.AreEqual (expectedPackages, fakeSolutionSharedRepository.PackagesAdded);
- }
-
- [Test]
- public void UpdatePackage_OldPackageReferenceIsRemovedOnUpdating_OldPackageIsUninstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- FakePackage installedPackage = fakeSolutionSharedRepository.AddFakePackageWithVersion ("MyPackage", "1.0");
- FakePackage updatedPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (installedPackage, null, null);
- RaisePackageRemovedEventWhenPackageReferenceUpdated (fakeProjectManager, updatedPackage, eventArgs);
- var updateAction = new FakeUpdatePackageAction {
- Operations = new List<PackageOperation> (),
- UpdateDependencies = false
- };
-
- packageManager.UpdatePackage (updatedPackage, updateAction);
-
- Assert.IsFalse (fakeSolutionSharedRepository.FakePackages.Contains (installedPackage));
- }
-
- [Test]
- public void UpdatePackage_TwoOldPackageReferencesAreRemovedOnUpdating_BothOldPackagesAreUninstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- FakePackage installedPackage1 = fakeSolutionSharedRepository.AddFakePackageWithVersion ("MyPackage-Core", "1.0");
- FakePackage installedPackage2 = fakeSolutionSharedRepository.AddFakePackageWithVersion ("MyPackage", "1.0");
- FakePackage updatedPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs1 = new PackageOperationEventArgs (installedPackage1, null, null);
- var eventArgs2 = new PackageOperationEventArgs (installedPackage2, null, null);
- RaisePackageRemovedEventWhenPackageReferenceUpdated (fakeProjectManager, updatedPackage, eventArgs1, eventArgs2);
- var updateAction = new FakeUpdatePackageAction {
- Operations = new List<PackageOperation> (),
- UpdateDependencies = false
- };
-
- packageManager.UpdatePackage (updatedPackage, updateAction);
-
- Assert.IsFalse (fakeSolutionSharedRepository.FakePackages.Contains (installedPackage2));
- Assert.IsFalse (fakeSolutionSharedRepository.FakePackages.Contains (installedPackage1));
- }
-
- [Test]
- public void UpdatePackage_OldPackageReferenceIsRemovedOnUpdatingButAnotherProjectStillReferencesThePackage_OldPackageIsNotUninstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- FakePackage installedPackage = fakeSolutionSharedRepository.AddFakePackageWithVersion ("MyPackage-Core", "1.0");
- FakePackage updatedPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (installedPackage, null, null);
- RaisePackageRemovedEventWhenPackageReferenceUpdated (fakeProjectManager, updatedPackage, eventArgs);
- var updateAction = new FakeUpdatePackageAction {
- Operations = new List<PackageOperation> (),
- UpdateDependencies = false
- };
- fakeSolutionSharedRepository.PackageIdsReferences.Add ("MyPackage-Core");
-
- packageManager.UpdatePackage (updatedPackage, updateAction);
-
- Assert.IsTrue (fakeSolutionSharedRepository.FakePackages.Contains (installedPackage));
- }
-
- [Test]
- public void InstallPackage_OldPackageReferenceIsRemovedOnInstalling_OldPackageIsUninstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- FakePackage installedPackage = fakeSolutionSharedRepository.AddFakePackageWithVersion ("MyPackage", "1.0");
- FakePackage newPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (installedPackage, null, null);
- RaisePackageRemovedEventWhenPackageReferenceAdded (fakeProjectManager, newPackage, eventArgs);
- var installAction = new FakeInstallPackageAction {
- Operations = new List<PackageOperation> ()
- };
-
- packageManager.InstallPackage (newPackage, installAction);
-
- Assert.IsFalse (fakeSolutionSharedRepository.FakePackages.Contains (installedPackage));
- }
-
- [Test]
- public void InstallPackage_OldPackageReferenceIsRemovedOnInstallingButOtherProjectsReferencesOldPackage_OldPackageIsNotUninstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- FakePackage installedPackage = fakeSolutionSharedRepository.AddFakePackageWithVersion ("MyPackage.Core", "1.0");
- FakePackage newPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- fakeSolutionSharedRepository.PackageIdsReferences.Add ("MyPackage.Core");
- var eventArgs = new PackageOperationEventArgs (installedPackage, null, null);
- RaisePackageRemovedEventWhenPackageReferenceAdded (fakeProjectManager, newPackage, eventArgs);
- var installAction = new FakeInstallPackageAction {
- Operations = new List<PackageOperation> ()
- };
-
- packageManager.InstallPackage (newPackage, installAction);
-
- Assert.IsTrue (fakeSolutionSharedRepository.FakePackages.Contains (installedPackage));
- }
-
- [Test]
- public void InstallPackage_PackageReferenceIsAddedForPackageNotInstalledInLocalRepository_PackageIsInstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- var packageReferenced = new FakePackage ("FooBar", "1.0");
- FakePackage newPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (packageReferenced, null, null);
- RaisePackageAddedEventWhenPackageReferenceAdded (fakeProjectManager, newPackage, eventArgs);
- var installAction = new FakeInstallPackageAction {
- Operations = new List<PackageOperation> ()
- };
-
- packageManager.InstallPackage (newPackage, installAction);
-
- Assert.IsTrue (fakeSolutionSharedRepository.PackagesAdded.Contains (packageReferenced));
- }
-
- [Test]
- public void InstallPackage_PackageReferenceIsAddedForPackageInstalledInLocalRepository_PackageIsNotInstalledToLocalRepositoryAgain ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- var packageReferenced = new FakePackage ("FooBar", "1.0");
- fakeSolutionSharedRepository.FakePackages.Add (packageReferenced);
- FakePackage newPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (packageReferenced, null, null);
- RaisePackageAddedEventWhenPackageReferenceAdded (fakeProjectManager, newPackage, eventArgs);
- var installAction = new FakeInstallPackageAction {
- Operations = new List<PackageOperation> ()
- };
-
- packageManager.InstallPackage (newPackage, installAction);
-
- Assert.IsFalse (fakeSolutionSharedRepository.PackagesAdded.Contains (packageReferenced));
- }
-
- [Test]
- public void UpdatePackage_PackageReferenceIsAddedForPackageNotInstalledInLocalRepository_PackageIsInstalled ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- var packageReferenced = new FakePackage ("FooBar", "1.0");
- FakePackage newPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (packageReferenced, null, null);
- RaisePackageAddedEventWhenPackageReferenceUpdated (fakeProjectManager, newPackage, eventArgs);
- var updateAction = new FakeUpdatePackageAction {
- Operations = new List<PackageOperation> ()
- };
-
- packageManager.UpdatePackage (newPackage, updateAction);
-
- Assert.IsTrue (fakeSolutionSharedRepository.PackagesAdded.Contains (packageReferenced));
- }
-
- [Test]
- public void UpdatePackage_PackageReferenceIsAddedForPackageInstalledInLocalRepository_PackageIsNotInstalledAgainInLocalRepository ()
- {
- CreatePackageManager ();
- var fakeProjectManager = new FakeProjectManager ();
- packageManager.ProjectManager = fakeProjectManager;
- var packageReferenced = new FakePackage ("FooBar", "1.0");
- fakeSolutionSharedRepository.FakePackages.Add (packageReferenced);
- FakePackage newPackage = fakeFeedSourceRepository.AddFakePackageWithVersion ("MyPackage", "1.1");
- var eventArgs = new PackageOperationEventArgs (packageReferenced, null, null);
- RaisePackageAddedEventWhenPackageReferenceUpdated (fakeProjectManager, newPackage, eventArgs);
- var updateAction = new FakeUpdatePackageAction {
- Operations = new List<PackageOperation> ()
- };
-
- packageManager.UpdatePackage (newPackage, updateAction);
-
- Assert.IsFalse (fakeSolutionSharedRepository.PackagesAdded.Contains (packageReferenced));
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectManagerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectManagerTests.cs deleted file mode 100644 index 49ce6e4f04..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectManagerTests.cs +++ /dev/null @@ -1,151 +0,0 @@ -//
-// MonoDevelopProjectManagerTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class MonoDevelopProjectManagerTests
- {
- TestableProjectManager projectManager;
- FakeFileSystem fileSystem;
-
- void CreateProjectManager ()
- {
- projectManager = new TestableProjectManager ();
- }
-
- FakeFileSystem CreateFileSystem ()
- {
- fileSystem = new FakeFileSystem ();
- return fileSystem;
- }
-
- void AddFakePackageToProjectLocalRepository (string packageId, string version)
- {
- projectManager.AddFakePackageToProjectLocalRepository (packageId, version);
- }
-
- FakePackage CreatePackage (string packageId, string version)
- {
- return FakePackage.CreatePackageWithVersion (packageId, version);
- }
-
- void SetProjectPackagesConfigFileContents (string xml)
- {
- fileSystem.FileExistsReturnValue = true;
- fileSystem.FileToReturnFromOpenFile = xml;
- }
-
- void CreateProjectManagerWithPackageReferenceRepository ()
- {
- var sharedRepository = new FakeSharedPackageRepository ();
- var repository = new PackageReferenceRepository (fileSystem, "MyProject", sharedRepository);
- projectManager = new TestableProjectManager (repository);
- }
-
- [Test]
- public void IsInstalled_PackageIdPassedThatDoesNotExistInProjectLocalRepository_ReturnsFalse ()
- {
- CreateProjectManager ();
-
- bool installed = projectManager.IsInstalled ("Test");
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIdPassedExistsInProjectLocalRepository_ReturnsTrue ()
- {
- CreateProjectManager ();
- projectManager.AddFakePackageToProjectLocalRepository ("Test", "1.0.2");
-
- bool installed = projectManager.IsInstalled ("Test");
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void HasOlderPackageInstalled_ProjectLocalRepositoryDoesNotHavePackage_ReturnsFalse ()
- {
- CreateProjectManager ();
- FakePackage package = CreatePackage ("Test", "1.0");
-
- bool installed = projectManager.HasOlderPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void HasOlderPackageInstalled_ProjectLocalRepositoryHasOlderPackage_ReturnsTrue ()
- {
- CreateProjectManager ();
- projectManager.AddFakePackageToProjectLocalRepository ("Test", "1.0");
- FakePackage package = CreatePackage ("Test", "1.1");
-
- bool installed = projectManager.HasOlderPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void HasOlderPackageInstalled_ProjectLocalRepositoryHasSamePackageVersion_ReturnsFalse ()
- {
- CreateProjectManager ();
- projectManager.AddFakePackageToProjectLocalRepository ("Test", "1.1");
- FakePackage package = CreatePackage ("Test", "1.1");
-
- bool installed = projectManager.HasOlderPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void GetPackageReferences_OnePackageReferenceInPackageReferenceRepository_ReturnsOnePackageReference ()
- {
- CreateFileSystem ();
- string config =
-@"<packages>
- <package id='NUnit' version='1.0.1' />
-</packages>";
- SetProjectPackagesConfigFileContents (config);
- CreateProjectManagerWithPackageReferenceRepository ();
-
- List<PackageReference> packageReferences = projectManager.GetPackageReferences ().ToList ();
- PackageReference packageReference = packageReferences.FirstOrDefault ();
-
- Assert.AreEqual ("NUnit", packageReference.Id);
- Assert.AreEqual ("1.0.1", packageReference.Version.ToString ());
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs index 0fa66464e2..8d49379950 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/MonoDevelopProjectSystemTests.cs @@ -1,5 +1,5 @@ //
-// MonoDevelopProjectSystemTests.cs
+// MonoDevelopMSBuildNuGetProjectSystemTests.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
@@ -28,31 +28,33 @@ using System; using System.IO;
using System.Linq;
using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
+using System.Threading.Tasks;
using MonoDevelop.Core;
using MonoDevelop.Core.Assemblies;
using MonoDevelop.PackageManagement.Tests.Helpers;
using MonoDevelop.Projects;
using MonoDevelop.Projects.MSBuild;
-using NuGet;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+using NuGet.Versioning;
using NUnit.Framework;
namespace MonoDevelop.PackageManagement.Tests
{
[TestFixture]
- public class MonoDevelopProjectSystemTests
+ public class MonoDevelopMSBuildNuGetProjectSystemTests
{
TestableMonoDevelopProjectSystem projectSystem;
FakeDotNetProject project;
- void CreateProjectSystem (IDotNetProject project)
+ void CreateProjectSystem (IDotNetProject dotNetProject)
{
- projectSystem = new TestableMonoDevelopProjectSystem (project);
+ projectSystem = new TestableMonoDevelopProjectSystem (dotNetProject);
}
void CreateTestProject ()
{
- project = new FakeDotNetProject ();
+ project = new FakeDotNetProject (@"d:\Projects\Test\MyProject.csproj");
}
void CreateTestWebApplicationProject ()
@@ -97,7 +99,7 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual (expectedCondition, import.Condition);
}
- void AssertLastImportHasImportLocation (ProjectImportLocation expectedLocation)
+ void AssertLastImportHasImportLocation (ImportLocation expectedLocation)
{
ImportAndCondition import = projectSystem.NewImportsHandler.ImportsAdded.Last ();
Assert.AreEqual (expectedLocation, import.Location);
@@ -115,7 +117,7 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual (expectedCondition, import.Condition);
} - void AssertFirstImportHasImportLocation (ProjectImportLocation expectedLocation)
+ void AssertFirstImportHasImportLocation (ImportLocation expectedLocation)
{
ImportAndCondition import = projectSystem.NewImportsHandler.ImportsAdded.First ();
Assert.AreEqual (expectedLocation, import.Location);
@@ -139,8 +141,8 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
CreateProjectSystem (project);
- string expectedRoot = @"d:\projects\MyProject\".ToNativePath ();
- Assert.AreEqual (expectedRoot, projectSystem.Root);
+ string expectedRoot = @"d:\projects\MyProject".ToNativePath ();
+ Assert.AreEqual (expectedRoot, projectSystem.ProjectFullPath);
}
[Test]
@@ -189,7 +191,7 @@ namespace MonoDevelop.PackageManagement.Tests FrameworkName expectedName = new FrameworkName (".NETFramework, Version=v4.0");
- Assert.AreEqual (expectedName, projectSystem.TargetFramework);
+ Assert.AreEqual (expectedName.ToString (), projectSystem.TargetFramework.ToString ());
}
[Test]
@@ -201,7 +203,7 @@ namespace MonoDevelop.PackageManagement.Tests FrameworkName expectedName = new FrameworkName (".NETFramework, Profile=Client, Version=v3.5");
- Assert.AreEqual (expectedName, projectSystem.TargetFramework);
+ Assert.AreEqual (expectedName.ToString (), projectSystem.TargetFramework.ToString ());
}
[Test]
@@ -213,7 +215,7 @@ namespace MonoDevelop.PackageManagement.Tests FrameworkName expectedName = new FrameworkName ("Silverlight, Version=v2.0");
- Assert.AreEqual (expectedName, projectSystem.TargetFramework);
+ Assert.AreEqual (expectedName.ToString (), projectSystem.TargetFramework.ToString ());
}
[Test]
@@ -397,7 +399,7 @@ namespace MonoDevelop.PackageManagement.Tests project.IsSaved = false;
string fileName = @"d:\projects\packages\nunit\nunit.framework.dll".ToNativePath ();
- projectSystem.AddReference (fileName, null);
+ projectSystem.AddReference (fileName);
Assert.AreEqual (1, project.ReferencesWhenSavedCount);
}
@@ -410,7 +412,7 @@ namespace MonoDevelop.PackageManagement.Tests project.IsSaved = false;
string fileName = @"d:\projects\packages\nunit\nunit.framework.dll".ToNativePath ();
- projectSystem.AddReference (fileName, null);
+ projectSystem.AddReference (fileName);
ProjectReference actualReference = project.References [0];
Assert.AreEqual ("nunit.framework", actualReference.Reference);
@@ -425,7 +427,7 @@ namespace MonoDevelop.PackageManagement.Tests project.IsSaved = false;
string relativeFileName = @"packages\nunit\nunit.framework.dll".ToNativePath ();
string fullFileName = @"d:\projects\MyProject\packages\nunit\nunit.framework.dll".ToNativePath ();
- projectSystem.AddReference (relativeFileName, null);
+ projectSystem.AddReference (relativeFileName);
ProjectReference actualReference = project.References [0];
Assert.AreEqual ("nunit.framework", actualReference.Reference);
@@ -440,7 +442,7 @@ namespace MonoDevelop.PackageManagement.Tests project.Name = "MyTestProject";
string fileName = @"d:\projects\packages\nunit\nunit.framework.dll".ToNativePath ();
- projectSystem.AddReference (fileName, null);
+ projectSystem.AddReference (fileName);
var expectedReferenceAndProjectName = new ReferenceAndProjectName () {
Reference = "nunit.framework",
@@ -691,62 +693,62 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void DeleteFile_DeletesFileFromFileSystem_CallsFileServiceRemoveFile ()
+ public void RemoveFile_DeletesFileFromFileSystem_CallsFileServiceRemoveFile ()
{
CreateTestProject (@"d:\temp\MyProject.csproj");
AddFileToProject (@"d:\temp\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteFile ("test.cs");
+ projectSystem.RemoveFile ("test.cs");
Assert.AreEqual (@"d:\temp\test.cs".ToNativePath (), projectSystem.FakeFileService.PathPassedToRemoveFile);
}
[Test]
- public void DeleteFile_DeletesFileFromFileSystem_ProjectIsSavedAfterFileRemoved ()
+ public void RemoveFile_DeletesFileFromFileSystem_ProjectIsSavedAfterFileRemoved ()
{
CreateTestProject (@"d:\temp\MyProject.csproj");
project.IsSaved = false;
AddFileToProject (@"d:\temp\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteFile ("test.cs");
+ projectSystem.RemoveFile ("test.cs");
Assert.AreEqual (0, project.FilesInProjectWhenSavedCount);
}
[Test]
- public void DeleteFile_DeletesFileFromFileSystem_FileDeletionLogged ()
+ public void RemoveFile_DeletesFileFromFileSystem_FileDeletionLogged ()
{
CreateTestProject (@"d:\temp\MyProject.csproj");
AddFileToProject (@"d:\temp\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteFile ("test.cs");
+ projectSystem.RemoveFile ("test.cs");
Assert.AreEqual ("test.cs", projectSystem.FileNamePassedToLogDeletedFile);
}
[Test]
- public void DeleteFile_DeletesFileFromFileSystem_FolderInformationNotLogged ()
+ public void RemoveFile_DeletesFileFromFileSystem_FolderInformationNotLogged ()
{
CreateTestProject (@"d:\temp\MyProject.csproj");
AddFileToProject (@"d:\temp\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteFile ("test.cs");
+ projectSystem.RemoveFile ("test.cs");
Assert.IsNull (projectSystem.FileNameAndDirectoryPassedToLogDeletedFileFromDirectory);
}
[Test]
- public void DeleteFile_DeletesFileFromSubFolder_FileDeletionLogged ()
+ public void RemoveFile_DeletesFileFromSubFolder_FileDeletionLogged ()
{
CreateTestProject (@"d:\temp\MyProject.csproj");
AddFileToProject (@"d:\temp\src\Files\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteFile (@"src\Files\test.cs".ToNativePath ());
+ projectSystem.RemoveFile (@"src\Files\test.cs".ToNativePath ());
var expectedFileNameAndFolder = new FileNameAndDirectory () {
FileName = "test.cs",
@@ -759,13 +761,13 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void DeleteFile_DeletesFileFromSubFolder_FileDeletionWithoutFolderInformationIsNotLogged ()
+ public void RemoveFile_DeletesFileFromSubFolder_FileDeletionWithoutFolderInformationIsNotLogged ()
{
CreateTestProject (@"d:\temp\MyProject.csproj");
AddFileToProject (@"d:\temp\src\Files\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteFile (@"src\Files\test.cs".ToNativePath ());
+ projectSystem.RemoveFile (@"src\Files\test.cs".ToNativePath ());
Assert.IsNull (projectSystem.FileNamePassedToLogDeletedFile);
}
@@ -777,7 +779,7 @@ namespace MonoDevelop.PackageManagement.Tests AddFileToProject (@"d:\temp\test\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteDirectory ("test");
+ projectSystem.DeleteDirectory ("test", false);
string path = @"d:\temp\test".ToNativePath ();
Assert.AreEqual (path, projectSystem.FakeFileService.PathPassedToRemoveDirectory);
@@ -791,7 +793,7 @@ namespace MonoDevelop.PackageManagement.Tests AddFileToProject (@"d:\temp\test\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteDirectory ("test");
+ projectSystem.DeleteDirectory ("test", false);
Assert.AreEqual (0, project.FilesInProjectWhenSavedCount);
Assert.IsTrue (project.IsSaved);
@@ -805,7 +807,7 @@ namespace MonoDevelop.PackageManagement.Tests AddFileToProject (@"d:\temp\test\test.cs");
CreateProjectSystem (project);
- projectSystem.DeleteDirectory ("test");
+ projectSystem.DeleteDirectory ("test", false);
Assert.AreEqual ("test", projectSystem.DirectoryPassedToLogDeletedDirectory);
}
@@ -908,10 +910,10 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
AssertLastMSBuildChildElementHasProjectAttributeValue (@"..\packages\Foo.0.1\build\Foo.targets");
- AssertLastImportHasImportLocation (ProjectImportLocation.Bottom);
+ AssertLastImportHasImportLocation (ImportLocation.Bottom);
}
[Test]
@@ -921,10 +923,10 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
AssertLastMSBuildChildElementHasProjectAttributeValue (@"packages\Foo.0.1\build\Foo.targets");
- AssertLastImportHasImportLocation (ProjectImportLocation.Bottom);
+ AssertLastImportHasImportLocation (ImportLocation.Bottom);
}
[Test]
@@ -934,10 +936,10 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
AssertLastImportHasCondition ("Exists('..\\packages\\Foo.0.1\\build\\Foo.targets')");
- AssertLastImportHasImportLocation (ProjectImportLocation.Bottom);
+ AssertLastImportHasImportLocation (ImportLocation.Bottom);
}
[Test]
@@ -947,10 +949,10 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
Assert.AreEqual (1, projectSystem.NewImportsHandler.ImportsAdded.Count);
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
Assert.AreEqual (1, projectSystem.NewImportsHandler.ImportsAdded.Count);
}
@@ -962,10 +964,10 @@ namespace MonoDevelop.PackageManagement.Tests string targetPath1 = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
string targetPath2 = @"d:\projects\MyProject\packages\Foo.0.1\BUILD\FOO.TARGETS".ToNativePath ();
- projectSystem.AddImport (targetPath1, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath1, ImportLocation.Bottom);
Assert.AreEqual (1, projectSystem.NewImportsHandler.ImportsAdded.Count);
- projectSystem.AddImport (targetPath2, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath2, ImportLocation.Bottom);
Assert.AreEqual (1, projectSystem.NewImportsHandler.ImportsAdded.Count);
}
@@ -976,7 +978,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
Assert.IsTrue (project.IsSaved);
}
@@ -987,7 +989,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
projectSystem.RemoveImport (targetPath);
@@ -1000,7 +1002,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath1 = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath1, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath1, ImportLocation.Bottom);
string targetPath2 = @"d:\projects\MyProject\packages\Foo.0.1\BUILD\FOO.TARGETS".ToNativePath ();
projectSystem.RemoveImport (targetPath2);
@@ -1027,10 +1029,10 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Top);
+ projectSystem.AddImport (targetPath, ImportLocation.Top);
AssertFirstMSBuildChildElementHasProjectAttributeValue (@"..\packages\Foo.0.1\build\Foo.targets");
- AssertFirstImportHasImportLocation (ProjectImportLocation.Top);
+ AssertFirstImportHasImportLocation (ImportLocation.Top);
}
[Test]
@@ -1040,10 +1042,10 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Top);
+ projectSystem.AddImport (targetPath, ImportLocation.Top);
AssertFirstImportHasCondition ("Exists('..\\packages\\Foo.0.1\\build\\Foo.targets')");
- AssertFirstImportHasImportLocation (ProjectImportLocation.Top);
+ AssertFirstImportHasImportLocation (ImportLocation.Top);
}
[Test]
@@ -1053,49 +1055,15 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Top);
+ projectSystem.AddImport (targetPath, ImportLocation.Top);
Assert.AreEqual (1, projectSystem.NewImportsHandler.ImportsAdded.Count);
- projectSystem.AddImport (targetPath, ProjectImportLocation.Top);
+ projectSystem.AddImport (targetPath, ImportLocation.Top);
Assert.AreEqual (1, projectSystem.NewImportsHandler.ImportsAdded.Count);
}
[Test]
- public void AddFile_NewFileAddedWithAction_AddsFileToFileSystem ()
- {
- CreateTestProject ();
- CreateProjectSystem (project);
-
- string expectedPath = @"d:\temp\abc.cs".ToNativePath ();
- Action<Stream> expectedAction = stream => {
- };
- projectSystem.AddFile (expectedPath, expectedAction);
-
- Assert.AreEqual (expectedPath, projectSystem.PathPassedToPhysicalFileSystemAddFile);
- Assert.AreEqual (expectedAction, projectSystem.ActionPassedToPhysicalFileSystemAddFile);
- }
-
- [Test]
- public void AddFile_NewFileAddedWithAction_AddsFileToProject ()
- {
- CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
- string fileName = @"d:\projects\MyProject\src\NewFile.cs".ToNativePath ();
- project.AddDefaultBuildAction (BuildAction.Compile, fileName);
- CreateProjectSystem (project);
-
- Action<Stream> action = stream => {
- };
- projectSystem.AddFile (fileName, action);
-
- ProjectFile fileItem = ProjectHelper.GetFile (project, fileName);
- var expectedFileName = new FilePath (fileName);
-
- Assert.AreEqual (expectedFileName, fileItem.FilePath);
- Assert.AreEqual (BuildAction.Compile, fileItem.BuildAction);
- }
-
- [Test]
public void ReferenceExists_ReferenceIsInProjectButIncludesAssemblyVersion_ReturnsTrue ()
{
CreateTestProject ();
@@ -1130,7 +1098,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
string expectedImportRemoved = @"..\packages\Foo.0.1\build\Foo.targets";
projectSystem.RemoveImport (targetPath.ToNativePath ());
@@ -1146,7 +1114,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
projectSystem.RemoveImport (targetPath);
@@ -1159,7 +1127,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
const string expectedImportRemoved = @"..\packages\Foo.0.1\build\Foo.targets";
DotNetProjectImportEventArgs eventArgs = null;
projectSystem.PackageManagementEvents.ImportRemoved += (sender, e) => {
@@ -1180,7 +1148,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
MSBuildProject msbuildProject = CreateMSBuildProject (
"<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n" +
" <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n" +
@@ -1214,7 +1182,7 @@ namespace MonoDevelop.PackageManagement.Tests };
string fileName = @"d:\projects\packages\nunit\nunit.framework.dll".ToNativePath ();
- projectSystem.AddReference (fileName, null);
+ projectSystem.AddReference (fileName);
Assert.AreEqual (fileName, referenceBeingAdded.HintPath.ToString ());
Assert.IsTrue (referenceBeingAdded.LocalCopy);
@@ -1247,10 +1215,89 @@ namespace MonoDevelop.PackageManagement.Tests CreateProjectSystem (project);
string targetPath = @"d:\projects\MyProject\packages\Foo.0.1\build\Foo.targets".ToNativePath ();
- projectSystem.AddImport (targetPath, ProjectImportLocation.Bottom);
+ projectSystem.AddImport (targetPath, ImportLocation.Bottom);
Assert.IsTrue (projectSystem.NewImportsHandler.IsDisposed);
}
+
+ [Test]
+ public void AddExistingFile_FileExists_AddsFileToProject ()
+ {
+ CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
+ string fileName = @"d:\projects\MyProject\src\NewFile.cs".ToNativePath ();
+ project.AddDefaultBuildAction (BuildAction.Compile, fileName);
+ CreateProjectSystem (project);
+
+ projectSystem.AddExistingFile (fileName);
+
+ ProjectFile fileItem = ProjectHelper.GetFile (project, fileName);
+ var expectedFileName = new FilePath (fileName);
+ Assert.AreEqual (expectedFileName, fileItem.FilePath);
+ Assert.AreEqual (BuildAction.Compile, fileItem.BuildAction);
+ Assert.IsNull (projectSystem.PathPassedToPhysicalFileSystemAddFile);
+ Assert.IsTrue (project.IsSaved);
+ Assert.AreEqual (1, project.FilesAddedWhenSavedCount);
+ }
+
+ [Test]
+ public async Task ExecuteScriptAsync_InitPowerShellScript_WarningLogged ()
+ {
+ CreateTestProject ();
+ CreateProjectSystem (project);
+ string scriptPath = @"init.ps1".ToNativePath ();
+ var package = new PackageIdentity ("Test", new NuGetVersion ("1.2"));
+ string expectedLogMessage = "WARNING: Test Package contains PowerShell script 'init.ps1' which will not be run.";
+
+ await projectSystem.ExecuteScriptAsync (package, null, scriptPath, null, false);
+
+ Assert.AreEqual (MessageLevel.Info, projectSystem.FakeNuGetProjectContext.LastLogLevel);
+ Assert.AreEqual (expectedLogMessage, projectSystem.FakeNuGetProjectContext.LastMessageLogged);
+ }
+
+ [Test]
+ public void GetDirectories_TwoDirectories_ReturnsTwoDirectories ()
+ {
+ CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
+ CreateProjectSystem (project);
+ var expectedDirectories = new string[] {
+ @"d:\projects\MyProject\Scripts\One".ToNativePath (),
+ @"d:\projects\MyProject\Scripts\Two".ToNativePath (),
+ };
+ projectSystem.AddDirectoriesForPath (@"d:\projects\MyProject\Scripts".ToNativePath (), expectedDirectories);
+
+ string[] directories = projectSystem.GetDirectories (@"Scripts").ToArray ();
+
+ CollectionAssert.AreEqual (expectedDirectories, directories);
+ }
+
+ [Test]
+ public void GetFiles_Recursive_ThrowsNotImplementedException ()
+ {
+ CreateTestProject ();
+ CreateProjectSystem (project);
+
+ Assert.Throws<NotImplementedException> (() => projectSystem.GetFiles ("", "*.*", true));
+ }
+
+ [Test]
+ public void GetFiles_TwoFiles_ReturnsTwoFiles ()
+ {
+ CreateTestProject (@"d:\projects\MyProject\MyProject.csproj");
+ CreateProjectSystem (project);
+ var expectedFiles = new string[] {
+ @"d:\projects\MyProject\Scripts\one.js".ToNativePath (),
+ @"d:\projects\MyProject\Scripts\two.js".ToNativePath (),
+ };
+ projectSystem.AddFilesForPath (
+ @"d:\projects\MyProject\Scripts".ToNativePath (),
+ "*.*",
+ SearchOption.TopDirectoryOnly,
+ expectedFiles);
+
+ string[] files = projectSystem.GetFiles (@"Scripts", "*.*", false).ToArray ();
+
+ CollectionAssert.AreEqual (expectedFiles, files);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/NuGetPackageUninstallerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/NuGetPackageUninstallerTests.cs new file mode 100644 index 0000000000..05f0858756 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/NuGetPackageUninstallerTests.cs @@ -0,0 +1,155 @@ +// +// NuGetPackageUninstallerTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Linq; +using System.Threading.Tasks; +using MonoDevelop.PackageManagement.Tests.Helpers; +using MonoDevelop.Projects.MSBuild; +using NuGet.Packaging; +using NuGet.Versioning; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class NuGetPackageUninstallerTests + { + NuGetPackageUninstaller uninstaller; + FakeDotNetProject project; + MSBuildProject msbuildProject; + + void CreateMSBuildProject () + { + CreateMSBuildProject ( + "<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n" + + "</Project>"); + } + + void CreateMSBuildProject (string xml) + { + msbuildProject = new MSBuildProject (); + msbuildProject.LoadXml (xml); + } + + void CreateProject (string fileName = @"d:\projects\MyProject\MyProject.csproj") + { + fileName = fileName.ToNativePath (); + project = new FakeDotNetProject (fileName); + project.SaveAction = SaveProject; + } + + void CreateUninstallerWithPackagesFolder (string packagesDirectory) + { + packagesDirectory = packagesDirectory.ToNativePath (); + CreateProject (); + var resolver = new PackagePathResolver (packagesDirectory); + uninstaller = new NuGetPackageUninstaller (project, resolver); + } + + void AddReferenceToProject (string name, string hintPath = null) + { + if (hintPath != null) + hintPath = hintPath.ToNativePath (); + ProjectHelper.AddReference (project, name, hintPath); + } + + Task ForceUninstall (string packageId, string packageVersion) + { + msbuildProject.FileName = project.FileName; + return uninstaller.ForceUninstall (packageId, new NuGetVersion (packageVersion)); + } + + void SaveProject () + { + var msbuildExtension = new PackageManagementMSBuildExtension (); + msbuildExtension.UpdateProject (msbuildProject); + } + + [Test] + public async Task ForceUninstall_TwoReferencesOneMatchesPackageBeingRemoved_OneReferenceRemoved () + { + CreateMSBuildProject (); + CreateUninstallerWithPackagesFolder (@"d:\MyProject\packages"); + AddReferenceToProject ("System"); + AddReferenceToProject ("MyLib", @"d:\MyProject\packages\MyLib.1.2\lib\net40\MyLib.dll"); + + await ForceUninstall ("MyLib", "1.2"); + + Assert.AreEqual (1, project.References.Count); + Assert.AreEqual ("System", project.References[0].Reference); + Assert.IsTrue (project.IsSaved); + } + + [Test] + public async Task ForceUninstall_TwoImportsOneMatchesPackageBeingRemoved_OneImportRemoved () + { + CreateMSBuildProject ( + "<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n" + + " <Import Project=\"$(MSBuildBinPath)\\Microsoft.CSharp.targets\" />\r\n" + + " <Import Project=\"packages\\MyLib.1.2\\build\\net45\\MyLib.targets\" Condition=\"Exists('packages\\MyLib.1.2\\build\\net45\\MyLib.targets')\" />\r\n" + + "</Project>"); + CreateUninstallerWithPackagesFolder (@"d:\MyProject\packages"); + project.ChangeFileName (@"d:\MyProject\MyProject.csproj"); + int importsBeforeUninstall = msbuildProject.Imports.Count (); + + await ForceUninstall ("MyLib", "1.2"); + + Assert.AreEqual (2, importsBeforeUninstall); + Assert.IsTrue (project.IsSaved); + Assert.AreEqual (1, msbuildProject.Imports.Count ()); + Assert.AreEqual (@"$(MSBuildBinPath)\Microsoft.CSharp.targets", msbuildProject.Imports.First ().Project); + } + + [Test] + public async Task ForceUninstall_EnsureNuGetPackageBuildImportExists_ImportAndEnsureNuGetPackageBuildImportIsRemoved () + { + CreateMSBuildProject ( + "<Project ToolsVersion=\"12.0\" DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n" + + " <Target Name=\"EnsureNuGetPackageBuildImports\" BeforeTargets=\"PrepareForBuild\">\r\n" + + " <PropertyGroup>\r\n" + + " <ErrorText>Error.</ErrorText>\r\n" + + " </PropertyGroup>\r\n" + + " <Error Condition=\"!Exists('packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets')\" Text=\"$([System.String]::Format('$(ErrorText)', 'packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets'))\" />\r\n" + + " </Target>\r\n" + + " <Import Project=\"$(MSBuildBinPath)\\Microsoft.CSharp.targets\" />\r\n" + + " <Import Project=\"packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets\" Condition=\"Exists('packages\\Xamarin.Forms.1.2.3.6257\\build\\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\\Xamarin.Forms.targets)\" />\r\n" + + "</Project>"); + CreateUninstallerWithPackagesFolder (@"d:\MyProject\packages"); + project.ChangeFileName (@"d:\MyProject\MyProject.csproj"); + int targetCountBeforeUninstall = msbuildProject.Targets.Count (); + int importsBeforeUninstall = msbuildProject.Imports.Count (); + + await ForceUninstall ("Xamarin.Forms", "1.2.3.6257"); + + Assert.AreEqual (1, targetCountBeforeUninstall); + Assert.AreEqual (2, importsBeforeUninstall); + Assert.AreEqual (1, msbuildProject.Imports.Count ()); + Assert.AreEqual (@"$(MSBuildBinPath)\Microsoft.CSharp.targets", msbuildProject.Imports.First ().Project); + Assert.AreEqual (0, msbuildProject.Targets.Count ()); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenDotNetProjectTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenDotNetProjectTests.cs deleted file mode 100644 index 39ddd0638f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenDotNetProjectTests.cs +++ /dev/null @@ -1,90 +0,0 @@ -//
-// OpenDotNetProjectTests.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class OpenDotNetProjectsTests
- {
- OpenDotNetProjects projects;
- FakePackageManagementProjectService fakeProjectService;
- List<IDotNetProject> openProjects;
-
- void CreateOpenMSBuildProjects ()
- {
- fakeProjectService = new FakePackageManagementProjectService ();
- openProjects = fakeProjectService.OpenProjects;
-
- projects = new OpenDotNetProjects (fakeProjectService);
- }
-
- FakeDotNetProject AddProjectWithShortName (string projectName)
- {
- var project = ProjectHelper.CreateTestProject (projectName);
- openProjects.Add (project);
- return project;
- }
-
- FakeDotNetProject AddProjectWithFileName (string fileName)
- {
- FakeDotNetProject project = AddProjectWithShortName ("Test");
- project.FileName = new FilePath (fileName);
- return project;
- }
-
- [Test]
- public void FindProject_ProjectShortNameUsedAndProjectIsOpen_ReturnsProject ()
- {
- CreateOpenMSBuildProjects ();
- IDotNetProject expectedProject = AddProjectWithShortName ("MyProject");
-
- IDotNetProject project = projects.FindProject ("MyProject");
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void FindProject_ProjectFileNameUsedAndProjectIsOpen_ReturnsProject ()
- {
- CreateOpenMSBuildProjects ();
- string fileName = @"d:\projects\MyProject\MyProject.csproj";
- IDotNetProject expectedProject = AddProjectWithFileName (fileName);
-
- IDotNetProject project = projects.FindProject (fileName);
-
- Assert.AreEqual (expectedProject, project);
- }
- }
-}
-
-
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 deleted file mode 100644 index 637b41bf47..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/OpenPackageReadMeMonitorTests.cs +++ /dev/null @@ -1,175 +0,0 @@ -//
-// OpenPackageReadMeMonitorTests.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;
-using System.IO;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class OpenPackageReadMeMonitorTests
- {
- FakeFileService fileService;
- FakePackageManagementProject project;
-
- OpenPackageReadMeMonitor CreateMonitor (string packageId)
- {
- fileService = new FakeFileService (null);
- project = new FakePackageManagementProject ();
- return new OpenPackageReadMeMonitor (packageId, project, fileService);
- }
-
- FakePackage CreatePackageWithFile (string packageId, string fileName)
- {
- var package = new FakePackage (packageId);
- package.AddFile (fileName);
- return package;
- }
-
- PackageOperationEventArgs CreatePackageInstallEventWithFile (string installPath, IPackage package)
- {
- return new PackageOperationEventArgs (package, null, installPath);
- }
-
- [Test]
- public void OpenReadMeFile_PackageInstalledWithReadmeTxt_ReadmeTxtIsOpened ()
- {
- 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);
- monitor.OpenReadMeFile ();
- }
-
- Assert.AreEqual (expectedFileOpened, fileService.FileNamePassedToOpenFile);
- }
-
- [Test]
- 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 (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 OpenReadMeFile_PackageInstalledWithoutReadmeTxt_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);
- var package = new FakePackage ("Test");
- PackageOperationEventArgs e = CreatePackageInstallEventWithFile (installPath, package);
- project.FirePackageInstalledEvent (e);
- monitor.OpenReadMeFile ();
- }
-
- Assert.IsFalse (fileService.IsOpenFileCalled);
- }
-
- [Test]
- public void OpenReadMeFile_PackageDependencyIsInstalledWithReadmeTxtWithDifferentCase_ReadmeTxtIsOpened ()
- {
- 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);
- monitor.OpenReadMeFile ();
- }
-
- Assert.AreEqual (expectedFileOpened, fileService.FileNamePassedToOpenFile);
- }
-
- [Test]
- public void OpenReadMeFile_PackageInstalledWithReadmeTxtButFileDoesNotExistOnFileSystem_ReadmeTxtIsNotOpened ()
- {
- const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
- string readmeFileName = Path.Combine (installPath, "readme.txt");
-
- 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_ReadmeTxtIsNotOpenedUntilOpenReadMeFileMethodIsCalled ()
- {
- const string installPath = @"d:\projects\myproject\packages\Test.1.2.0";
- string expectedFileOpened = Path.Combine (installPath, "ReadMe.TXT");
-
- 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);
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageCompatibilityRunnerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageCompatibilityRunnerTests.cs index b9b290a0ff..eeff2e1b93 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageCompatibilityRunnerTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageCompatibilityRunnerTests.cs @@ -28,7 +28,6 @@ using System; using System.IO;
using System.Linq;
using System.Text;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Core;
using MonoDevelop.Core.Assemblies;
using MonoDevelop.PackageManagement.Tests.Helpers;
@@ -42,12 +41,8 @@ namespace MonoDevelop.PackageManagement.Tests {
TestablePackageCompatibilityRunner runner;
FakeDotNetProject project;
- FakePackageManagementSolution solution;
- FakeRegisteredPackageRepositories registeredRepositories;
FakeProgressMonitorFactory progressMonitorFactory;
PackageManagementEvents packageManagementEvents;
- PackageManagementProgressProvider progressProvider;
- FakePackageRepositoryFactoryEvents repositoryFactoryEvents;
FakeProgressMonitor progressMonitor;
void CreateRunner ()
@@ -55,24 +50,14 @@ namespace MonoDevelop.PackageManagement.Tests project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj");
project.Name = "MyProject";
project.TargetFrameworkMoniker = new TargetFrameworkMoniker ("4.5");
- solution = new FakePackageManagementSolution ();
- registeredRepositories = new FakeRegisteredPackageRepositories ();
progressMonitorFactory = new FakeProgressMonitorFactory ();
progressMonitor = progressMonitorFactory.ProgressMonitor;
packageManagementEvents = new PackageManagementEvents ();
- repositoryFactoryEvents = new FakePackageRepositoryFactoryEvents ();
- progressProvider = new PackageManagementProgressProvider (repositoryFactoryEvents, handler => {
- handler.Invoke ();
- });
-
runner = new TestablePackageCompatibilityRunner (
project,
- solution,
- registeredRepositories,
progressMonitorFactory,
- packageManagementEvents,
- progressProvider);
+ packageManagementEvents);
}
void Run ()
@@ -98,9 +83,7 @@ namespace MonoDevelop.PackageManagement.Tests package.AddFile (@"lib\net45\MyPackage.dll");
package.AddFile (@"lib\net40\MyPackage.dll");
- FakePackageManagementProject packageManagementProject =
- solution.AddFakeProjectToReturnFromGetProject (project.Name);
- packageManagementProject.FakePackages.Add (package);
+ runner.PackageRepository.FakeSharedRepository.FakePackages.Add (package);
string xml = String.Format (
@"<packages>
@@ -119,29 +102,28 @@ namespace MonoDevelop.PackageManagement.Tests void ProjectPackagesAreNotRestored ()
{
- solution.FakeProjectsToReturnFromGetProject ["MyProject"].FakePackages.Clear ();
+ runner.PackageRepository.FakeSharedRepository.FakePackages.Clear ();
}
void ProjectHasOnePackageReferenceCompatibleWithCurrentProjectTargetFramework (string packageId)
{
ProjectHasOnePackageReferenceNeedingReinstall (packageId);
- solution.FakeProjectsToReturnFromGetProject ["MyProject"].FakePackages [0].FilesList.Clear ();
+ runner.PackageRepository.FakeSharedRepository.FakePackages [0].FilesList.Clear ();
}
void ProjectHasOnePackageReferenceIncompatibleWithCurrentProjectTargetFramework (string packageId)
{
ProjectHasOnePackageReferenceNeedingReinstall (packageId);
- FakePackage package = solution.FakeProjectsToReturnFromGetProject ["MyProject"].FakePackages [0];
+ FakePackage package = runner.PackageRepository.FakeSharedRepository.FakePackages [0];
package.FilesList.Clear ();
package.AddFile (@"lib\wp8\MyPackage.dll");
}
void FindPackageInProjectThrowsException (string errorMessage)
{
- FakePackageManagementProject project = solution.FakeProjectsToReturnFromGetProject ["MyProject"];
- project.FindPackageAction = packageId => {
+ runner.PackageRepository.FakeSharedRepository.BeforeGetPackagesAction = () => {
throw new Exception (errorMessage);
};
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageFilesTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageFilesTests.cs deleted file mode 100644 index acf36c1ef4..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageFilesTests.cs +++ /dev/null @@ -1,170 +0,0 @@ -//
-// PackageFilesTests.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;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageFilesTests
- {
- PackageFiles packageFiles;
-
- void CreatePackageFiles (FakePackage package)
- {
- packageFiles = new PackageFiles (package);
- }
-
- void CreatePackageFilesWithOneFile (string fileName)
- {
- var package = new FakePackage ();
- package.AddFile (fileName);
- CreatePackageFiles (package);
- }
-
- void CreatePackageFilesWithTwoFiles (string fileName1, string fileName2)
- {
- var package = new FakePackage ();
- package.AddFile (fileName1);
- package.AddFile (fileName2);
- CreatePackageFiles (package);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellInitScript_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\init.ps1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOneCSharpFile_ReturnsFalse ()
- {
- CreatePackageFilesWithOneFile (@"src\test.cs");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsFalse (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellInitScriptWithDifferentParentFolder_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"parentfolder\init.ps1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellInitScriptInUpperCase_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\INIT.PS1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellInstallScript_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\install.ps1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellInstallScriptInUpperCase_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\INSTALL.PS1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellUninstallScript_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\uninstall.ps1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_HasOnePowerShellUninstallScriptInUpperCase_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\UNINSTALL.PS1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasAnyPackageScripts_SecondFileIsPowerShellInitScript_ReturnsTrue ()
- {
- CreatePackageFilesWithTwoFiles (@"src\test.cs", @"tools\init.ps1");
-
- bool hasScripts = packageFiles.HasAnyPackageScripts ();
-
- Assert.IsTrue (hasScripts);
- }
-
- [Test]
- public void HasUninstallPackageScript_HasOnePowerShellUninstallScript_ReturnsTrue ()
- {
- CreatePackageFilesWithOneFile (@"tools\uninstall.ps1");
-
- bool hasScript = packageFiles.HasUninstallPackageScript ();
-
- Assert.IsTrue (hasScript);
- }
-
- [Test]
- public void HasUninstallPackageScript_HasOneCSharpFile_ReturnsFalse ()
- {
- CreatePackageFilesWithOneFile (@"tools\test.cs");
-
- bool hasScript = packageFiles.HasUninstallPackageScript ();
-
- Assert.IsFalse (hasScript);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageFromRepositoryTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageFromRepositoryTests.cs deleted file mode 100644 index a0ad251140..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageFromRepositoryTests.cs +++ /dev/null @@ -1,480 +0,0 @@ -//
-// PackageFromRepositoryTests.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 System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageFromRepositoryTests
- {
- FakePackage fakePackage;
- TestablePackageFromRepository package;
- FakePackageRepository fakeRepository;
-
- void CreatePackage ()
- {
- package = new TestablePackageFromRepository ();
- fakePackage = package.FakePackagePassedToConstructor;
- fakeRepository = package.FakePackageRepositoryPassedToConstructor;
- }
-
- [Test]
- public void Repository_PackageCreatedWithSourceRepository_ReturnsSourceRepository ()
- {
- CreatePackage ();
- IPackageRepository repository = package.Repository;
-
- Assert.AreEqual (fakeRepository, repository);
- }
-
- [Test]
- public void AssemblyReferences_WrappedPackageHasOneAssemblyReference_ReturnsOneAssemblyReference ()
- {
- CreatePackage ();
- fakePackage.AssemblyReferenceList.Add (new FakePackageAssemblyReference ());
-
- IEnumerable<IPackageAssemblyReference> assemblyReferences = package.AssemblyReferences;
- List<IPackageAssemblyReference> expectedAssemblyReferences = fakePackage.AssemblyReferenceList;
-
- CollectionAssert.AreEqual (expectedAssemblyReferences, assemblyReferences);
- }
-
- [Test]
- public void Id_WrappedPackageIdIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Id = "Test";
- string id = package.Id;
-
- Assert.AreEqual ("Test", id);
- }
-
- [Test]
- public void Version_WrappedPackageVersionIsOnePointOne_ReturnsOnePointOne ()
- {
- CreatePackage ();
- var expectedVersion = new SemanticVersion ("1.1");
- fakePackage.Version = expectedVersion;
- SemanticVersion version = package.Version;
-
- Assert.AreEqual (expectedVersion, version);
- }
-
- [Test]
- public void Title_WrappedPackageTitleIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Title = "Test";
- string title = package.Title;
-
- Assert.AreEqual ("Test", title);
- }
-
- [Test]
- public void Authors_WrappedPackageHasOneAuthor_ReturnsOneAuthor ()
- {
- CreatePackage ();
- fakePackage.AuthorsList.Add ("Author1");
-
- IEnumerable<string> authors = package.Authors;
- List<string> expectedAuthors = fakePackage.AuthorsList;
-
- CollectionAssert.AreEqual (expectedAuthors, authors);
- }
-
- [Test]
- public void Owners_WrappedPackageHasOneOwner_ReturnsOneOwner ()
- {
- CreatePackage ();
- fakePackage.OwnersList.Add ("Owner1");
-
- IEnumerable<string> owners = package.Owners;
- List<string> expectedOwners = fakePackage.OwnersList;
-
- CollectionAssert.AreEqual (expectedOwners, owners);
- }
-
- [Test]
- public void IconUrl_WrappedPackageIconUrlIsHttpMonoDevelopNet_ReturnsHttpMonoDevelopNet ()
- {
- CreatePackage ();
- var expectedUrl = new Uri ("http://monodevelop.net");
- fakePackage.IconUrl = expectedUrl;
- Uri url = package.IconUrl;
-
- Assert.AreEqual (expectedUrl, url);
- }
-
- [Test]
- public void LicenseUrl_WrappedPackageLicenseUrlIsHttpMonoDevelopNet_ReturnsHttpMonoDevelopNet ()
- {
- CreatePackage ();
- var expectedUrl = new Uri ("http://monodevelop.net");
- fakePackage.LicenseUrl = expectedUrl;
- Uri url = package.LicenseUrl;
-
- Assert.AreEqual (expectedUrl, url);
- }
-
- [Test]
- public void ProjectUrl_WrappedPackageProjectUrlIsHttpMonoDevelopNet_ReturnsHttpMonoDevelopNet ()
- {
- CreatePackage ();
- var expectedUrl = new Uri ("http://monodevelop.net");
- fakePackage.ProjectUrl = expectedUrl;
- Uri url = package.ProjectUrl;
-
- Assert.AreEqual (expectedUrl, url);
- }
-
- [Test]
- public void ReportAbuseUrl_WrappedPackageReportAbuseUrlIsHttpMonoDevelopNet_ReturnsHttpMonoDevelopNet ()
- {
- CreatePackage ();
- var expectedUrl = new Uri ("http://monodevelop.net");
- fakePackage.ReportAbuseUrl = expectedUrl;
- Uri url = package.ReportAbuseUrl;
-
- Assert.AreEqual (expectedUrl, url);
- }
-
- [Test]
- public void RequiresLicenseAcceptance_WrappedPackageRequiresLicenseAcceptanceIsTrue_ReturnsTrue ()
- {
- CreatePackage ();
- fakePackage.RequireLicenseAcceptance = true;
-
- Assert.IsTrue (package.RequireLicenseAcceptance);
- }
-
- [Test]
- public void Description_WrappedPackageDescriptionIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Description = "Test";
- string description = package.Description;
-
- Assert.AreEqual ("Test", description);
- }
-
- [Test]
- public void Summary_WrappedPackageSummaryIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Summary = "Test";
- string summary = package.Summary;
-
- Assert.AreEqual ("Test", summary);
- }
-
- [Test]
- public void Language_WrappedPackageLanguageIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Language = "Test";
- string language = package.Language;
-
- Assert.AreEqual ("Test", language);
- }
-
- [Test]
- public void Tags_WrappedPackageTagsIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Tags = "Test";
- string tags = package.Tags;
-
- Assert.AreEqual ("Test", tags);
- }
-
- [Test]
- public void FrameworkAssemblies_WrappedPackageHasOneFrameworkAssembly_ReturnsOneFrameworkAssembly ()
- {
- CreatePackage ();
- fakePackage.FrameworkAssembliesList.Add (new FrameworkAssemblyReference ("System.Xml"));
-
- IEnumerable<FrameworkAssemblyReference> assemblies = package.FrameworkAssemblies;
- IEnumerable<FrameworkAssemblyReference> expectedAssemblies = fakePackage.FrameworkAssemblies;
-
- CollectionAssert.AreEqual (expectedAssemblies, assemblies);
- }
-
- [Test]
- public void Dependencies_WrappedPackageHasOneDependency_ReturnsOneDependency ()
- {
- CreatePackage ();
- fakePackage.AddDependency ("Test");
-
- IEnumerable<PackageDependency> dependencies = package.Dependencies;
-
- CollectionAssert.AreEqual (fakePackage.DependenciesList, dependencies);
- }
-
- [Test]
- public void GetFiles_WrappedPackageHasOneFile_ReturnsOneFile ()
- {
- CreatePackage ();
- fakePackage.FilesList.Add (new PhysicalPackageFile ());
-
- IEnumerable<IPackageFile> files = package.GetFiles ();
- IEnumerable<IPackageFile> expectedFiles = fakePackage.FilesList;
-
- CollectionAssert.AreEqual (expectedFiles, files);
- }
-
- [Test]
- public void DownloadCount_WrappedPackageDownloadCountIsTen_ReturnsTen ()
- {
- CreatePackage ();
- fakePackage.DownloadCount = 10;
- int count = package.DownloadCount;
-
- Assert.AreEqual (10, count);
- }
-
- [Test]
- public void GetStream_WrappedPackageHasStream_ReturnsWrappedPackageStream ()
- {
- CreatePackage ();
- var expectedStream = new MemoryStream ();
- fakePackage.Stream = expectedStream;
-
- Stream stream = package.GetStream ();
-
- Assert.AreEqual (expectedStream, stream);
- }
-
- [Test]
- public void HasDependencies_WrappedPackageHasNoDependencies_ReturnsFalse ()
- {
- CreatePackage ();
- fakePackage.DependenciesList.Clear ();
- bool result = package.HasDependencies;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void HasDependencies_WrappedPackageHasOneDependency_ReturnsTrue ()
- {
- CreatePackage ();
- fakePackage.AddDependency ("Test");
- bool result = package.HasDependencies;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void LastUpdated_PackageWrapsDataServicePackageThatHasLastUpdatedDateOffset_ReturnsDateFromDataServicePackage ()
- {
- CreatePackage ();
- var expectedDateTime = new DateTime (2011, 1, 2);
- package.DateTimeOffsetToReturnFromGetDataServicePackageLastUpdated = new DateTimeOffset (expectedDateTime);
-
- DateTime? lastUpdated = package.LastUpdated;
-
- Assert.AreEqual (expectedDateTime, lastUpdated.Value);
- }
-
- [Test]
- public void LastUpdated_PackageWrapsPackageThatDoesNotHaveLastUpdatedDateOffset_ReturnsNullDate ()
- {
- CreatePackage ();
- package.DateTimeOffsetToReturnFromGetDataServicePackageLastUpdated = null;
-
- DateTime? lastUpdated = package.LastUpdated;
-
- Assert.IsFalse (lastUpdated.HasValue);
- }
-
- [Test]
- public void IsLatestVersion_WrappedPackageIsNotLatestVersion_ReturnsFalse ()
- {
- CreatePackage ();
- fakePackage.IsLatestVersion = false;
- bool result = package.IsLatestVersion;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void IsLatestVersion_WrappedPackageHasOneDependency_ReturnsTrue ()
- {
- CreatePackage ();
- fakePackage.IsLatestVersion = true;
- bool result = package.IsLatestVersion;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Published_PackageWrapsPackageThatHasPublishedDateOffset_ReturnsDateTimeOffsetFromWrappedPackage ()
- {
- CreatePackage ();
- var dateTime = new DateTime (2011, 1, 2);
- var expectedDateTimeOffset = new DateTimeOffset (dateTime);
- fakePackage.Published = expectedDateTimeOffset;
-
- DateTimeOffset? published = package.Published;
-
- Assert.AreEqual (expectedDateTimeOffset, published.Value);
- }
-
- [Test]
- public void Copyright_WrappedPackageCopyrightIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.Copyright = "Test";
- string copyright = package.Copyright;
-
- Assert.AreEqual ("Test", copyright);
- }
-
- [Test]
- public void ReleaseNotes_WrappedPackageReleaseNotesIsTest_ReturnsTest ()
- {
- CreatePackage ();
- fakePackage.ReleaseNotes = "Test";
- string releaseNotes = package.ReleaseNotes;
-
- Assert.AreEqual ("Test", releaseNotes);
- }
-
- [Test]
- public void IsAbsoluteLatestVersion_WrappedPackageIsAbsoluteLatestVersion_ReturnsTrue ()
- {
- CreatePackage ();
- fakePackage.IsAbsoluteLatestVersion = true;
- bool result = package.IsAbsoluteLatestVersion;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Listed_WrappedPackageIsListed_ReturnsTrue ()
- {
- CreatePackage ();
- fakePackage.Listed = true;
- bool result = package.Listed;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void DependencySets_WrappedPackageIsListed_ReturnsTrue ()
- {
- CreatePackage ();
- fakePackage.AddDependency ("Test");
- List<PackageDependencySet> expectedDependencies = fakePackage.DependencySets.ToList ();
-
- List<PackageDependencySet> dependencies = package.DependencySets.ToList ();
-
- Assert.AreEqual (1, dependencies.Count);
- Assert.AreEqual (expectedDependencies [0].Dependencies, dependencies [0].Dependencies);
- }
-
- [Test]
- public void GetSupportedFrameworks_OneFramework_ReturnsOneFramework ()
- {
- CreatePackage ();
- FrameworkName expectedFramework = fakePackage.AddSupportedFramework (".NET Framework, Version=4.0");
-
- List<FrameworkName> supportedFrameworks = package.GetSupportedFrameworks ().ToList ();
-
- Assert.AreEqual (1, supportedFrameworks.Count);
- Assert.AreEqual (expectedFramework, supportedFrameworks [0]);
- }
-
- [Test]
- public void ToString_PackageHasIdAndVersion_ReturnsWrappedPackageToString ()
- {
- CreatePackage ();
- fakePackage.Id = "MyPackage";
- fakePackage.Version = new SemanticVersion ("1.1");
-
- string result = package.ToString ();
-
- Assert.AreEqual ("MyPackage 1.1", result);
- }
-
- [Test]
- public void MinClientVersion_PackageHasMinClientVersion_ReturnsWrappedPackageMinClientVersion ()
- {
- CreatePackage ();
- var expectedVersion = new Version ("1.1");
- fakePackage.MinClientVersion = expectedVersion;
-
- Version version = package.MinClientVersion;
-
- Assert.AreEqual (expectedVersion, version);
- }
-
- [Test]
- public void PackageAssemblyReferences_PackageHasOnePackageAssemblyReference_ReturnsWrappedPackagePackageAssemblyReferences ()
- {
- CreatePackage ();
- fakePackage.AddPackageReferences ("Test");
- List<PackageReferenceSet> expectedReferences = fakePackage.PackageAssemblyReferences.ToList ();
-
- List<PackageReferenceSet> result = package.PackageAssemblyReferences.ToList ();
-
- Assert.AreEqual (expectedReferences, result);
- }
-
- [Test]
- public void DevelopmentDependency_PackageHasDevelopmentDependencySetToTrue_ReturnsWrappedPackageDevelopmentDependency ()
- {
- CreatePackage ();
- fakePackage.DevelopmentDependency = true;
-
- bool dependency = package.DevelopmentDependency;
-
- Assert.IsTrue (dependency);
- }
-
- [Test]
- public void ExtractPath_WrappedPackage_WrappedPackageExtractContentsCalled ()
- {
- CreatePackage ();
- var expectedFileSystem = new FakeFileSystem ();
- string expectedPath = @"d:\projects\test\packages";
-
- package.ExtractContents (expectedFileSystem, expectedPath);
-
- Assert.AreEqual (expectedFileSystem, fakePackage.FileSystemPassedToExtractContents);
- Assert.AreEqual (expectedPath, fakePackage.ExtractPathPassedToExtractContents);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementEventsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementEventsTests.cs index 8327d86530..858f3f7fdb 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementEventsTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementEventsTests.cs @@ -25,11 +25,8 @@ // THE SOFTWARE.
using System;
-using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
+using NuGet.ProjectManagement;
using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
namespace MonoDevelop.PackageManagement.Tests
{
@@ -37,20 +34,12 @@ namespace MonoDevelop.PackageManagement.Tests public class PackageManagementEventsTests
{
PackageManagementEvents events;
- List<FakePackage> packages;
void CreateEvents ()
{
- packages = new List<FakePackage> ();
events = new PackageManagementEvents ();
}
- PackageManagementSelectedProjects CreateSelectedProjects ()
- {
- var solution = new FakePackageManagementSolution ();
- return new PackageManagementSelectedProjects (solution);
- }
-
[Test]
public void OnPackageOperationsStarting_OneEventSubscriber_PackageOperationsStartingFired ()
{
@@ -116,156 +105,13 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void OnAcceptLicenses_OneEventSubscriber_EventArgsHasPackages ()
- {
- CreateEvents ();
- IEnumerable<IPackage> packages = null;
- events.AcceptLicenses += (sender, e) => packages = e.Packages;
-
- var expectedPackages = new FakePackage[] {
- new FakePackage ("A"),
- new FakePackage ("B")
- };
- events.OnAcceptLicenses (expectedPackages);
-
- Assert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void OnAcceptLicenses_OneEventSubscriber_SenderIsPackageEvents ()
- {
- CreateEvents ();
- object eventSender = null;
- events.AcceptLicenses += (sender, e) => eventSender = sender;
- events.OnAcceptLicenses (packages);
-
- Assert.AreEqual (events, eventSender);
- }
-
- [Test]
- public void OnAcceptLicenses_NoEventSubscribers_NullReferenceExceptionIsNotThrown ()
- {
- CreateEvents ();
- Assert.DoesNotThrow (() => events.OnAcceptLicenses (packages));
- }
-
- [Test]
- public void OnAcceptLicenses_NoEventSubscribers_ReturnsTrue ()
- {
- CreateEvents ();
- bool result = events.OnAcceptLicenses (packages);
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void OnAcceptLicenses_EventArgIsAcceptedIsSetToFalse_ReturnsFalse ()
- {
- CreateEvents ();
- events.AcceptLicenses += (sender, e) => e.IsAccepted = false;
- bool result = events.OnAcceptLicenses (packages);
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void OnAcceptLicenses_EventArgIsAcceptedIsSetToTrue_ReturnsTrue ()
- {
- CreateEvents ();
- events.AcceptLicenses += (sender, e) => e.IsAccepted = true;
- bool result = events.OnAcceptLicenses (packages);
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void OnParentPackageInstalled_OneEventSubscriber_EventArgsHasPackage ()
- {
- CreateEvents ();
- IPackage package = null;
- IPackageManagementProject project = null;
- events.ParentPackageInstalled += (sender, e) => {
- package = e.Package;
- project = e.Project;
- };
-
- var expectedPackage = new FakePackage ("Test");
- var expectedProject = new FakePackageManagementProject ();
- events.OnParentPackageInstalled (expectedPackage, expectedProject);
-
- Assert.AreEqual (expectedPackage, package);
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void OnParentPackageInstalled_OneEventSubscriber_SenderIsPackageManagementEvents ()
- {
- CreateEvents ();
- object eventSender = null;
- events.ParentPackageInstalled += (sender, e) => eventSender = sender;
-
- var package = new FakePackage ("Test");
- events.OnParentPackageInstalled (package, null);
-
- Assert.AreEqual (events, eventSender);
- }
-
- [Test]
- public void OnParentPackageInstalled_NoEventSubscribers_NullReferenceExceptionIsNotThrown ()
- {
- CreateEvents ();
- var package = new FakePackage ("Test");
- Assert.DoesNotThrow (() => events.OnParentPackageInstalled (package, null));
- }
-
- [Test]
- public void OnParentPackageUninstalled_OneEventSubscriber_EventArgsHasPackage ()
- {
- CreateEvents ();
- IPackage package = null;
- IPackageManagementProject project = null;
- events.ParentPackageUninstalled += (sender, e) => {
- package = e.Package;
- project = e.Project;
- };
-
- var expectedPackage = new FakePackage ("Test");
- var expectedProject = new FakePackageManagementProject ();
- events.OnParentPackageUninstalled (expectedPackage, expectedProject);
-
- Assert.AreEqual (expectedPackage, package);
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void OnParentPackageUninstalled_OneEventSubscriber_SenderIsPackageManagementEvents ()
- {
- CreateEvents ();
- object eventSender = null;
- events.ParentPackageUninstalled += (sender, e) => eventSender = sender;
-
- var package = new FakePackage ("Test");
- events.OnParentPackageUninstalled (package, null);
-
- Assert.AreEqual (events, eventSender);
- }
-
- [Test]
- public void OnParentPackageUninstalled_NoEventSubscribers_NullReferenceExceptionIsNotThrown ()
- {
- CreateEvents ();
- var package = new FakePackage ("Test");
- Assert.DoesNotThrow (() => events.OnParentPackageUninstalled (package, null));
- }
-
- [Test]
public void OnPackageOperationMessageLogged_OneEventSubscriber_SenderIsPackageManagementEvents ()
{
CreateEvents ();
object eventSender = null;
events.PackageOperationMessageLogged += (sender, e) => eventSender = sender;
- events.OnPackageOperationMessageLogged (MessageLevel.Info, "Test");
+ events.OnPackageOperationMessageLogged (NuGet.MessageLevel.Info, "Test");
Assert.AreEqual (events, eventSender);
}
@@ -274,7 +120,7 @@ namespace MonoDevelop.PackageManagement.Tests public void OnPackageOperationMessageLogged_NoEventSubscribers_NullReferenceExceptionIsNotThrown ()
{
CreateEvents ();
- Assert.DoesNotThrow (() => events.OnPackageOperationMessageLogged (MessageLevel.Info, "Test"));
+ Assert.DoesNotThrow (() => events.OnPackageOperationMessageLogged (NuGet.MessageLevel.Info, "Test"));
}
[Test]
@@ -284,9 +130,9 @@ namespace MonoDevelop.PackageManagement.Tests PackageOperationMessageLoggedEventArgs eventArgs = null;
events.PackageOperationMessageLogged += (sender, e) => eventArgs = e;
- events.OnPackageOperationMessageLogged (MessageLevel.Info, "Test");
+ events.OnPackageOperationMessageLogged (NuGet.MessageLevel.Info, "Test");
- Assert.AreEqual (MessageLevel.Info, eventArgs.Message.Level);
+ Assert.AreEqual (NuGet.MessageLevel.Info, eventArgs.Message.Level);
}
[Test]
@@ -297,7 +143,7 @@ namespace MonoDevelop.PackageManagement.Tests events.PackageOperationMessageLogged += (sender, e) => eventArgs = e;
string format = "Test {0}";
- events.OnPackageOperationMessageLogged (MessageLevel.Info, format, "B");
+ events.OnPackageOperationMessageLogged (NuGet.MessageLevel.Info, format, "B");
string message = eventArgs.Message.ToString ();
@@ -306,72 +152,6 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void OnSelectProjects_OneEventSubscriber_EventArgsHasSelectedProjects ()
- {
- CreateEvents ();
- IEnumerable<IPackageManagementSelectedProject> selectedProjects = null;
- events.SelectProjects += (sender, e) => selectedProjects = e.SelectedProjects;
-
- var expectedSelectedProjects = new List<IPackageManagementSelectedProject> ();
- events.OnSelectProjects (expectedSelectedProjects);
-
- Assert.AreEqual (expectedSelectedProjects, selectedProjects);
- }
-
- [Test]
- public void OnSelectProjects_OneEventSubscriber_SenderIsPackageEvents ()
- {
- CreateEvents ();
- object eventSender = null;
- events.SelectProjects += (sender, e) => eventSender = sender;
- var selectedProjects = new List<IPackageManagementSelectedProject> ();
- events.OnSelectProjects (selectedProjects);
-
- Assert.AreEqual (events, eventSender);
- }
-
- [Test]
- public void OnSelectProjects_NoEventSubscribers_NullReferenceExceptionIsNotThrown ()
- {
- CreateEvents ();
- var selectedProjects = new List<IPackageManagementSelectedProject> ();
-
- Assert.DoesNotThrow (() => events.OnSelectProjects (selectedProjects));
- }
-
- [Test]
- public void OnSelectProjects_NoEventSubscribers_ReturnsTrue ()
- {
- CreateEvents ();
- var selectedProjects = new List<IPackageManagementSelectedProject> ();
- bool result = events.OnSelectProjects (selectedProjects);
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void OnSelectProjects_EventArgIsAcceptedIsSetToFalse_ReturnsFalse ()
- {
- CreateEvents ();
- events.SelectProjects += (sender, e) => e.IsAccepted = false;
- var selectedProjects = new List<IPackageManagementSelectedProject> ();
- bool result = events.OnSelectProjects (selectedProjects);
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void OnSelectProjects_EventArgIsAcceptedIsSetToTrue_ReturnsTrue ()
- {
- CreateEvents ();
- events.SelectProjects += (sender, e) => e.IsAccepted = true;
- var selectedProjects = new List<IPackageManagementSelectedProject> ();
- bool result = events.OnSelectProjects (selectedProjects);
-
- Assert.IsTrue (result);
- }
-
- [Test]
public void OnResolveFileConflict_OneEventSubscriber_SenderIsPackageEvents ()
{
CreateEvents ();
@@ -401,61 +181,26 @@ namespace MonoDevelop.PackageManagement.Tests events.ResolveFileConflict += (sender, e) => eventArgs = e;
events.OnResolveFileConflict ("message");
- Assert.AreEqual (FileConflictResolution.Ignore, eventArgs.Resolution);
+ Assert.AreEqual (FileConflictAction.Ignore, eventArgs.Resolution);
}
[Test]
public void OnResolveFileConflict_OneEventSubscriberWhichChangesResolutionToOverwrite_ReturnsOverwrite ()
{
CreateEvents ();
- events.ResolveFileConflict += (sender, e) => e.Resolution = FileConflictResolution.Overwrite;
- FileConflictResolution resolution = events.OnResolveFileConflict ("message");
+ events.ResolveFileConflict += (sender, e) => e.Resolution = FileConflictAction.Overwrite;
+ FileConflictAction resolution = events.OnResolveFileConflict ("message");
- Assert.AreEqual (FileConflictResolution.Overwrite, resolution);
+ Assert.AreEqual (FileConflictAction.Overwrite, resolution);
}
[Test]
public void OnResolveFileConflict_NoEventSubscribers_ReturnsIgnoreAll ()
{
CreateEvents ();
- FileConflictResolution resolution = events.OnResolveFileConflict ("message");
-
- Assert.AreEqual (FileConflictResolution.IgnoreAll, resolution);
- }
-
- [Test]
- public void OnParentPackagesUpdated_OneEventSubscriber_PackagesUpdatedEventFired ()
- {
- CreateEvents ();
- ParentPackagesOperationEventArgs eventArgs = null;
- events.ParentPackagesUpdated += (sender, e) => eventArgs = e;
- var packages = new FakePackage[] { new FakePackage ("Test") };
-
- events.OnParentPackagesUpdated (packages);
-
- Assert.AreEqual (packages, eventArgs.Packages);
- }
-
- [Test]
- public void OnParentPackagesUpdated_OneEventSubscriber_SenderIsPackageManagementEvents ()
- {
- CreateEvents ();
- object eventSender = null;
- events.ParentPackagesUpdated += (sender, e) => eventSender = sender;
- var packages = new FakePackage[] { new FakePackage ("Test") };
-
- events.OnParentPackagesUpdated (packages);
-
- Assert.AreEqual (events, eventSender);
- }
-
- [Test]
- public void OnParentPackagesUpdated_NoEventSubscribers_NullReferenceExceptionNotThrown ()
- {
- CreateEvents ();
- var packages = new FakePackage[] { new FakePackage ("Test") };
+ FileConflictAction resolution = events.OnResolveFileConflict ("message");
- Assert.DoesNotThrow (() => events.OnParentPackagesUpdated (packages));
+ Assert.AreEqual (FileConflictAction.IgnoreAll, resolution);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementLoggerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementLoggerTests.cs index 360cd4e72b..5e32828ff7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementLoggerTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementLoggerTests.cs @@ -77,33 +77,6 @@ namespace MonoDevelop.PackageManagement.Tests AssertOnPackageOperationMessageLoggedCalled (MessageLevel.Info, "Test C");
}
-
- [Test]
- public void ResolveFileConflict_MessagePassed_RaisesOnResolveFileConflictEvent ()
- {
- CreateLogger ();
- string message = null;
- packageManagementEvents.ResolveFileConflict += (sender, e) => {
- message = e.Message;
- };
-
- logger.ResolveFileConflict ("message");
-
- Assert.AreEqual ("message", message);
- }
-
- [Test]
- public void ResolveFileConflict_PackageManagementEventsResolveFileConflictReturnsIgnoreAll_ReturnsIgnoreAll ()
- {
- CreateLogger ();
- packageManagementEvents.ResolveFileConflict += (sender, e) => {
- e.Resolution = FileConflictResolution.IgnoreAll;
- };
-
- FileConflictResolution resolution = logger.ResolveFileConflict ("message");
-
- Assert.AreEqual (FileConflictResolution.IgnoreAll, resolution);
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementOptionsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementOptionsTests.cs deleted file mode 100644 index 6505eabb04..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementOptionsTests.cs +++ /dev/null @@ -1,584 +0,0 @@ -//
-// PackageManagementOptionsTests.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 System.Collections.Generic;
-using System.IO;
-using System.Text;
-using System.Xml;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageManagementOptionsTests
- {
- Properties properties;
- PackageManagementOptions options;
- FakeSettings fakeSettings;
- SettingsProvider settingsProvider;
- FakePackageManagementProjectService projectService;
-
- void CreateOptions ()
- {
- CreateProperties ();
- CreateSettings ();
- CreateOptions (properties, fakeSettings);
- }
-
- void CreateProperties ()
- {
- properties = new Properties ();
- }
-
- void CreateSettings ()
- {
- fakeSettings = new FakeSettings ();
- }
-
- void CreateOptions (Properties properties)
- {
- CreateSettings ();
- CreateOptions (properties, fakeSettings);
- }
-
- void CreateOptions (FakeSettings fakeSettings)
- {
- CreateProperties ();
- CreateSettingsProvider (fakeSettings);
- options = new PackageManagementOptions (properties, settingsProvider);
- }
-
- void CreateSettingsProvider (FakeSettings fakeSettings)
- {
- projectService = new FakePackageManagementProjectService ();
- settingsProvider = TestablePackageManagementOptions.CreateSettingsProvider (fakeSettings, projectService);
- }
-
- void ChangeSettingsReturnedBySettingsProvider ()
- {
- fakeSettings = new FakeSettings ();
- TestablePackageManagementOptions.ChangeSettingsReturnedBySettingsProvider (fakeSettings);
- }
-
- void CreateOptions (Properties properties, FakeSettings fakeSettings)
- {
- CreateSettingsProvider (fakeSettings);
- options = new PackageManagementOptions (properties, settingsProvider);
- }
-
- void SaveOptions ()
- {
- var builder = new StringBuilder ();
- var writer = new XmlTextWriter (new StringWriter (builder));
- properties.Write (writer);
- }
-
- RecentPackageInfo AddRecentPackageToOptions (string id, string version)
- {
- var recentPackage = new RecentPackageInfo (id, new SemanticVersion (version));
- options.RecentPackages.Add (recentPackage);
- return recentPackage;
- }
-
- void EnablePackageRestoreInSettings ()
- {
- fakeSettings.SetPackageRestoreSetting (true);
- }
-
- void OpenSolution ()
- {
- projectService.RaiseSolutionLoadedEvent ();
- }
-
- void CloseSolution ()
- {
- projectService.RaiseSolutionUnloadedEvent ();
- }
-
- [Test]
- public void PackageSources_OnePackageSourceInSettings_ContainsPackageSourceFromSettingsAndDefaultNuGetOrgFeed ()
- {
- CreateSettings ();
- var packageSource = new PackageSource ("http://codeplex.com", "Test");
- fakeSettings.AddFakePackageSource (packageSource);
- CreateOptions (fakeSettings);
-
- RegisteredPackageSources actualSources = options.PackageSources;
-
- List<PackageSource> expectedSources = new List<PackageSource> ();
- expectedSources.Add (packageSource);
- expectedSources.Add (RegisteredPackageSources.DefaultPackageSource);
-
- Assert.AreEqual (expectedSources, actualSources);
- }
-
- [Test]
- public void PackageSources_NoPackageSourceInSavedSettings_ContainsDefaultPackageSource ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
-
- List<PackageSource> expectedSources = new List<PackageSource> ();
- expectedSources.Add (RegisteredPackageSources.DefaultPackageSource);
-
- RegisteredPackageSources actualPackageSources = options.PackageSources;
-
- CollectionAssert.AreEqual (expectedSources, actualPackageSources);
- }
-
- [Test]
- public void PackageSources_NoPackageSourceInSavedSettings_DefaultPackageSourceIsNotAddedToSettings ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources packageSources = options.PackageSources;
-
- PackageSource packageSource = RegisteredPackageSources.DefaultPackageSource;
-
- bool result = fakeSettings.SavedSectionValueLists.ContainsKey (FakeSettings.PackageSourcesSectionName);
- Assert.IsFalse (result);
- Assert.IsNotNull (packageSource);
- }
-
- [Test]
- public void PackageSources_OnePackageSourceAdded_PackageSourceSavedInSettings ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources registeredPackageSources = options.PackageSources;
-
- var packageSource = new PackageSource ("http://codeplex.com", "Test");
- registeredPackageSources.Clear ();
- registeredPackageSources.Add (packageSource);
-
- var expectedSavedPackageSourceSettings = new List<SettingValue> ();
- expectedSavedPackageSourceSettings.Add (new SettingValue ("Test", "http://codeplex.com", false));
-
- IList<SettingValue> actualSavedPackageSourceSettings = fakeSettings.GetValuesPassedToSetValuesForPackageSourcesSection ();
-
- Assert.AreEqual (expectedSavedPackageSourceSettings, actualSavedPackageSourceSettings);
- }
-
- [Test]
- public void PackageSources_OnePackageSourceAdded_PackageSourcesSectionUpdated ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources registeredPackageSources = options.PackageSources;
-
- var packageSource = new PackageSource ("http://codeplex.com", "Test");
- registeredPackageSources.Clear ();
- registeredPackageSources.Add (packageSource);
-
- IList<SettingValue> settings = fakeSettings.SectionsUpdated [RegisteredPackageSourceSettings.PackageSourcesSectionName];
-
- Assert.AreEqual (1, settings.Count);
- Assert.AreEqual ("Test", settings[0].Key);
- Assert.AreEqual ("http://codeplex.com", settings[0].Value);
- }
-
- [Test]
- public void PackageSources_SettingsFilesDoesNotExistSoSettingsReturnsNullForPackageSourcesSection_DoesNotThrowException ()
- {
- CreateSettings ();
- fakeSettings.MakePackageSourceSectionsNull ();
- CreateOptions (fakeSettings);
-
- RegisteredPackageSources packageSources = null;
- Assert.DoesNotThrow (() => packageSources = options.PackageSources);
- }
-
- [Test]
- public void ActivePackageSource_NoInitialPropertiesSet_ReturnsNull ()
- {
- CreateOptions ();
- PackageSource actualSource = options.ActivePackageSource;
- Assert.IsNull (options.ActivePackageSource);
- }
-
- [Test]
- public void ActivePackageSource_SourceChanged_ActivePackageSourceUpdatedInSettings ()
- {
- CreateOptions ();
- var packageSource = new PackageSource ("http://monodevelop.com", "Test");
-
- options.ActivePackageSource = packageSource;
-
- var expectedSetting = new SettingValue ("Test", "http://monodevelop.com", false);
- SettingValue actualSetting = fakeSettings.GetValuePassedToSetValueForActivePackageSourceSection ();
-
- Assert.AreEqual (expectedSetting, actualSetting);
- }
-
- [Test]
- public void ActivePackageSource_ActivePackageSourceNonNullInSettings_ReturnsActivatePackageSourceInSavedSettings ()
- {
- CreateSettings ();
- var expectedSource = new PackageSource ("http://source-url", "Test");
- fakeSettings.SetFakeActivePackageSource (expectedSource);
- fakeSettings.AddFakePackageSource (expectedSource);
- CreateOptions (fakeSettings);
-
- PackageSource actualSource = options.ActivePackageSource;
-
- Assert.AreEqual (expectedSource, actualSource);
- }
-
- [Test]
- public void ActivePackageSource_SetToNullAfterHavingNonNullValue_ReturnsNull ()
- {
- CreateOptions ();
- var source = new PackageSource ("http://source-url", "Test");
- options.ActivePackageSource = source;
-
- options.ActivePackageSource = null;
-
- PackageSource actualSource = options.ActivePackageSource;
- Assert.IsNull (actualSource);
- }
-
- [Test]
- public void ActivePackageSource_ActivePackageSourceRemovedFromPackageSources_ActivePackageSourceSetToNull ()
- {
- CreateOptions ();
- var source = new PackageSource ("http://source-url", "Test");
- options.PackageSources.Add (source);
-
- var differentSource = new PackageSource ("http://different-url", "Test2");
- options.ActivePackageSource = differentSource;
-
- PackageSource activeSource = options.ActivePackageSource;
-
- Assert.IsNull (activeSource);
- }
-
- [Test]
- public void ActivePackageSource_ActivePackageSourceChanged_ActivePackageSourceSectionRemovedFromSettings ()
- {
- CreateOptions ();
-
- options.ActivePackageSource = new PackageSource ("http://monodevelop.com", "Test");
-
- bool sectionDeleted = fakeSettings.IsActivePackageSourceSectionDeleted;
-
- Assert.IsTrue (sectionDeleted);
- }
-
- [Test]
- public void ActivePackageSource_OneActivePackageSourceInSettingsAndActivePackageSourceSetToNull_ActivePackageSourceSectionRemoved ()
- {
- CreateSettings ();
- var expectedSource = new PackageSource ("http://source-url", "Test");
- fakeSettings.SetFakeActivePackageSource (expectedSource);
- fakeSettings.AddFakePackageSource (expectedSource);
- CreateOptions (fakeSettings);
-
- options.ActivePackageSource = null;
-
- bool sectionRemoved = fakeSettings.IsActivePackageSourceSectionDeleted;
-
- Assert.IsTrue (sectionRemoved);
- }
-
- [Test]
- public void ActivePackageSource_SettingsFilesDoesNotExistSoSettingsReturnsNullForActivePackageSourceSection_DoesNotThrowException ()
- {
- CreateSettings ();
- fakeSettings.MakeActivePackageSourceSectionNull ();
- CreateOptions (fakeSettings);
-
- PackageSource activePackageSource = null;
- Assert.DoesNotThrow (() => activePackageSource = options.ActivePackageSource);
- }
-
- [Test]
- public void RecentPackages_OneRecentPackageAddedAndOptionsReloadedFromSavedProperties_ContainsOneRecentPackageThatWasSavedPreviously ()
- {
- CreateOptions ();
- var package = new FakePackage ("Test");
- var recentPackage = new RecentPackageInfo (package);
- options.RecentPackages.Add (recentPackage);
- CreateOptions (properties);
-
- IList<RecentPackageInfo> recentPackages = options.RecentPackages;
-
- var expectedRecentPackages = new RecentPackageInfo[] {
- new RecentPackageInfo (package)
- };
-
- RecentPackageInfoCollectionAssert.AreEqual (expectedRecentPackages, recentPackages);
- }
-
- [Test]
- public void RecentPackages_SaveRecentPackages_DoesNotThrowInvalidOperationException ()
- {
- CreateOptions ();
- AddRecentPackageToOptions ("id", "1.0");
-
- Assert.DoesNotThrow (() => SaveOptions ());
- }
-
- [Test]
- public void ActivePackageSource_AggregatePackageSourceIsActivePackageSourceInSettings_ReturnsAggregatePackageSource ()
- {
- CreateSettings ();
- PackageSource expectedPackageSource = RegisteredPackageSourceSettings.AggregatePackageSource;
- fakeSettings.SetFakeActivePackageSource (expectedPackageSource);
- CreateOptions (fakeSettings);
-
- PackageSource activePackageSource = options.ActivePackageSource;
-
- Assert.AreEqual (expectedPackageSource, activePackageSource);
- }
-
- [Test]
- public void PackageSources_OneEnabledPackageSourceInSettings_ContainsSingleEnabledPackageSourceFromSettings ()
- {
- CreateSettings ();
- var packageSource = new PackageSource ("http://codeplex.com", "Test") { IsEnabled = true };
- fakeSettings.AddFakePackageSource (packageSource);
- CreateOptions (fakeSettings);
-
- RegisteredPackageSources actualSources = options.PackageSources;
-
- Assert.IsTrue (actualSources [0].IsEnabled);
- }
-
- [Test]
- public void PackageSources_OneDisabledPackageSourceInSettings_ContainsSingleDisabledPackageSourceFromSettings ()
- {
- CreateSettings ();
- var packageSource = new PackageSource ("http://codeplex.com", "Test") { IsEnabled = false };
- fakeSettings.AddFakePackageSource (packageSource);
- fakeSettings.AddDisabledPackageSource (packageSource);
- CreateOptions (fakeSettings);
-
- RegisteredPackageSources actualSources = options.PackageSources;
-
- Assert.IsFalse (actualSources [0].IsEnabled);
- }
-
- [Test]
- public void PackageSources_OnePackageSourceAdded_DisabledPackageSourcesSectionDeletedFromSettings ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources registeredPackageSources = options.PackageSources;
-
- var packageSource = new PackageSource ("http://codeplex.com", "Test");
- registeredPackageSources.Clear ();
- registeredPackageSources.Add (packageSource);
-
- IList<SettingValue> settings = fakeSettings.SectionsUpdated[RegisteredPackageSourceSettings.DisabledPackageSourceSectionName];
-
- Assert.AreEqual (0, settings.Count);
- }
-
- [Test]
- public void PackageSources_OneDisabledPackageSourceAdded_DisabledPackageSourcesSectionSaved ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources registeredPackageSources = options.PackageSources;
-
- var packageSource = new PackageSource ("http://codeplex.com", "Test") { IsEnabled = false };
- registeredPackageSources.Clear ();
- registeredPackageSources.Add (packageSource);
-
- var expectedSavedPackageSourceSettings = new List<SettingValue> ();
- expectedSavedPackageSourceSettings.Add (new SettingValue (packageSource.Name, "true", false));
-
- IList<SettingValue> actualSavedPackageSourceSettings =
- fakeSettings.GetValuesPassedToSetValuesForDisabledPackageSourcesSection ();
- Assert.AreEqual (expectedSavedPackageSourceSettings, actualSavedPackageSourceSettings);
- }
-
- [Test]
- public void PackageSources_OneEnabledPackageSourceAdded_DisabledPackageSourcesSectionNotChanged ()
- {
- CreateSettings ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources registeredPackageSources = options.PackageSources;
-
- var packageSource = new PackageSource ("http://codeplex.com", "Test") { IsEnabled = true };
- registeredPackageSources.Clear ();
- registeredPackageSources.Add (packageSource);
-
- IList<SettingValue> actualSavedPackageSourceSettings =
- fakeSettings.GetValuesPassedToSetValuesForDisabledPackageSourcesSection ();
- Assert.AreEqual (0, actualSavedPackageSourceSettings.Count);
- }
-
- [Test]
- public void IsPackageRestoreEnabled_EnabledInSettings_ReturnsTrue ()
- {
- CreateSettings ();
- EnablePackageRestoreInSettings ();
- CreateOptions (fakeSettings);
-
- bool enabled = options.IsPackageRestoreEnabled;
-
- Assert.IsTrue (enabled);
- }
-
- [Test]
- public void IsPackageRestoreEnabled_PackageRestoreNotInSettings_ReturnsTrue ()
- {
- CreateOptions ();
-
- bool enabled = options.IsPackageRestoreEnabled;
-
- Assert.IsTrue (enabled);
- }
-
- [Test]
- public void IsPackageRestoreEnabled_NotInSettingsOriginallyButSetToTrue_PackageRestoreEnabledInSettings ()
- {
- CreateOptions ();
-
- options.IsPackageRestoreEnabled = true;
-
- SettingValue setting = fakeSettings.GetValuePassedToSetValueForPackageRestoreSection ();
-
- Assert.AreEqual ("enabled", setting.Key);
- Assert.AreEqual ("True", setting.Value);
- }
-
- [Test]
- public void IsPackageRestoreEnabled_OriginallyEnabledInSettingsButSetToTrue_PackageRestoreSectionIsNotDeletedFromSettings ()
- {
- CreateSettings ();
- EnablePackageRestoreInSettings ();
- CreateOptions (fakeSettings);
-
- options.IsPackageRestoreEnabled = false;
-
- bool deleted = fakeSettings.IsPackageRestoreSectionDeleted;
- Assert.IsFalse (deleted);
- }
-
- [Test]
- public void IsPackageRestoreEnabled_OriginallyEnabledInSettingsButSetToTrue_PackageRestoreIsFalseInSettings ()
- {
- CreateSettings ();
- EnablePackageRestoreInSettings ();
- CreateOptions (fakeSettings);
-
- options.IsPackageRestoreEnabled = false;
-
- SettingValue setting = fakeSettings.GetValuePassedToSetValueForPackageRestoreSection ();
- Assert.AreEqual ("False", setting.Value);
- }
-
- [Test]
- public void PackageSources_SolutionOpenedAfterInitialPackageSourcesLoaded_ContainsPackageSourceFromSolutionSpecificSettings ()
- {
- CreateSettings ();
- var packageSource = new PackageSource ("https://www.nuget.org/api/v2/", "Official NuGet Gallery");
- fakeSettings.AddFakePackageSource (packageSource);
- CreateOptions (fakeSettings);
- RegisteredPackageSources initialSources = options.PackageSources;
- var expectedInitialSources = new List<PackageSource> ();
- expectedInitialSources.Add (packageSource);
- ChangeSettingsReturnedBySettingsProvider ();
- packageSource = new PackageSource ("https://www.nuget.org/api/v2/", "Official NuGet Gallery");
- fakeSettings.AddFakePackageSource (packageSource);
- var expectedSources = new List<PackageSource> ();
- expectedSources.Add (packageSource);
- packageSource = new PackageSource ("http://codeplex.com", "ProjectSource");
- fakeSettings.AddFakePackageSource (packageSource);
- expectedSources.Add (packageSource);
- OpenSolution ();
-
- RegisteredPackageSources actualSources = options.PackageSources;
-
- Assert.AreEqual (expectedInitialSources, initialSources);
- Assert.AreEqual (expectedSources, actualSources);
- }
-
- [Test]
- public void PackageSources_SolutionClosedAfterInitialPackageSourcesLoaded_PackageSourcesReloaded ()
- {
- CreateSettings ();
- var packageSource = new PackageSource ("https://www.nuget.org/api/v2/", "Official NuGet Gallery");
- fakeSettings.AddFakePackageSource (packageSource);
- var expectedInitialSources = new List<PackageSource> ();
- expectedInitialSources.Add (packageSource);
- packageSource = new PackageSource ("http://projectsource.org", "ProjectSource");
- fakeSettings.AddFakePackageSource (packageSource);
- expectedInitialSources.Add (packageSource);
- OpenSolution ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources initialSources = options.PackageSources;
- ChangeSettingsReturnedBySettingsProvider ();
- packageSource = new PackageSource ("https://www.nuget.org/api/v2/", "Official NuGet Gallery");
- fakeSettings.AddFakePackageSource (packageSource);
- var expectedSources = new List<PackageSource> ();
- expectedSources.Add (packageSource);
- CloseSolution ();
-
- RegisteredPackageSources actualSources = options.PackageSources;
-
- Assert.AreEqual (expectedInitialSources, initialSources);
- Assert.AreEqual (expectedSources, actualSources);
- }
-
- [Test]
- public void PackageSources_SolutionClosedAfterInitialPackageSourcesLoaded_ActivePackageSourceReloaded ()
- {
- CreateSettings ();
- var packageSource = new PackageSource ("https://www.nuget.org/api/v2/", "Official NuGet Gallery");
- fakeSettings.AddFakePackageSource (packageSource);
- var expectedInitialSources = new List<PackageSource> ();
- expectedInitialSources.Add (packageSource);
- var initialActivePackageSource = new PackageSource ("http://projectsource.org", "ProjectSource");
- fakeSettings.AddFakePackageSource (initialActivePackageSource);
- fakeSettings.SetFakeActivePackageSource (initialActivePackageSource);
- expectedInitialSources.Add (initialActivePackageSource);
- OpenSolution ();
- CreateOptions (fakeSettings);
- RegisteredPackageSources actualInitialPackageSources = options.PackageSources;
- PackageSource actualInitialActivePackageSource = options.ActivePackageSource;
- ChangeSettingsReturnedBySettingsProvider ();
- var expectedActivePackageSource = new PackageSource ("https://www.nuget.org/api/v2/", "Official NuGet Gallery");
- fakeSettings.SetFakeActivePackageSource (expectedActivePackageSource);
- fakeSettings.AddFakePackageSource (expectedActivePackageSource);
- CloseSolution ();
-
- PackageSource actualSource = options.ActivePackageSource;
-
- Assert.AreEqual (initialActivePackageSource, actualInitialActivePackageSource);
- Assert.AreEqual (expectedActivePackageSource, actualSource);
- Assert.AreEqual (expectedInitialSources, actualInitialPackageSources);
- Assert.AreEqual (new PackageSource[] { expectedActivePackageSource }, options.PackageSources);
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementOptionsViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementOptionsViewModelTests.cs deleted file mode 100644 index 1f18cd7c90..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementOptionsViewModelTests.cs +++ /dev/null @@ -1,332 +0,0 @@ -//
-// PackageManagementOptionsViewModelTests.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NUnit.Framework;
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageManagementOptionsViewModelTests
- {
- PackageManagementOptionsViewModel viewModel;
- FakeRecentPackageRepository fakeRecentRepository;
- FakeMachinePackageCache fakeMachineCache;
- FakeProcess fakeProcess;
- List<string> propertiesChanged;
- PackageManagementOptions options;
- FakeSettings fakeSettings;
-
- void CreateRecentRepository ()
- {
- fakeRecentRepository = new FakeRecentPackageRepository ();
- }
-
- void CreateMachineCache ()
- {
- fakeMachineCache = new FakeMachinePackageCache ();
- }
-
- void CreateOptions ()
- {
- var properties = new Properties ();
- var projectService = new FakePackageManagementProjectService ();
- fakeSettings = new FakeSettings ();
- SettingsProvider settingsProvider = TestablePackageManagementOptions.CreateSettingsProvider (fakeSettings, projectService);
- options = new PackageManagementOptions (properties, settingsProvider);
- }
-
- void EnablePackageRestoreInOptions ()
- {
- fakeSettings.SetPackageRestoreSetting (true);
- }
-
- void DisablePackageRestoreInOptions ()
- {
- fakeSettings.SetPackageRestoreSetting (false);
- }
-
- void CreateViewModelUsingCreatedMachineCache ()
- {
- CreateRecentRepository ();
- CreateOptions ();
- fakeProcess = new FakeProcess ();
- CreateViewModel (options);
- }
-
- void CreateViewModelUsingCreatedRecentRepository ()
- {
- CreateMachineCache ();
- CreateOptions ();
- fakeProcess = new FakeProcess ();
- CreateViewModel (options);
- }
-
- void CreateViewModel (PackageManagementOptions options)
- {
- viewModel = new PackageManagementOptionsViewModel (options, fakeRecentRepository, fakeMachineCache, fakeProcess);
- }
-
- void AddPackageToRecentRepository ()
- {
- fakeRecentRepository.FakePackages.Add (new FakePackage ());
- fakeRecentRepository.HasRecentPackages = true;
- }
-
- void AddPackageToMachineCache ()
- {
- fakeMachineCache.FakePackages.Add (new FakePackage ());
- }
-
- void RecordPropertyChanges ()
- {
- propertiesChanged = new List<string> ();
- viewModel.PropertyChanged += (sender, e) => propertiesChanged.Add (e.PropertyName);
- }
-
- [Test]
- public void HasNoRecentPackages_RecentPackageRepositoryHasNoPackages_ReturnsTrue ()
- {
- CreateRecentRepository ();
- CreateViewModelUsingCreatedRecentRepository ();
- fakeRecentRepository.HasRecentPackages = false;
-
- bool hasPackages = viewModel.HasNoRecentPackages;
-
- Assert.IsTrue (hasPackages);
- }
-
- [Test]
- public void HasNoRecentPackages_RecentPackageRepositoryHasOnePackage_ReturnsFalse ()
- {
- CreateRecentRepository ();
- fakeRecentRepository.HasRecentPackages = true;
- AddPackageToRecentRepository ();
- CreateViewModelUsingCreatedRecentRepository ();
-
- bool hasPackages = viewModel.HasNoRecentPackages;
-
- Assert.IsFalse (hasPackages);
- }
-
- [Test]
- public void HasNoCachedPackages_MachinePackageCacheHasNoPackages_ReturnsTrue ()
- {
- CreateMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- bool hasPackages = viewModel.HasNoCachedPackages;
-
- Assert.IsTrue (hasPackages);
- }
-
- [Test]
- public void HasNoCachedPackages_MachinePackageCacheHasOnePackage_ReturnsFalse ()
- {
- CreateMachineCache ();
- AddPackageToMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- bool hasPackages = viewModel.HasNoCachedPackages;
-
- Assert.IsFalse (hasPackages);
- }
-
- [Test]
- public void ClearRecentPackagesCommandCanExecute_OneRecentPackage_CanExecuteReturnsTrue ()
- {
- CreateRecentRepository ();
- AddPackageToRecentRepository ();
- CreateViewModelUsingCreatedRecentRepository ();
-
- bool canExecute = viewModel.ClearRecentPackagesCommand.CanExecute (null);
-
- Assert.IsTrue (canExecute);
- }
-
- [Test]
- public void ClearRecentPackagesCommandCanExecute_NoRecentPackages_CanExecuteReturnsFalse ()
- {
- CreateRecentRepository ();
- CreateViewModelUsingCreatedRecentRepository ();
-
- bool canExecute = viewModel.ClearRecentPackagesCommand.CanExecute (null);
-
- Assert.IsFalse (canExecute);
- }
-
- [Test]
- public void ClearCachedPackagesCommandCanExecute_OneCachedPackage_CanExecuteReturnsTrue ()
- {
- CreateMachineCache ();
- AddPackageToMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- bool canExecute = viewModel.ClearCachedPackagesCommand.CanExecute (null);
-
- Assert.IsTrue (canExecute);
- }
-
- [Test]
- public void ClearCachedPackagesCommandCanExecute_NoCachedPackages_CanExecuteReturnsFalse ()
- {
- CreateMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- bool canExecute = viewModel.ClearCachedPackagesCommand.CanExecute (null);
-
- Assert.IsFalse (canExecute);
- }
-
- [Test]
- public void ClearCachedPackagesCommandExecute_OneCachedPackage_ClearsPackagesFromCache ()
- {
- CreateMachineCache ();
- AddPackageToMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- viewModel.ClearCachedPackagesCommand.Execute (null);
-
- Assert.IsTrue (fakeMachineCache.IsClearCalled);
- }
-
- [Test]
- public void ClearRecentPackagesCommandExecute_OneRecentPackage_ClearsPackages ()
- {
- CreateMachineCache ();
- AddPackageToRecentRepository ();
- CreateViewModelUsingCreatedRecentRepository ();
-
- viewModel.ClearRecentPackagesCommand.Execute (null);
-
- Assert.IsTrue (fakeRecentRepository.IsClearCalled);
- }
-
- [Test]
- public void ClearRecentPackages_OneRecentPackage_HasNoRecentPackagesIsTrue ()
- {
- CreateRecentRepository ();
- AddPackageToRecentRepository ();
- CreateViewModelUsingCreatedRecentRepository ();
-
- RecordPropertyChanges ();
- viewModel.ClearRecentPackages ();
- fakeRecentRepository.HasRecentPackages = false;
-
- bool hasPackages = viewModel.HasNoRecentPackages;
-
- Assert.IsTrue (hasPackages);
- }
-
- [Test]
- public void ClearCachedPackages_OneCachedPackage_HasNoCachedPackagesReturnsTrue ()
- {
- CreateMachineCache ();
- AddPackageToMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- RecordPropertyChanges ();
- viewModel.ClearCachedPackages ();
-
- bool hasPackages = viewModel.HasNoCachedPackages;
-
- Assert.IsTrue (hasPackages);
- }
-
- [Test]
- public void ClearRecentPackages_OneRecentPackage_HasNoRecentPackagesPropertyChangedEventFired ()
- {
- CreateRecentRepository ();
- AddPackageToRecentRepository ();
- CreateViewModelUsingCreatedMachineCache ();
-
- RecordPropertyChanges ();
- viewModel.ClearRecentPackages ();
-
- bool fired = propertiesChanged.Contains ("HasNoRecentPackages");
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void ClearCachedPackages_OneCachedPackage_HasNoCachedPackagesPropertyChangedEventFired ()
- {
- CreateMachineCache ();
- AddPackageToMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- RecordPropertyChanges ();
- viewModel.ClearCachedPackages ();
-
- bool fired = propertiesChanged.Contains ("HasNoCachedPackages");
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void BrowseCachedPackagesCommandCanExecute_OneCachedPackage_ReturnsTrue ()
- {
- CreateMachineCache ();
- AddPackageToMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- bool canExecute = viewModel.BrowseCachedPackagesCommand.CanExecute (null);
-
- Assert.IsTrue (canExecute);
- }
-
- [Test]
- public void BrowseCachedPackagesCommandCanExecute_NoCachedPackages_ReturnsFalse ()
- {
- CreateMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- bool canExecute = viewModel.BrowseCachedPackagesCommand.CanExecute (null);
-
- Assert.IsFalse (canExecute);
- }
-
- [Test]
- public void BrowseCachedPackagesCommandExecute_OneCachedPackage_StartsProcessToOpenMachineCacheFolder ()
- {
- CreateMachineCache ();
- CreateViewModelUsingCreatedMachineCache ();
-
- string expectedFileName = @"d:\projects\nugetpackages";
- fakeMachineCache.Source = expectedFileName;
-
- viewModel.BrowseCachedPackagesCommand.Execute (null);
-
- string fileName = fakeProcess.FileNamePassedToStart;
-
- Assert.AreEqual (expectedFileName, fileName);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementProjectTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementProjectTests.cs deleted file mode 100644 index d0ec929a40..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementProjectTests.cs +++ /dev/null @@ -1,846 +0,0 @@ -//
-// PackageManagementProjectTests.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 System.Collections.Generic;
-using System.Linq;
-
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageManagementProjectTests
- {
- FakePackageManagerFactory fakePackageManagerFactory;
- FakePackageRepository fakeSourceRepository;
- FakeDotNetProject fakeProject;
- PackageManagementProject project;
- FakeProjectManager fakeProjectManager;
- FakePackageManager fakePackageManager;
- PackageManagementEvents packageManagementEvents;
- FakeInstallPackageAction fakeInstallAction;
- FakeUninstallPackageAction fakeUninstallAction;
- FakeUpdatePackageAction fakeUpdateAction;
- UpdatePackagesAction updatePackagesAction;
-
- void CreateProject ()
- {
- fakeSourceRepository = new FakePackageRepository ();
- CreateProject (fakeSourceRepository);
- }
-
- void CreateProject (IPackageRepository sourceRepository)
- {
- fakePackageManagerFactory = new FakePackageManagerFactory ();
- fakePackageManager = fakePackageManagerFactory.FakePackageManager;
- fakeProjectManager = fakePackageManager.FakeProjectManager;
- fakeProject = new FakeDotNetProject ();
- packageManagementEvents = new PackageManagementEvents ();
-
- project = new PackageManagementProject (
- sourceRepository,
- fakeProject,
- packageManagementEvents,
- fakePackageManagerFactory);
- }
-
- FakeInstallPackageAction CreateFakeInstallAction ()
- {
- fakeInstallAction = new FakeInstallPackageAction ();
- return fakeInstallAction;
- }
-
- FakeUninstallPackageAction CreateFakeUninstallAction ()
- {
- fakeUninstallAction = new FakeUninstallPackageAction (project);
- return fakeUninstallAction;
- }
-
- FakeUpdatePackageAction CreateFakeUpdateAction ()
- {
- fakeUpdateAction = new FakeUpdatePackageAction (project);
- return fakeUpdateAction;
- }
-
- void CreateUpdatePackagesAction ()
- {
- updatePackagesAction = new UpdatePackagesAction (project, null);
- }
-
- [Test]
- public void IsInstalled_PackageIsInstalled_ReturnsTrue ()
- {
- CreateProject ();
- fakeProjectManager.IsInstalledReturnValue = true;
- var package = new FakePackage ("Test");
-
- bool installed = project.IsPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIsNotInstalled_ReturnsFalse ()
- {
- CreateProject ();
- fakeProjectManager.IsInstalledReturnValue = false;
- var package = new FakePackage ("Test");
-
- bool installed = project.IsPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIsInstalled_PackagePassedToProjectManager ()
- {
- CreateProject ();
- fakeProjectManager.IsInstalledReturnValue = false;
- var expectedPackage = new FakePackage ("Test");
-
- project.IsPackageInstalled (expectedPackage);
- IPackage actualPackage = fakeProjectManager.PackagePassedToIsInstalled;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Constructor_RepositoryAndProjectPassed_RepositoryUsedToCreatePackageManager ()
- {
- CreateProject ();
- IPackageRepository actualrepository = fakePackageManagerFactory.PackageRepositoryPassedToCreatePackageManager;
-
- Assert.AreEqual (fakeSourceRepository, actualrepository);
- }
-
- [Test]
- public void Constructor_RepositoryAndProjectPassed_ProjectUsedToCreatePackageManager ()
- {
- CreateProject ();
- var actualProject = fakePackageManagerFactory.ProjectPassedToCreateRepository;
-
- Assert.AreEqual (fakeProject, actualProject);
- }
-
- [Test]
- public void GetPackages_ProjectManagerLocalRepositoryHasTwoPackages_ReturnsTwoPackages ()
- {
- CreateProject ();
- FakePackageRepository repository = fakeProjectManager.FakeLocalRepository;
- FakePackage packageA = repository.AddFakePackage ("A");
- FakePackage packageB = repository.AddFakePackage ("B");
-
- IQueryable<IPackage> actualPackages = project.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- packageA,
- packageB
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, actualPackages);
- }
-
- [Test]
- public void GetInstallPackageOperations_IgnoreDependenciesIsTrue_DependenciesIgnoredWhenRetrievingPackageOperations ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeInstallAction ()
- .IgnoreDependencies = true;
-
- project.GetInstallPackageOperations (package, fakeInstallAction);
-
- Assert.IsTrue (fakePackageManager.IgnoreDependenciesPassedToGetInstallPackageOperations);
- }
-
- [Test]
- public void GetInstallPackageOperations_IgnoreDependenciesIsFalse_DependenciesNotIgnoredWhenRetrievingPackageOperations ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeInstallAction ()
- .IgnoreDependencies = false;
-
- project.GetInstallPackageOperations (package, fakeInstallAction);
-
- Assert.IsFalse (fakePackageManager.IgnoreDependenciesPassedToGetInstallPackageOperations);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackagePassed_PackageUsedToRetrievePackageOperations ()
- {
- CreateProject ();
- var expectedPackage = new FakePackage ();
- CreateFakeInstallAction ()
- .IgnoreDependencies = true;
-
- project.GetInstallPackageOperations (expectedPackage, fakeInstallAction);
-
- IPackage actualPackage = fakePackageManager.PackagePassedToGetInstallPackageOperations;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void GetInstallPackageOperations_PackagePassed_ReturnsPackageOperations ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeInstallAction ()
- .IgnoreDependencies = true;
-
- IEnumerable<PackageOperation> operations = project.GetInstallPackageOperations (package, fakeInstallAction);
-
- IEnumerable<PackageOperation> expectedOperations = fakePackageManager.PackageOperationsToReturnFromGetInstallPackageOperations;
-
- Assert.AreEqual (expectedOperations, operations);
- }
-
- [Test]
- public void Logger_SetLogger_LoggerOnPackageManagerIsSet ()
- {
- CreateProject ();
- var expectedLogger = new FakeLogger ();
-
- project.Logger = expectedLogger;
-
- Assert.AreEqual (expectedLogger, fakePackageManager.Logger);
- }
-
- [Test]
- public void Logger_GetLogger_LoggerOnPackageManagerIsReturned ()
- {
- CreateProject ();
-
- ILogger logger = project.Logger;
- ILogger expectedLogger = fakePackageManager.Logger;
-
- Assert.AreEqual (expectedLogger, logger);
- }
-
- [Test]
- public void InstallPackage_PackagePassed_PackageInstalled ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeInstallAction ()
- .Package = package;
-
- project.InstallPackage (package, fakeInstallAction);
-
- IPackage expectedPackage = fakePackageManager.PackagePassedToInstallPackage;
-
- Assert.AreEqual (expectedPackage, package);
- }
-
- [Test]
- public void InstallPackage_IgnoreDependenciesIsTrue_DependenciesAreIgnoredWhenPackageIsInstalled ()
- {
- CreateProject ();
- CreateFakeInstallAction ()
- .IgnoreDependencies = true;
- project.InstallPackage (null, fakeInstallAction);
-
- Assert.IsTrue (fakePackageManager.IgnoreDependenciesPassedToInstallPackage);
- }
-
- [Test]
- public void InstallPackage_IgnoreDependenciesIsFalse_DependenciesAreNotIgnoredWhenPackageIsInstalled ()
- {
- CreateProject ();
- CreateFakeInstallAction ()
- .IgnoreDependencies = false;
- project.InstallPackage (null, fakeInstallAction);
-
- Assert.IsFalse (fakePackageManager.IgnoreDependenciesPassedToInstallPackage);
- }
-
- [Test]
- public void InstallPackage_PackageOperationsPassed_PackageOperationsUsedToInstallPackage ()
- {
- CreateProject ();
- var expectedOperations = new List<PackageOperation> ();
- CreateFakeInstallAction ()
- .Operations = expectedOperations;
- project.InstallPackage (null, fakeInstallAction);
-
- IEnumerable<PackageOperation> actualOperations = fakePackageManager.PackageOperationsPassedToInstallPackage;
-
- Assert.AreEqual (expectedOperations, actualOperations);
- }
-
- [Test]
- public void SourceRepository_NewInstance_ReturnsRepositoryUsedToCreateInstance ()
- {
- CreateProject ();
- IPackageRepository repository = project.SourceRepository;
-
- Assert.AreEqual (fakeSourceRepository, repository);
- }
-
- [Test]
- public void UninstallPackage_PackagePassed_PackageUninstalled ()
- {
- CreateProject ();
- CreateFakeUninstallAction ();
- fakeUninstallAction.ForceRemove = true;
- fakeUninstallAction.RemoveDependencies = true;
- var package = new FakePackage ();
-
- project.UninstallPackage (package, fakeUninstallAction);
-
- IPackage expectedPackage = fakePackageManager.PackagePassedToUninstallPackage;
-
- Assert.AreEqual (expectedPackage, package);
- }
-
- [Test]
- public void UninstallPackage_ForceRemoveIsTrue_PackageUninstallIsForced ()
- {
- CreateProject ();
- CreateFakeUninstallAction ();
- fakeUninstallAction.ForceRemove = true;
- fakeUninstallAction.RemoveDependencies = false;
-
- project.UninstallPackage (null, fakeUninstallAction);
-
- Assert.IsTrue (fakePackageManager.ForceRemovePassedToUninstallPackage);
- }
-
- [Test]
- public void UninstallPackage_ForceRemoveIsFalse_PackageUninstallIsNotForced ()
- {
- CreateProject ();
- CreateFakeUninstallAction ();
- fakeUninstallAction.ForceRemove = false;
- fakeUninstallAction.RemoveDependencies = true;
-
- project.UninstallPackage (null, fakeUninstallAction);
-
- Assert.IsFalse (fakePackageManager.ForceRemovePassedToUninstallPackage);
- }
-
- [Test]
- public void UninstallPackage_RemoveDependenciesIsTrue_PackageDependenciesIsRemoved ()
- {
- CreateProject ();
- CreateFakeUninstallAction ();
- fakeUninstallAction.ForceRemove = false;
- fakeUninstallAction.RemoveDependencies = true;
-
- project.UninstallPackage (null, fakeUninstallAction);
-
- Assert.IsTrue (fakePackageManager.RemoveDependenciesPassedToUninstallPackage);
- }
-
- [Test]
- public void UninstallPackage_RemoveDependenciesIsFalse_PackageDependenciesNotRemoved ()
- {
- CreateProject ();
- CreateFakeUninstallAction ();
- fakeUninstallAction.ForceRemove = true;
- fakeUninstallAction.RemoveDependencies = false;
-
- project.UninstallPackage (null, fakeUninstallAction);
-
- Assert.IsFalse (fakePackageManager.RemoveDependenciesPassedToUninstallPackage);
- }
-
- [Test]
- public void UpdatePackage_PackagePassed_PackageUpdated ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeUpdateAction ()
- .UpdateDependencies = true;
-
- project.UpdatePackage (package, fakeUpdateAction);
-
- IPackage expectedPackage = fakePackageManager.PackagePassedToUpdatePackage;
-
- Assert.AreEqual (expectedPackage, package);
- }
-
- [Test]
- public void UpdatePackage_UpdateDependenciesIsTrue_DependenciesUpdatedWhenPackageIsUpdated ()
- {
- CreateProject ();
- CreateFakeUpdateAction ()
- .UpdateDependencies = true;
-
- project.UpdatePackage (null, fakeUpdateAction);
-
- Assert.IsTrue (fakePackageManager.UpdateDependenciesPassedToUpdatePackage);
- }
-
- [Test]
- public void UpdatePackage_UpdateDependenciesIsFalse_DependenciesAreNotUpdatedWhenPackageIsUpdated ()
- {
- CreateProject ();
- CreateFakeUpdateAction ()
- .UpdateDependencies = false;
-
- project.UpdatePackage (null, fakeUpdateAction);
-
- Assert.IsFalse (fakePackageManager.UpdateDependenciesPassedToUpdatePackage);
- }
-
- [Test]
- public void UpdatePackage_PackageOperationsPassed_PackageOperationsUsedToUpdatePackage ()
- {
- CreateProject ();
- var expectedOperations = new List<PackageOperation> ();
- CreateFakeUpdateAction ()
- .Operations = expectedOperations;
-
- project.UpdatePackage (null, fakeUpdateAction);
-
- IEnumerable<PackageOperation> actualOperations = fakePackageManager.PackageOperationsPassedToUpdatePackage;
-
- Assert.AreEqual (expectedOperations, actualOperations);
- }
-
- [Test]
- public void Logger_SetLogger_ProjectManagerUsesLogger ()
- {
- CreateProject ();
- ILogger expectedLogger = new NullLogger ();
- project.Logger = expectedLogger;
- ILogger actualLogger = fakePackageManager.ProjectManager.Logger;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void Logger_SetLogger_ProjectManagerProjectSystemUsesLogger ()
- {
- CreateProject ();
- ILogger expectedLogger = new NullLogger ();
- project.Logger = expectedLogger;
- ILogger actualLogger = fakePackageManager.ProjectManager.Project.Logger;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void Logger_SetLogger_PackageManagerFileSystemUsesLogger ()
- {
- CreateProject ();
- ILogger expectedLogger = new NullLogger ();
- project.Logger = expectedLogger;
- ILogger actualLogger = fakePackageManager.FileSystem.Logger;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void Logger_GetLogger_ReturnsLogger ()
- {
- CreateProject ();
- ILogger expectedLogger = new NullLogger ();
- project.Logger = expectedLogger;
- ILogger actualLogger = project.Logger;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void PackageInstalled_PackagerManagerPackageInstalledEventFired_EventFiresWithPackage ()
- {
- CreateProject ();
- PackageOperationEventArgs eventArgs = null;
- project.PackageInstalled += (sender, e) => eventArgs = e;
-
- var expectedEventArgs = new PackageOperationEventArgs (new FakePackage (), null, String.Empty);
- fakePackageManager.FirePackageInstalled (expectedEventArgs);
-
- Assert.AreEqual (expectedEventArgs, eventArgs);
- }
-
- [Test]
- public void PackageUninstalled_PackagerManagerPackageUninstalledEventFired_EventFiresWithPackage ()
- {
- CreateProject ();
- PackageOperationEventArgs eventArgs = null;
- project.PackageUninstalled += (sender, e) => eventArgs = e;
-
- var expectedEventArgs = new PackageOperationEventArgs (new FakePackage (), null, String.Empty);
- fakePackageManager.FirePackageUninstalled (expectedEventArgs);
-
- Assert.AreEqual (expectedEventArgs, eventArgs);
- }
-
- [Test]
- public void PackageReferenceAdded_ProjectManagerPackageReferenceAddedEventFired_EventFiresWithPackage ()
- {
- CreateProject ();
- PackageOperationEventArgs eventArgs = null;
- project.PackageReferenceAdded += (sender, e) => eventArgs = e;
-
- var expectedPackage = new FakePackage ();
- fakeProjectManager.FirePackageReferenceAdded (expectedPackage);
-
- Assert.AreEqual (expectedPackage, eventArgs.Package);
- }
-
- [Test]
- public void PackageReferenceRemoved_ProjectManagerPackageReferenceRemovedEventFired_EventFiresWithPackage ()
- {
- CreateProject ();
- PackageOperationEventArgs eventArgs = null;
- project.PackageReferenceRemoved += (sender, e) => eventArgs = e;
-
- var expectedPackage = new FakePackage ();
- fakeProjectManager.FirePackageReferenceRemoved (expectedPackage);
-
- Assert.AreEqual (expectedPackage, eventArgs.Package);
- }
-
- [Test]
- public void Name_MSBuildProjectNameIsSet_ReturnsMSBuildProjectName ()
- {
- CreateProject ();
- fakeProject.Name = "MyProject";
-
- string name = project.Name;
-
- Assert.AreEqual ("MyProject", name);
- }
-
- [Test]
- public void IsInstalled_PackageIdPassedAndPackageIsInstalled_ReturnsTrue ()
- {
- CreateProject ();
- fakeProjectManager.IsInstalledReturnValue = true;
-
- bool installed = project.IsPackageInstalled ("Test");
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIdPassedAndPackageIsNotInstalled_ReturnsFalse ()
- {
- CreateProject ();
- fakeProjectManager.IsInstalledReturnValue = false;
-
- bool installed = project.IsPackageInstalled ("Test");
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIdPassedPackageIsInstalled_PackageIdPassedToProjectManager ()
- {
- CreateProject ();
- fakeProjectManager.IsInstalledReturnValue = false;
-
- project.IsPackageInstalled ("Test");
- string id = fakeProjectManager.PackageIdPassedToIsInstalled;
-
- Assert.AreEqual ("Test", id);
- }
-
- [Test]
- public void GetPackagesInReverseDependencyOrder_TwoPackages_ReturnsPackagesFromProjectLocalRepositoryInCorrectOrder ()
- {
- CreateProject ();
- FakePackage packageA = fakeProjectManager.FakeLocalRepository.AddFakePackageWithVersion ("A", "1.0");
- FakePackage packageB = fakeProjectManager.FakeLocalRepository.AddFakePackageWithVersion ("B", "1.0");
-
- packageB.DependenciesList.Add (new PackageDependency ("A"));
-
- var expectedPackages = new FakePackage[] {
- packageB,
- packageA
- };
-
- IEnumerable<IPackage> packages = project.GetPackagesInReverseDependencyOrder ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void InstallPackage_AllowPrereleaseVersionsIsTrue_PrereleaseVersionsAreNotAllowedWhenPackageIsInstalled ()
- {
- CreateProject ();
- CreateFakeInstallAction ()
- .AllowPrereleaseVersions = false;
- project.InstallPackage (null, fakeInstallAction);
-
- Assert.IsFalse (fakePackageManager.AllowPrereleaseVersionsPassedToInstallPackage);
- }
-
- [Test]
- public void InstallPackage_AllowPrereleaseVersionsIsFalse_PrereleaseVersionsAreAllowedWhenPackageIsInstalled ()
- {
- CreateProject ();
- CreateFakeInstallAction ()
- .AllowPrereleaseVersions = true;
- project.InstallPackage (null, fakeInstallAction);
-
- Assert.IsTrue (fakePackageManager.AllowPrereleaseVersionsPassedToInstallPackage);
- }
-
- [Test]
- public void GetInstallPackageOperations_AllowPrereleaseVersionsIsTrue_PrereleaseVersionsAllowedWhenRetrievingPackageOperations ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeInstallAction ()
- .AllowPrereleaseVersions = true;
-
- project.GetInstallPackageOperations (package, fakeInstallAction);
-
- Assert.IsTrue (fakePackageManager.AllowPrereleaseVersionsPassedToGetInstallPackageOperations);
- }
-
- [Test]
- public void GetInstallPackageOperations_AllowPrereleaseVersionsIsFalse_PrereleaseVersionsNotAllowedWhenRetrievingPackageOperations ()
- {
- CreateProject ();
- var package = new FakePackage ();
- CreateFakeInstallAction ()
- .AllowPrereleaseVersions = false;
-
- project.GetInstallPackageOperations (package, fakeInstallAction);
-
- Assert.IsFalse (fakePackageManager.AllowPrereleaseVersionsPassedToGetInstallPackageOperations);
- }
-
- [Test]
- public void UpdatePackage_AllowPrereleaseVersionsIsTrue_PrereleaseVersionsNotAllowedWhenPackageIsUpdated ()
- {
- CreateProject ();
- CreateFakeUpdateAction ()
- .AllowPrereleaseVersions = true;
-
- project.UpdatePackage (null, fakeUpdateAction);
-
- Assert.IsTrue (fakePackageManager.AllowPrereleaseVersionsPassedToInstallPackage);
- }
-
- [Test]
- public void UpdatePackage_AllowPrereleaseVersionsIsFalse_PrereleaseVersionsNotAllowedWhenPackageIsUpdated ()
- {
- CreateProject ();
- CreateFakeUpdateAction ()
- .AllowPrereleaseVersions = false;
-
- project.UpdatePackage (null, fakeUpdateAction);
-
- Assert.IsFalse (fakePackageManager.AllowPrereleaseVersionsPassedToInstallPackage);
- }
-
- [Test]
- public void UpdatePackages_ActionHasOperationsAndPackages_ActionPassedToPackageManager ()
- {
- CreateProject ();
- CreateUpdatePackagesAction ();
-
- project.UpdatePackages (updatePackagesAction);
-
- Assert.AreEqual (updatePackagesAction, fakePackageManager.UpdatePackagesActionsPassedToUpdatePackages);
- }
-
- [Test]
- public void GetUpdatePackagesOperations_ActionPassed_ActionPassedToPackageManager ()
- {
- CreateProject ();
- CreateUpdatePackagesAction ();
- var expectedPackages = new FakePackage[] { new FakePackage ("Test") };
- updatePackagesAction.AddPackages (expectedPackages);
-
- project.GetUpdatePackagesOperations (updatePackagesAction.Packages, updatePackagesAction);
-
- Assert.AreEqual (updatePackagesAction, fakePackageManager.SettingsPassedToGetUpdatePackageOperations);
- Assert.AreEqual (expectedPackages, fakePackageManager.PackagesPassedToGetUpdatePackageOperations);
- }
-
- [Test]
- public void GetUpdatePackagesOperations_ActionPassed_PackageOperationsReturned ()
- {
- CreateProject ();
- CreateUpdatePackagesAction ();
- List<PackageOperation> expectedOperations = PackageOperationHelper.CreateListWithOneInstallOperationWithFile ("readme.txt");
- fakePackageManager.PackageOperationsToReturnFromGetUpdatePackageOperations = expectedOperations;
-
- IEnumerable<PackageOperation> operations = project.GetUpdatePackagesOperations (updatePackagesAction.Packages, updatePackagesAction);
-
- CollectionAssert.AreEqual (expectedOperations, operations);
- }
-
- [Test]
- public void RunPackageOperations_OneOperation_PackageOperationsRunByPackageManager ()
- {
- CreateProject ();
- CreateUpdatePackagesAction ();
- List<PackageOperation> expectedOperations = PackageOperationHelper.CreateListWithOneInstallOperationWithFile ("readme.txt");
-
- project.RunPackageOperations (expectedOperations);
-
- CollectionAssert.AreEqual (expectedOperations, fakePackageManager.PackageOperationsPassedToRunPackageOperations);
- }
-
- [Test]
- public void HasOlderPackageInstalled_TestPackage_PackagePassedToProjectManager ()
- {
- CreateProject ();
- CreateUpdatePackagesAction ();
- var expectedPackage = new FakePackage ("Test");
-
- project.HasOlderPackageInstalled (expectedPackage);
-
- Assert.AreEqual (expectedPackage, fakeProjectManager.PackagePassedToHasOlderPackageInstalled);
- }
-
- [Test]
- public void HasOlderPackageInstalled_PackageIsInstalled_ReturnsTrue ()
- {
- CreateProject ();
- fakeProjectManager.HasOlderPackageInstalledReturnValue = true;
- var package = new FakePackage ("Test");
-
- bool installed = project.HasOlderPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void HasOlderPackageInstalled_PackageIsNotInstalled_ReturnsFalse ()
- {
- CreateProject ();
- fakeProjectManager.HasOlderPackageInstalledReturnValue = false;
- var package = new FakePackage ("Test");
-
- bool installed = project.HasOlderPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void UpdatePackageReference_PackageAndUpdateActionPassed_BothPassedToPackageManager ()
- {
- CreateProject ();
- CreateUpdatePackagesAction ();
- var package = new FakePackage ("Test");
-
- project.UpdatePackageReference (package, updatePackagesAction);
-
- Assert.AreEqual (package, fakePackageManager.PackagePassedToUpdatePackageReference);
- Assert.AreEqual (updatePackagesAction, fakePackageManager.SettingsPassedToUpdatePackageReference);
- }
-
- [Test]
- public void Logger_SetLoggerWhenSourceRepositoryIsAggregateRepository_LoggerOnAggregateRepositoryIsSet ()
- {
- var aggregateRepository = new AggregateRepository (new FakePackageRepository [0]);
- CreateProject (aggregateRepository);
- var expectedLogger = new FakeLogger ();
-
- project.Logger = expectedLogger;
-
- Assert.AreEqual (expectedLogger, aggregateRepository.Logger);
- }
-
- [Test]
- public void GetPackageReferences_ProjectManagerHasOnePackageReference_ReturnsOnePackageReference ()
- {
- CreateProject ();
- fakeProjectManager.AddPackageReference ("MyPackage", "1.2.3.4");
-
- List<PackageReference> packageReferences = project.GetPackageReferences ().ToList ();
- PackageReference packageReference = packageReferences.FirstOrDefault ();
-
- Assert.AreEqual ("MyPackage", packageReference.Id);
- Assert.AreEqual ("1.2.3.4", packageReference.Version.ToString ());
- Assert.AreEqual (1, packageReferences.Count);
- }
-
- [Test]
- public void AnyUnrestoredPackages_LocalRepositoryHasPackagesForEachPackageReference_ReturnsFalse ()
- {
- CreateProject ();
- fakeProjectManager.AddPackageReference ("MyPackage", "1.2.3.4");
- fakeProjectManager.FakeLocalRepository.AddFakePackageWithVersion ("MyPackage", "1.2.3.4");
-
- bool result = project.AnyUnrestoredPackages ();
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void AnyUnrestoredPackages_LocalRepositoryHasNoPackagesAndProjectHasOnePackageReference_ReturnsTrue ()
- {
- CreateProject ();
- fakeProjectManager.AddPackageReference ("MyPackage", "1.2.3.4");
-
- bool result = project.AnyUnrestoredPackages ();
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void AnyUnrestoredPackages_LocalRepositoryHasDifferentPackageVersion_ReturnsTrue ()
- {
- CreateProject ();
- fakeProjectManager.AddPackageReference ("MyPackage", "1.2.3.4");
- fakeProjectManager.FakeLocalRepository.AddFakePackageWithVersion ("MyPackage", "1.0");
-
- bool result = project.AnyUnrestoredPackages ();
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void ConstraintProvider_LocalRepositoryDoesNotImplementIConstraintProvider_ReturnsNullConstraintProviderInstance ()
- {
- CreateProject ();
-
- IPackageConstraintProvider provider = project.ConstraintProvider;
-
- Assert.AreEqual (NullConstraintProvider.Instance, provider);
- }
-
- [Test]
- public void ConstraintProvider_LocalRepositoryImplementsIConstraintProvider_ReturnsLocalRepository ()
- {
- CreateProject ();
- var localRepository = new FakePackageRepositoryWithConstraintProvider ();
- fakeProjectManager.FakeLocalRepository = localRepository;
-
- IPackageConstraintProvider provider = project.ConstraintProvider;
-
- Assert.AreEqual (localRepository, provider);
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSelectedProjectTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSelectedProjectTests.cs deleted file mode 100644 index 77d06c2fad..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSelectedProjectTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -//
-// PackageManagementSelectedProjectTests.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 MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageManagementSelectedProjectTests
- {
- PackageManagementSelectedProject selectedProject;
- FakePackageManagementProject fakeProject;
-
- void CreateFakePackageManagementProject ()
- {
- fakeProject = new FakePackageManagementProject ();
- }
-
- void CreateSelectedProject (FakePackageManagementProject fakeProject)
- {
- selectedProject = new PackageManagementSelectedProject (fakeProject);
- }
-
- [Test]
- public void Name_PackageManagementProjectNameIsTest_ReturnsTest ()
- {
- CreateFakePackageManagementProject ();
- CreateSelectedProject (fakeProject);
- fakeProject.Name = "Test";
-
- string name = selectedProject.Name;
-
- Assert.AreEqual ("Test", name);
- }
-
- [Test]
- public void IsSelected_SelectedNotSpecifiedInConstructor_ReturnsFalse ()
- {
- CreateFakePackageManagementProject ();
- CreateSelectedProject (fakeProject);
-
- bool selected = selectedProject.IsSelected;
-
- Assert.IsFalse (selected);
- }
-
- [Test]
- public void IsEnabled_EnabledNotSpecifiedInConstructor_ReturnsTrue ()
- {
- CreateFakePackageManagementProject ();
- CreateSelectedProject (fakeProject);
-
- bool enabled = selectedProject.IsEnabled;
-
- Assert.IsTrue (enabled);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSelectedProjectsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSelectedProjectsTests.cs deleted file mode 100644 index e820f8a489..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSelectedProjectsTests.cs +++ /dev/null @@ -1,536 +0,0 @@ -//
-// PackageManagementSelectedProjectsTests.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 System.Collections.Generic;
-using System.Linq;
-
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageManagementSelectedProjectsTests
- {
- PackageManagementSelectedProjects selectedProjects;
- FakePackageManagementSolution fakeSolution;
-
- void CreateSelectedProjects ()
- {
- selectedProjects = new PackageManagementSelectedProjects (fakeSolution);
- }
-
- void CreateFakeSolution ()
- {
- fakeSolution = new FakePackageManagementSolution ();
- }
-
- List<FakeDotNetProject> AddSolutionWithOneProjectToProjectService ()
- {
- FakeDotNetProject project = ProjectHelper.CreateTestProject ("Test1");
- fakeSolution.FakeDotNetProjects.Add (project);
-
- return fakeSolution.FakeDotNetProjects;
- }
-
- List<FakeDotNetProject> AddSolutionWithTwoProjectsToProjectService ()
- {
- ISolution solution = ProjectHelper.CreateSolution ();
- FakeDotNetProject project1 = ProjectHelper.CreateTestProject (solution, "Test1");
- FakeDotNetProject project2 = ProjectHelper.CreateTestProject ("Test2");
-
- fakeSolution.FakeDotNetProjects.Add (project1);
- fakeSolution.FakeDotNetProjects.Add (project2);
-
- return fakeSolution.FakeDotNetProjects;
- }
-
- void NoProjectsSelected ()
- {
- fakeSolution.NoProjectsSelected ();
- }
-
- [Test]
- public void GetProjects_SolutionHasTwoProjectsAndOneProjectSelectedInProjectsBrowser_ReturnsProjectSelectedInProjects ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- FakeDotNetProject project = projectsAddedToSolution [1];
- project.Name = "MyProject";
- fakeSolution.FakeActiveDotNetProject = project;
-
- fakeSolution.AddFakeProjectToReturnFromGetProject ("MyProject");
- CreateSelectedProjects ();
-
- var fakePackage = new FakePackage ();
- var projects = new List<IPackageManagementSelectedProject> ();
- projects.AddRange (selectedProjects.GetProjects (fakePackage));
-
- var expectedProject = new PackageManagementSelectedProject ("MyProject", selected: false, enabled: true);
- var expectedProjects = new List<IPackageManagementSelectedProject> ();
- expectedProjects.Add (expectedProject);
-
- SelectedProjectCollectionAssert.AreEqual (expectedProjects, projects);
- }
-
- [Test]
- public void GetProjects_SolutionHasTwoProjectsAndOneProjectSelectedInitiallyAndGetProjectsCalledAgainAfterNoProjectsAreSelected_ReturnsProjectSelectedInProjects ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- FakeDotNetProject project = projectsAddedToSolution [1];
- project.Name = "MyProject";
- fakeSolution.FakeActiveDotNetProject = project;
-
- fakeSolution.AddFakeProjectToReturnFromGetProject ("MyProject");
- CreateSelectedProjects ();
-
- var fakePackage = new FakePackage ();
- var projects = new List<IPackageManagementSelectedProject> ();
- projects.AddRange (selectedProjects.GetProjects (fakePackage));
-
- projects.Clear ();
-
- NoProjectsSelected ();
- projects.AddRange (selectedProjects.GetProjects (fakePackage));
-
- var expectedProject = new PackageManagementSelectedProject ("MyProject", selected: false, enabled: true);
- var expectedProjects = new List<IPackageManagementSelectedProject> ();
- expectedProjects.Add (expectedProject);
-
- SelectedProjectCollectionAssert.AreEqual (expectedProjects, projects);
- }
-
- [Test]
- public void HasMultipleProjects_SolutionHasTwoProjectsAndOneProjectSelectedInProjectsBrowser_ReturnsFalse ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- FakeDotNetProject expectedProject = projectsAddedToSolution [1];
- fakeSolution.FakeActiveDotNetProject = expectedProject;
- CreateSelectedProjects ();
-
- bool hasMultipleProjects = selectedProjects.HasMultipleProjects ();
-
- Assert.IsFalse (hasMultipleProjects);
- }
-
- [Test]
- public void GetProjects_SolutionHasTwoProjectsAndNoProjectSelectedInProjectsBrowser_ReturnsAllProjectsInSolutionForPackage ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- projectsAddedToSolution [0].Name = "Project A";
- projectsAddedToSolution [1].Name = "Project B";
- fakeSolution.FakeActiveProject = null;
-
- fakeSolution.AddFakeProjectToReturnFromGetProject ("Project A");
- fakeSolution.AddFakeProjectToReturnFromGetProject ("Project B");
- CreateSelectedProjects ();
-
- var fakePackage = new FakePackage ();
- var projects = new List<IPackageManagementSelectedProject> ();
- projects.AddRange (selectedProjects.GetProjects (fakePackage));
-
- var expectedProjects = new List<IPackageManagementSelectedProject> ();
- expectedProjects.Add (new PackageManagementSelectedProject ("Project A", selected: false, enabled: true));
- expectedProjects.Add (new PackageManagementSelectedProject ("Project B", selected: false, enabled: true));
-
- SelectedProjectCollectionAssert.AreEqual (expectedProjects, projects);
- }
-
- [Test]
- public void HasMultipleProjects_SolutionHasTwoProjectsAndNoProjectSelectedInProjectsBrowser_ReturnsTrue ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveProject = null;
- CreateSelectedProjects ();
-
- bool hasMultipleProjects = selectedProjects.HasMultipleProjects ();
-
- Assert.IsTrue (hasMultipleProjects);
- }
-
- [Test]
- public void HasMultipleProjects_SolutionHasOneProjectAndNoProjectSelectedInProjectsBrowser_ReturnsFalse ()
- {
- CreateFakeSolution ();
- AddSolutionWithOneProjectToProjectService ();
- fakeSolution.FakeActiveProject = null;
- CreateSelectedProjects ();
-
- bool hasMultipleProjects = selectedProjects.HasMultipleProjects ();
-
- Assert.IsFalse (hasMultipleProjects);
- }
-
- [Test]
- public void SelectionName_SolutionHasOneProject_ReturnsProjectNameWithoutFileExtension ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithOneProjectToProjectService ();
- projectsAddedToSolution [0].Name = "MyProject";
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- string name = selectedProjects.SelectionName;
-
- Assert.AreEqual ("MyProject", name);
- }
-
- [Test]
- public void SelectionName_SolutionHasTwoProjectsAndNoProjectSelected_ReturnsSolutionFileNameWithoutFullPath ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
- fakeSolution.FileName = @"d:\projects\MyProject\MySolution.sln".ToNativePath ();
- CreateSelectedProjects ();
-
- string name = selectedProjects.SelectionName;
-
- Assert.AreEqual ("MySolution.sln", name);
- }
-
- [Test]
- public void IsPackageInstalled_PackageInstalledInSolutionWithTwoProjectsAndNoProjectSelected_ReturnsTrue ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
-
- var package = new FakePackage ("Test");
- fakeSolution.FakeInstalledPackages.Add (package);
- CreateSelectedProjects ();
-
- bool installed = selectedProjects.IsPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsPackageInstalled_PackageIsInstalledInSolutionWithTwoProjectsAndNoProjectSelected_ReturnsFalse ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
- CreateSelectedProjects ();
-
- var package = new FakePackage ("Test");
- bool installed = selectedProjects.IsPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void IsPackageInstalled_PackageIsInstalledInProjectAndProjectSelected_ReturnsTrue ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
-
- var package = new FakePackage ("Test");
- fakeSolution.FakeProjectToReturnFromGetProject.FakePackages.Add (package);
- CreateSelectedProjects ();
-
- bool installed = selectedProjects.IsPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsPackageInstalled_PackageIsNotInstalledInProjectAndProjectSelected_ReturnsFalse ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var package = new FakePackage ("Test");
- bool installed = selectedProjects.IsPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void IsPackageInstalled_PackagePackageIsNotInstalledInProjectAndProjectSelected_ProjectCreatedUsingPackageRepository ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var package = new FakePackage ("Test");
- selectedProjects.IsPackageInstalled (package);
-
- IPackageRepository repository = fakeSolution.RepositoryPassedToGetProject;
- IPackageRepository expectedRepository = package.FakePackageRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void IsPackageInstalledInSolution_PackageInstalledInSolutionWithTwoProjectsAndOneProjectSelected_ReturnsTrue ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
-
- var package = new FakePackage ("Test");
- fakeSolution.FakeInstalledPackages.Add (package);
- CreateSelectedProjects ();
-
- bool installed = selectedProjects.Solution.IsPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsPackageInstalledInSolution_PackageNotInstalledInSolutionWithTwoProjectsAndOneProjectSelected_ReturnsFalse ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var package = new FakePackage ("Test");
-
- bool installed = selectedProjects.Solution.IsPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void GetPackagesInstalledInSolution_PackageInstalledInSolutionAndProjectNotSelected_ReturnsPackageInstalledInSolution ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
-
- var package = new FakePackage ("Test");
- fakeSolution.FakeInstalledPackages.Add (package);
- CreateSelectedProjects ();
-
- IQueryable<IPackage> packages = selectedProjects.Solution.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- package
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetSingleProjectSelected_ProjectSelected_ReturnsProject ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var repository = new FakePackageRepository ();
- IPackageManagementProject project = selectedProjects.GetSingleProjectSelected (repository);
-
- FakePackageManagementProject expectedProject = fakeSolution.FakeProjectToReturnFromGetProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetSingleProjectSelected_ProjectSelectedAndRepositoryPassed_ReturnsProjectCreatedWithRepository ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var repository = new FakePackageRepository ();
- selectedProjects.GetSingleProjectSelected (repository);
-
- Assert.AreEqual (repository, fakeSolution.RepositoryPassedToGetProject);
- }
-
- [Test]
- public void GetSingleProjectSelected_NoProjectSelectedAndRepositoryPassed_ReturnsProjectCreatedWithRepository ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var repository = new FakePackageRepository ();
- selectedProjects.GetSingleProjectSelected (repository);
-
- Assert.AreEqual (repository, fakeSolution.RepositoryPassedToGetProject);
- }
-
- [Test]
- public void HasSingleProjectSelected_SolutionHasTwoProjectsAndOneProjectSelectedInProjectsBrowser_ReturnsTrue ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- FakeDotNetProject expectedProject = projectsAddedToSolution [1];
- fakeSolution.FakeActiveDotNetProject = expectedProject;
- CreateSelectedProjects ();
-
- bool singleProjectSelected = selectedProjects.HasSingleProjectSelected ();
-
- Assert.IsTrue (singleProjectSelected);
- }
-
- [Test]
- public void HasSingleProjectSelected_SolutionHasTwoProjectsAndNoProjectsSelectedInProjectsBrowser_ReturnsFalse ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
- CreateSelectedProjects ();
-
- bool singleProjectSelected = selectedProjects.HasSingleProjectSelected ();
-
- Assert.IsFalse (singleProjectSelected);
- }
-
- [Test]
- public void HasSingleProjectSelected_NoProjectsInitiallySelectedAndProjectSelectedAfterInitialCall_IsUnchangedAndReturnsFalse ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
- CreateSelectedProjects ();
-
- bool singleProjectSelected = selectedProjects.HasSingleProjectSelected ();
- fakeSolution.FakeActiveDotNetProject = fakeSolution.FakeDotNetProjects [0];
- singleProjectSelected = selectedProjects.HasSingleProjectSelected ();
-
- Assert.IsFalse (singleProjectSelected);
- }
-
- [Test]
- public void GetInstalledPackages_PackageInstalledInSolutionAndProjectNotSelected_ReturnsPackageInstalledInSolution ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
-
- var package = new FakePackage ("Test");
- fakeSolution.FakeInstalledPackages.Add (package);
- CreateSelectedProjects ();
-
- var repository = new FakePackageRepository ();
- IQueryable<IPackage> packages = selectedProjects.GetInstalledPackages (repository);
-
- var expectedPackages = new FakePackage[] {
- package
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetInstalledPackages_PackageInstalledInProjectAndProjectIsSelected_ReturnsPackageInstalledInProject ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- fakeSolution.FakeActiveDotNetProject.Name = "MyProject";
-
- var package = new FakePackage ("Test");
- var project = new FakePackageManagementProject ("MyProject");
- project.FakePackages.Add (package);
- fakeSolution.FakeProjectsToReturnFromGetProject.Add ("MyProject", project);
- CreateSelectedProjects ();
-
- var repository = new FakePackageRepository ();
- IQueryable<IPackage> packages = selectedProjects.GetInstalledPackages (repository);
-
- var expectedPackages = new FakePackage[] {
- package
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetInstalledPackages_PackageInstalledInProjectAndProjectIsSelected_CreatesProjectUsingRepository ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- fakeSolution.FakeActiveDotNetProject = projectsAddedToSolution [0];
- CreateSelectedProjects ();
-
- var expectedRepository = new FakePackageRepository ();
- selectedProjects.GetInstalledPackages (expectedRepository);
-
- IPackageRepository repository = fakeSolution.RepositoryPassedToGetProject;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void GetSingleProjectSelected_NoProjectSelected_ReturnsNull ()
- {
- CreateFakeSolution ();
- AddSolutionWithTwoProjectsToProjectService ();
- NoProjectsSelected ();
- CreateSelectedProjects ();
-
- var repository = new FakePackageRepository ();
- IPackageManagementProject project = selectedProjects.GetSingleProjectSelected (repository);
-
- Assert.IsNull (project);
- }
-
- [Test]
- public void GetProjects_SolutionHasTwoProjectsAndOneProjectSelectedInitiallyAndActiveProjectChangedInSolutionAfterInstanceCreated_ReturnsProjectSelectedInProjects ()
- {
- CreateFakeSolution ();
- List<FakeDotNetProject> projectsAddedToSolution = AddSolutionWithTwoProjectsToProjectService ();
- FakeDotNetProject project = projectsAddedToSolution [1];
- project.Name = "MyProject";
- fakeSolution.FakeActiveDotNetProject = project;
- fakeSolution.AddFakeProjectToReturnFromGetProject ("MyProject");
- CreateSelectedProjects ();
-
- NoProjectsSelected ();
-
- var fakePackage = new FakePackage ();
- List<IPackageManagementSelectedProject> projects = selectedProjects.GetProjects (fakePackage).ToList ();
-
- var expectedProject = new PackageManagementSelectedProject ("MyProject", selected: false, enabled: true);
- var expectedProjects = new List<IPackageManagementSelectedProject> ();
- expectedProjects.Add (expectedProject);
-
- SelectedProjectCollectionAssert.AreEqual (expectedProjects, projects);
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSolutionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSolutionTests.cs deleted file mode 100644 index 63b6b51f9f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageManagementSolutionTests.cs +++ /dev/null @@ -1,735 +0,0 @@ -//
-// PackageManagementSolutionTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageManagementSolutionTests
- {
- PackageManagementSolution solution;
- FakeRegisteredPackageRepositories fakeRegisteredPackageRepositories;
- OneRegisteredPackageSourceHelper packageSourcesHelper;
- FakePackageManagementProjectService fakeProjectService;
- FakePackageManagementProjectFactory fakeProjectFactory;
- FakeDotNetProject testProject;
- FakeSolutionPackageRepositoryFactory fakeSolutionPackageRepositoryFactory;
- FakeSolutionPackageRepository fakeSolutionPackageRepository;
-
- void CreatePackageSources ()
- {
- packageSourcesHelper = new OneRegisteredPackageSourceHelper ();
- }
-
- void CreateSolution ()
- {
- CreatePackageSources ();
- CreateSolution (packageSourcesHelper.Options);
- }
-
- void CreateSolution (PackageManagementOptions options)
- {
- testProject = ProjectHelper.CreateTestProject ();
- fakeRegisteredPackageRepositories = new FakeRegisteredPackageRepositories ();
- fakeProjectFactory = new FakePackageManagementProjectFactory ();
- fakeProjectService = new FakePackageManagementProjectService ();
-
- fakeProjectService.CurrentProject = testProject;
- fakeProjectService.OpenSolution = testProject.ParentSolution;
-
- fakeSolutionPackageRepositoryFactory = new FakeSolutionPackageRepositoryFactory ();
- fakeSolutionPackageRepository = fakeSolutionPackageRepositoryFactory.FakeSolutionPackageRepository;
-
- solution =
- new PackageManagementSolution (
- fakeRegisteredPackageRepositories,
- fakeProjectService,
- fakeProjectFactory,
- fakeSolutionPackageRepositoryFactory);
- }
-
- FakeDotNetProject AddProjectToOpenProjects (string projectName)
- {
- FakeDotNetProject project = ProjectHelper.CreateTestProject (projectName);
- fakeProjectService.OpenProjects.Add (project);
- return project;
- }
-
- FakePackage AddPackageInReverseDependencyOrderToSolution (string packageId)
- {
- var package = new FakePackage (packageId);
- fakeSolutionPackageRepository.FakePackagesByReverseDependencyOrder.Add (package);
- return package;
- }
-
- AggregateRepository CreateAggregateRepositoryWithOneRepository ()
- {
- var repositories = new FakePackageRepository [] {
- new FakePackageRepository ()
- };
- return new AggregateRepository (repositories);
- }
-
- [Test]
- public void GetActiveProject_ProjectIsSelected_CreatesProjectUsingCurrentProjectSelectedInMonoDevelop ()
- {
- CreateSolution ();
-
- solution.GetActiveProject ();
-
- IProject actualProject = fakeProjectFactory.FirstProjectPassedToCreateProject;
- Assert.AreEqual (testProject, actualProject);
- }
-
- [Test]
- public void GetActiveProject_ProjectIsSelected_CreatesProjectUsingAggregateRepository ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = new FakeDotNetProject ();
- AggregateRepository expectedRepository = CreateAggregateRepositoryWithOneRepository ();
- fakeRegisteredPackageRepositories.CreateAggregateRepositoryAction = () => expectedRepository;
-
- solution.GetActiveProject ();
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void GetActiveProject_ProjectIsSelected_ReturnsProjectCreatedByFactory ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = new FakeDotNetProject ();
-
- IPackageManagementProject activeProject = solution.GetActiveProject ();
- IPackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;
-
- Assert.AreEqual (expectedProject, activeProject);
- }
-
- [Test]
- public void GetActiveProject_RepositoryPassed_CreatesProjectUsingFallbackRepositoryWithAggregateAsFallback ()
- {
- CreateSolution ();
- var expectedRepository = new FakePackageRepository ();
-
- solution.GetActiveProject (expectedRepository);
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
- var fallbackRepository = repository as FallbackRepository;
- Assert.IsNotNull (fallbackRepository);
- Assert.AreEqual (expectedRepository, fallbackRepository.SourceRepository);
- Assert.AreEqual (fakeRegisteredPackageRepositories.FakeAggregateRepository, fallbackRepository.DependencyResolver);
- }
-
- [Test]
- public void GetActiveProject_AggregateRepositoryPassed_CreatesProjectUsingAggregateRepository ()
- {
- CreateSolution ();
- AggregateRepository expectedRepository = CreateAggregateRepositoryWithOneRepository ();
-
- solution.GetActiveProject (expectedRepository);
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void GetActiveProject_RepositoryPassed_CreatesProjectUsingCurrentActiveProject ()
- {
- CreateSolution ();
- var expectedRepository = new FakePackageRepository ();
- FakeDotNetProject expectedProject = ProjectHelper.CreateTestProject ();
- fakeProjectService.CurrentProject = expectedProject;
-
- solution.GetActiveProject (expectedRepository);
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetActiveProject_RepositoryPassed_ReturnsProjectFromProjectFactory ()
- {
- CreateSolution ();
- var expectedRepository = new FakePackageRepository ();
- IPackageManagementProject project = solution.GetActiveProject (expectedRepository);
-
- FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesSourceAndProjectNamePassed_CreatesProjectUsingFoundProjectMatchingName ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
- var source = new PackageSource ("http://monodevelop.net");
-
- solution.GetProject (source, "Test");
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesSourceAndProjectNameWithDifferentCasePassed_CreatesProjectUsingFoundProjectMatchingName ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
- var source = new PackageSource ("http://monodevelop.net");
-
- solution.GetProject (source, "TEST");
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesSourceAndProjectPassed_ReturnsProjectFromProjectFactory ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("Test");
- var source = new PackageSource ("http://monodevelop.net");
- IPackageManagementProject project = solution.GetProject (source, "Test");
-
- FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesSourceAndProjectPassed_PackageSourceUsedToCreateRepository ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("Test");
- var expectedSource = new PackageSource ("http://monodevelop.net");
- solution.GetProject (expectedSource, "Test");
-
- PackageSource actualSource = fakeRegisteredPackageRepositories.PackageSourcePassedToCreateRepository;
-
- Assert.AreEqual (expectedSource, actualSource);
- }
-
- [Test]
- public void GetProject_PackagesRepositoryAndProjectNamePassed_CreatesProjectUsingFoundProjectMatchingName ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
- var repository = new FakePackageRepository ();
-
- solution.GetProject (repository, "Test");
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingProjectPassed ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
- var repository = new FakePackageRepository ();
-
- solution.GetProject (repository, expectedProject);
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesRepositoryAndProjectPassed_ReturnsProjectCreatedFromProjectFactory ()
- {
- CreateSolution ();
- FakeDotNetProject msbuildProject = AddProjectToOpenProjects ("Test");
- var repository = new FakePackageRepository ();
-
- IPackageManagementProject project = solution.GetProject (repository, msbuildProject);
-
- FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_PackagesRepositoryAndProjectPassed_CreatesProjectUsingRepository ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
- AggregateRepository expectedRepository = CreateAggregateRepositoryWithOneRepository ();
-
- solution.GetProject (expectedRepository, expectedProject);
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void GetProject_RepositoryAndProjectNameWithDifferentCasePassed_CreatesProjectUsingFoundProjectMatchingName ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("Test");
- var repository = new FakePackageRepository ();
-
- solution.GetProject (repository, "TEST");
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_RepositoryAndProjectNamePassed_ReturnsProject ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("Test");
- var repository = new FakePackageRepository ();
-
- IPackageManagementProject project = solution.GetProject (repository, "Test");
-
- FakePackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProject_RepositoryAndProjectNamePassed_RepositoryUsedToCreateProject ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("Test");
- AggregateRepository expectedRepository = CreateAggregateRepositoryWithOneRepository ();
-
- solution.GetProject (expectedRepository, "Test");
-
- IPackageRepository actualRepository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
-
- Assert.AreEqual (expectedRepository, actualRepository);
- }
-
- [Test]
- public void GetMSBuildProjects_TwoProjectsInOpenSolution_ReturnsTwoProjects ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("A");
- AddProjectToOpenProjects ("B");
-
- IEnumerable<IDotNetProject> projects = solution.GetDotNetProjects ();
- IEnumerable<IDotNetProject> expectedProjects = fakeProjectService.OpenProjects;
-
- CollectionAssert.AreEqual (expectedProjects, projects);
- }
-
- [Test]
- public void IsOpen_NoSolutionOpen_ReturnsFalse ()
- {
- CreateSolution ();
- fakeProjectService.OpenSolution = null;
-
- bool open = solution.IsOpen;
-
- Assert.IsFalse (open);
- }
-
- [Test]
- public void IsOpen_SolutionIsOpen_ReturnsTrue ()
- {
- CreateSolution ();
- fakeProjectService.OpenSolution = new FakeSolution ();
-
- bool open = solution.IsOpen;
-
- Assert.IsTrue (open);
- }
-
- [Test]
- public void GetActiveMSBuildProject_CurrentProjectIsSetInProjectService_ReturnsProjectCurrentlySelected ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = testProject;
-
- IProject activeProject = solution.GetActiveDotNetProject ();
-
- Assert.AreEqual (testProject, activeProject);
- }
-
- [Test]
- public void HasMultipleProjects_OneProjectInSolution_ReturnsFalse ()
- {
- CreateSolution ();
- FakeDotNetProject project = ProjectHelper.CreateTestProject ();
- fakeProjectService.OpenProjects.Add (project);
-
- bool hasMultipleProjects = solution.HasMultipleProjects ();
-
- Assert.IsFalse (hasMultipleProjects);
- }
-
- [Test]
- public void HasMultipleProjects_TwoProjectsInSolution_ReturnsTrue ()
- {
- CreateSolution ();
- FakeDotNetProject project1 = ProjectHelper.CreateTestProject ();
- fakeProjectService.OpenProjects.Add (project1);
- FakeDotNetProject project2 = ProjectHelper.CreateTestProject ();
- fakeProjectService.OpenProjects.Add (project2);
-
- bool hasMultipleProjects = solution.HasMultipleProjects ();
-
- Assert.IsTrue (hasMultipleProjects);
- }
-
- [Test]
- public void FileName_SolutionHasFileName_ReturnsSolutionFileName ()
- {
- CreateSolution ();
- string expectedFileName = @"d:\projects\myproject\Project.sln".ToNativePath ();
- var solution = new FakeSolution (expectedFileName);
- fakeProjectService.OpenSolution = solution;
-
- string fileName = this.solution.FileName;
-
- Assert.AreEqual (expectedFileName, fileName);
- }
-
- [Test]
- public void IsInstalled_PackageIsInstalledInSolutionLocalRepository_ReturnsTrue ()
- {
- CreateSolution ();
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.3.4.5");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (package);
-
- bool installed = solution.IsPackageInstalled (package);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIsNotInstalledInSolutionLocalRepository_ReturnsFalse ()
- {
- CreateSolution ();
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.3.4.5");
-
- bool installed = solution.IsPackageInstalled (package);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIsNotInstalledInSolutionLocalRepository_ActivSolutionUsedToCreateSolutionPackageRepository ()
- {
- CreateSolution ();
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.3.4.5");
-
- solution.IsPackageInstalled (package);
-
- ISolution expectedSolution = fakeProjectService.OpenSolution;
- ISolution solutionUsedToCreateSolutionPackageRepository =
- fakeSolutionPackageRepositoryFactory.SolutionPassedToCreateSolutionPackageRepository;
-
- Assert.AreEqual (expectedSolution, solutionUsedToCreateSolutionPackageRepository);
- }
-
- [Test]
- public void GetActiveProject_SolutionOpenButNoProjectSelected_ReturnsNull ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
-
- IPackageManagementProject activeProject = solution.GetActiveProject ();
-
- Assert.IsNull (activeProject);
- }
-
- [Test]
- public void GetActiveProject_RepositoryPassedWhenSolutionOpenButNoProjectSelected_ReturnsNull ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
-
- var repository = new FakePackageRepository ();
- IPackageManagementProject activeProject = solution.GetActiveProject (repository);
-
- Assert.IsNull (activeProject);
- }
-
- [Test]
- public void GetPackages_OnePackageInSolutionRepository_ReturnsOnePackage ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.3.4.5");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (package);
- AddProjectToOpenProjects ("Test");
- var project = new FakePackageManagementProject ();
- fakeProjectFactory.CreatePackageManagementProject = (repository, msbuildProject) => {
- return project;
- };
- project.FakePackages.Add (package);
-
- IQueryable<IPackage> packages = solution.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- package
- };
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetPackagesInReverseDependencyOrder_TwoPackages_ReturnsPackagesFromSolutionLocalRepositoryInCorrectOrder ()
- {
- CreateSolution ();
- FakePackage packageA = AddPackageInReverseDependencyOrderToSolution ("A");
- FakePackage packageB = AddPackageInReverseDependencyOrderToSolution ("A");
-
- packageB.DependenciesList.Add (new PackageDependency ("A"));
-
- var expectedPackages = new FakePackage[] {
- packageB,
- packageA
- };
-
- IEnumerable<IPackage> packages = solution.GetPackagesInReverseDependencyOrder ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetProjects_SolutionHasOneProject_ReturnsOneProject ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("MyProject");
- var repository = new FakePackageRepository ();
- List<IPackageManagementProject> projects = solution.GetProjects (repository).ToList ();
-
- Assert.AreEqual (1, projects.Count);
- }
-
- [Test]
- public void GetProjects_SolutionHasOneProject_RepositoryUsedToCreateProject ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("MyProject");
- AggregateRepository expectedRepository = CreateAggregateRepositoryWithOneRepository ();
- solution.GetProjects (expectedRepository).ToList ();
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void GetProjects_SolutionHasOneProject_FallbackRepositoryUsedToCreateProject ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("MyProject");
- var expectedRepository = new FakePackageRepository ();
-
- solution.GetProjects (expectedRepository).ToList ();
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
- var fallbackRepository = repository as FallbackRepository;
- Assert.AreEqual (expectedRepository, fallbackRepository.SourceRepository);
- Assert.AreEqual (fakeRegisteredPackageRepositories.FakeAggregateRepository, fallbackRepository.DependencyResolver);
- }
-
- [Test]
- public void GetProjects_SolutionHasOneProject_MSBuildProjectUsedToCreateProject ()
- {
- CreateSolution ();
- FakeDotNetProject expectedProject = AddProjectToOpenProjects ("MyProject");
- var repository = new FakePackageRepository ();
- solution.GetProjects (repository).ToList ();
-
- IDotNetProject project = fakeProjectFactory.FirstProjectPassedToCreateProject;
-
- Assert.AreEqual (expectedProject, project);
- }
-
- [Test]
- public void GetProjects_SolutionHasNoProjects_ReturnsNoProjects ()
- {
- CreateSolution ();
- var repository = new FakePackageRepository ();
- List<IPackageManagementProject> projects = solution.GetProjects (repository).ToList ();
-
- Assert.AreEqual (0, projects.Count);
- }
-
- [Test]
- public void GetProjects_SolutionHasTwoProjects_ReturnsTwoProjects ()
- {
- CreateSolution ();
- AddProjectToOpenProjects ("One");
- AddProjectToOpenProjects ("Two");
- var repository = new FakePackageRepository ();
- List<IPackageManagementProject> projects = solution.GetProjects (repository).ToList ();
-
- Assert.AreEqual (2, projects.Count);
- }
-
- [Test]
- public void GetInstallPath_OnePackageInSolutionRepository_ReturnsPackageInstallPath ()
- {
- CreateSolution ();
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.3.4.5");
- string expectedInstallPath = @"d:\projects\MyProject\packages\TestPackage".ToNativePath ();
- fakeSolutionPackageRepository.InstallPathToReturn = expectedInstallPath;
-
- string installPath = solution.GetInstallPath (package);
-
- Assert.AreEqual (expectedInstallPath, installPath);
- Assert.AreEqual (package, fakeSolutionPackageRepository.PackagePassedToGetInstallPath);
- }
-
- [Test]
- public void GetPackages_OnePackageInstalledIntoOneProjectButTwoPackagesInSolutionRepository_ReturnsOnePackageInstalledInProject ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
- AddProjectToOpenProjects ("Test");
- var project = new FakePackageManagementProject ();
- fakeProjectFactory.CreatePackageManagementProject = (repository, msbuildProject) => {
- return project;
- };
- FakePackage notInstalledPackage = FakePackage.CreatePackageWithVersion ("NotInstalled", "1.0.0.0");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (notInstalledPackage);
- FakePackage installedPackage = FakePackage.CreatePackageWithVersion ("Installed", "1.0.0.0");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (installedPackage);
- project.FakePackages.Add (installedPackage);
-
- IQueryable<IPackage> packages = solution.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- installedPackage
- };
-
- Assert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetPackages_OnePackageInstalledIntoOneProjectButTwoPackagesInSolutionRepository_ReturnsOnlyOneProjectPackage ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
- AddProjectToOpenProjects ("Test");
- var project = new FakePackageManagementProject ();
- fakeProjectFactory.CreatePackageManagementProject = (repository, msbuildProject) => {
- return project;
- };
- FakePackage installedSolutionPackage = FakePackage.CreatePackageWithVersion ("SolutionPackage", "1.0.0.0");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (installedSolutionPackage);
- FakePackage installedProjectPackage = FakePackage.CreatePackageWithVersion ("ProjectPackage", "1.0.0.0");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (installedProjectPackage);
- project.FakePackages.Add (installedProjectPackage);
-
- IQueryable<IPackage> packages = solution.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- installedProjectPackage
- };
-
- Assert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetPackages_TwoProjectsButNoPackagesInstalledInProjects_PackageProjectsCreatedUsingActiveRepository ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
- FakeDotNetProject testProject1 = AddProjectToOpenProjects ("Test1");
- FakeDotNetProject testProject2 = AddProjectToOpenProjects ("Test2");
- AggregateRepository repository = CreateAggregateRepositoryWithOneRepository ();
- fakeRegisteredPackageRepositories.GetActiveRepositoryAction = () => repository;
-
- solution.GetPackages ();
-
- Assert.AreEqual (testProject1, fakeProjectFactory.ProjectsPassedToCreateProject [0]);
- Assert.AreEqual (testProject2, fakeProjectFactory.ProjectsPassedToCreateProject [1]);
- Assert.AreEqual (fakeRegisteredPackageRepositories.ActiveRepository, fakeProjectFactory.RepositoriesPassedToCreateProject [0]);
- Assert.AreEqual (fakeRegisteredPackageRepositories.ActiveRepository, fakeProjectFactory.RepositoriesPassedToCreateProject [1]);
- }
-
- [Test]
- public void GetPackages_OnePackageInstalledIntoPackagesFolderOnly_ReturnsNoPackages ()
- {
- CreateSolution ();
- fakeProjectService.CurrentProject = null;
- FakePackage fakePackage = FakePackage.CreatePackageWithVersion ("One", "1.0");
- fakeSolutionPackageRepository.FakeSharedRepository.FakePackages.Add (fakePackage);
-
- IQueryable<IPackage> packages = solution.GetPackages ();
-
- var expectedPackages = new FakePackage [0];
- Assert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetRepository_OpenSolution_ReturnsRepositoryForSolution ()
- {
- CreateSolution ();
- var fakeSolution = new FakeSolution (@"d:\projects\MyProject\MySolution.sln");
- fakeProjectService.OpenSolution = fakeSolution;
-
- ISolutionPackageRepository repository = solution.GetRepository ();
-
- Assert.IsNotNull (repository);
- Assert.AreEqual (fakeSolutionPackageRepositoryFactory.SolutionPassedToCreateSolutionPackageRepository, fakeSolution);
- Assert.AreEqual (fakeSolutionPackageRepositoryFactory.FakeSolutionPackageRepository, repository);
- }
-
- [Test]
- public void GetProject_NoRepositorySpecified_CreatesProjectUsingAggregateRepository ()
- {
- CreateSolution ();
- var dotNetProject = new FakeDotNetProject ();
- AggregateRepository expectedRepository = CreateAggregateRepositoryWithOneRepository ();
- fakeRegisteredPackageRepositories.CreateAggregateRepositoryAction = () => expectedRepository;
-
- IPackageManagementProject project = solution.GetProject (dotNetProject);
-
- IPackageRepository repository = fakeProjectFactory.FirstRepositoryPassedToCreateProject;
- IPackageManagementProject expectedProject = fakeProjectFactory.FirstFakeProjectCreated;
- Assert.AreEqual (expectedRepository, repository);
- Assert.AreEqual (expectedProject, project);
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReferenceNodeTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReferenceNodeTests.cs index 006218771d..c050d5b762 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReferenceNodeTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReferenceNodeTests.cs @@ -26,11 +26,14 @@ using System;
using MonoDevelop.PackageManagement.NodeBuilders;
+using MonoDevelop.PackageManagement.Tests.Helpers;
using NUnit.Framework;
-using NuGet;
+using NuGet.Packaging;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Tasks;
+using NuGet.Packaging.Core;
+using NuGet.Versioning;
namespace MonoDevelop.PackageManagement.Tests
{
@@ -43,17 +46,26 @@ namespace MonoDevelop.PackageManagement.Tests void CreatePackageReferenceNode (
bool installed = true,
bool installPending = false,
- PackageName updatedPackage = null)
+ PackageIdentity updatedPackage = null)
{
node = new PackageReferenceNode (null, packageReference, installed, installPending, updatedPackage);
}
void CreatePackageReference (
string packageId = "Id",
+ string packageVersion = "1.2.3",
bool requireReinstallation = false)
{
- var version = new SemanticVersion ("1.2.3");
- packageReference = new PackageReference (packageId, version, null, null, false, requireReinstallation);
+ var version = new NuGetVersion (packageVersion);
+ var identity = new PackageIdentity (packageId, version);
+ packageReference = new PackageReference (identity, null, true, false, requireReinstallation);
+ }
+
+ void CreatePackageReferenceWithProjectJsonWildcardVersion (string packageId, string version)
+ {
+ packageReference = TestPackageReferenceFactory.CreatePackageReferenceWithProjectJsonWildcardVersion (
+ packageId,
+ version);
}
[Test]
@@ -167,7 +179,7 @@ namespace MonoDevelop.PackageManagement.Tests requireReinstallation: true);
CreatePackageReferenceNode (
installed: true,
- updatedPackage: new PackageName ("MyPackage", new SemanticVersion ("1.2.3.4")));
+ updatedPackage: new PackageIdentity ("MyPackage", new NuGetVersion ("1.2.3.4")));
string label = node.GetLabel ();
string secondaryLabel = node.GetSecondaryLabel ();
@@ -296,6 +308,28 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsNull (message);
}
+
+ [Test]
+ public void GetVersionLabel_SpecificVersionInstalled_ReturnsVersion ()
+ {
+ CreatePackageReference ("MyPackage", "1.2.3");
+ CreatePackageReferenceNode ();
+
+ string label = node.GetPackageVersionLabel ();
+
+ Assert.AreEqual (label, "Version 1.2.3");
+ }
+
+ [Test]
+ public void GetVersionLabel_FloatingVersionVersion_ReturnsFloatingVersion ()
+ {
+ CreatePackageReferenceWithProjectJsonWildcardVersion ("MyPackage", "1.2.3-*");
+ CreatePackageReferenceNode ();
+
+ string label = node.GetPackageVersionLabel ();
+
+ Assert.AreEqual (label, "Version 1.2.3-*");
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReinstallerTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReinstallerTests.cs deleted file mode 100644 index 51651487dc..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageReinstallerTests.cs +++ /dev/null @@ -1,105 +0,0 @@ -//
-// PackageReinstallerTests.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 MonoDevelop.PackageManagement.Tests.Helpers;
-using NUnit.Framework;
-using NuGet;
-using MonoDevelop.PackageManagement.NodeBuilders;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageReinstallerTests
- {
- PackageReinstaller reinstaller;
- FakePackageManagementSolution solution;
- FakeBackgroundPackageActionRunner backgroundRunner;
- FakePackageManagementProject project;
-
- void CreateReinstaller ()
- {
- solution = new FakePackageManagementSolution ();
- project = solution.FakeActiveProject;
- backgroundRunner = new FakeBackgroundPackageActionRunner ();
-
- reinstaller = new PackageReinstaller (solution, backgroundRunner);
- }
-
- void Run (string packageId, string packageVersion)
- {
- var packageReference = new PackageReference (
- packageId,
- new SemanticVersion (packageVersion),
- null,
- null,
- false);
-
- var parentNode = new TestableProjectPackagesFolderNode (project.FakeDotNetProject, null);
- var node = new PackageReferenceNode (parentNode, packageReference, true);
-
- reinstaller.Run (node);
- }
-
- [Test]
- public void Run_ReinstallSucceeds_ReinstallActionCreatedFromActiveProjectAndPassedToBackgroundActionRunner ()
- {
- CreateReinstaller ();
-
- Run ("MyPackage", "1.2.3.4");
-
- Assert.AreEqual (1, project.ReinstallPackageActionsCreated.Count);
- Assert.AreEqual (project.ReinstallPackageActionsCreated [0], backgroundRunner.ActionRun);
- }
-
- [Test]
- public void Run_ReinstallSucceeds_ReinstallActionHasPackageIdAndVersionSet ()
- {
- CreateReinstaller ();
-
- Run ("MyPackage", "1.2.3.4");
-
- var reinstallAction = backgroundRunner.ActionRun as ReinstallPackageAction;
- Assert.AreEqual ("MyPackage", reinstallAction.PackageId);
- Assert.AreEqual (new SemanticVersion ("1.2.3.4"), reinstallAction.PackageVersion);
- }
-
- [Test]
- public void Run_ReinstallThrowsException_ExceptionReported ()
- {
- CreateReinstaller ();
- var exception = new Exception ("error");
- backgroundRunner.RunAction = (progressMessage, action) => {
- throw exception;
- };
-
- Run ("MyPackage", "1.2.3.4");
-
- Assert.AreEqual (exception, backgroundRunner.ShowErrorException);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageRepositoryCacheTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageRepositoryCacheTests.cs deleted file mode 100644 index 58aad3dd12..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageRepositoryCacheTests.cs +++ /dev/null @@ -1,485 +0,0 @@ -//
-// PackageRepositoryCacheTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageRepositoryCacheTests
- {
- PackageRepositoryCache cache;
- FakePackageRepositoryFactory fakePackageRepositoryFactory;
- PackageSource nuGetPackageSource;
- OneRegisteredPackageSourceHelper packageSourcesHelper;
- RecentPackageInfo[] recentPackagesPassedToCreateRecentPackageRepository;
- FakePackageRepository fakeAggregateRepositoryPassedToCreateRecentPackageRepository;
- FakePackageRepository machineCache;
-
- void CreateCache ()
- {
- CreatePackageSources ();
- CreateCacheUsingPackageSources ();
- }
-
- void CreatePackageSources ()
- {
- packageSourcesHelper = new OneRegisteredPackageSourceHelper ();
- }
-
- void CreateCacheUsingPackageSources ()
- {
- fakePackageRepositoryFactory = new FakePackageRepositoryFactory ();
- CreateCacheUsingPackageSources (fakePackageRepositoryFactory);
- }
-
- void CreateCacheUsingPackageSources (IMonoDevelopPackageRepositoryFactory repositoryFactory)
- {
- nuGetPackageSource = new PackageSource ("http://nuget.org", "NuGet");
- machineCache = new FakePackageRepository ();
- cache = new PackageRepositoryCache (packageSourcesHelper.Options, machineCache, repositoryFactory);
- }
-
- FakePackageRepository AddFakePackageRepositoryForPackageSource (string source)
- {
- return fakePackageRepositoryFactory.AddFakePackageRepositoryForPackageSource (source);
- }
-
- IPackageRepository CreateRecentPackageRepositoryPassingAggregateRepository ()
- {
- recentPackagesPassedToCreateRecentPackageRepository = new RecentPackageInfo[0];
- fakeAggregateRepositoryPassedToCreateRecentPackageRepository = new FakePackageRepository ();
-
- return cache.CreateRecentPackageRepository (
- recentPackagesPassedToCreateRecentPackageRepository,
- fakeAggregateRepositoryPassedToCreateRecentPackageRepository);
- }
-
- RecentPackageInfo AddOneRecentPackage ()
- {
- var recentPackage = new RecentPackageInfo ("Id", new SemanticVersion ("1.0"));
- packageSourcesHelper.Options.RecentPackages.Add (recentPackage);
- return recentPackage;
- }
-
- [Test]
- public void CreateRepository_CacheCastToIMonoDevelopPackageRepositoryFactory_CreatesPackageRepositoryUsingPackageRepositoryFactoryPassedInConstructor ()
- {
- CreateCache ();
- var factory = cache as IMonoDevelopPackageRepositoryFactory;
- IPackageRepository repository = factory.CreateRepository (nuGetPackageSource.Source);
-
- Assert.AreEqual (fakePackageRepositoryFactory.FakePackageRepository, repository);
- }
-
- [Test]
- public void CreateRepository_PackageSourcePassed_PackageSourceUsedToCreateRepository ()
- {
- CreateCache ();
- cache.CreateRepository (nuGetPackageSource.Source);
-
- string actualPackageSource = fakePackageRepositoryFactory.FirstPackageSourcePassedToCreateRepository;
- Assert.AreEqual (nuGetPackageSource.Source, actualPackageSource);
- }
-
- [Test]
- public void CreateRepository_RepositoryAlreadyCreatedForPackageSource_NoRepositoryCreated ()
- {
- CreateCache ();
- cache.CreateRepository (nuGetPackageSource.Source);
- fakePackageRepositoryFactory.PackageSourcesPassedToCreateRepository.Clear ();
-
- cache.CreateRepository (nuGetPackageSource.Source);
-
- Assert.AreEqual (0, fakePackageRepositoryFactory.PackageSourcesPassedToCreateRepository.Count);
- }
-
- [Test]
- public void CreateRepository_RepositoryAlreadyCreatedForPackageSource_RepositoryOriginallyCreatedIsReturned ()
- {
- CreateCache ();
- IPackageRepository originallyCreatedRepository = cache.CreateRepository (nuGetPackageSource.Source);
- fakePackageRepositoryFactory.PackageSourcesPassedToCreateRepository.Clear ();
-
- IPackageRepository repository = cache.CreateRepository (nuGetPackageSource.Source);
-
- Assert.AreSame (originallyCreatedRepository, repository);
- }
-
- [Test]
- public void CreateSharedRepository_MethodCalled_ReturnsSharedPackageRepository ()
- {
- CreateCache ();
- ISharedPackageRepository repository = cache.CreateSharedRepository (null, null, null);
- Assert.IsNotNull (repository);
- }
-
- [Test]
- public void CreatedSharedRepository_PathResolverPassed_PathResolverUsedToCreatedSharedRepository ()
- {
- CreateCache ();
- FakePackagePathResolver resolver = new FakePackagePathResolver ();
- cache.CreateSharedRepository (resolver, null, null);
-
- Assert.AreEqual (resolver, fakePackageRepositoryFactory.PathResolverPassedToCreateSharedRepository);
- }
-
- [Test]
- public void CreatedSharedRepository_FileSystemPassed_FileSystemUsedToCreatedSharedRepository ()
- {
- CreateCache ();
- FakeFileSystem fileSystem = new FakeFileSystem ();
- cache.CreateSharedRepository (null, fileSystem, null);
-
- Assert.AreEqual (fileSystem, fakePackageRepositoryFactory.FileSystemPassedToCreateSharedRepository);
- }
-
- [Test]
- public void CreatedSharedRepository_ConfigSettingsFileSystemPassed_FileSystemUsedToCreatedSharedRepository ()
- {
- CreateCache ();
- FakeFileSystem fileSystem = new FakeFileSystem ();
- cache.CreateSharedRepository (null, null, fileSystem);
-
- Assert.AreEqual (fileSystem, fakePackageRepositoryFactory.ConfigSettingsFileSystemPassedToCreateSharedRepository);
- }
-
- [Test]
- public void CreateAggregatePackageRepository_TwoRegisteredPackageRepositories_ReturnsAggregateRepositoryFromFactory ()
- {
- CreatePackageSources ();
- packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
- CreateCacheUsingPackageSources ();
-
- IPackageRepository aggregateRepository = cache.CreateAggregateRepository ();
- FakePackageRepository expectedRepository = fakePackageRepositoryFactory.FakeAggregateRepository;
-
- Assert.AreEqual (expectedRepository, aggregateRepository);
- }
-
- [Test]
- public void CreateAggregatePackageRepository_TwoRegisteredPackageSourcesButOneDisabled_ReturnsAggregateRepositoryCreatedWithOnlyEnabledPackageSource ()
- {
- CreatePackageSources ();
- packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
- packageSourcesHelper.RegisteredPackageSources [0].IsEnabled = false;
- CreateCacheUsingPackageSources ();
- AddFakePackageRepositoryForPackageSource ("Source1");
- FakePackageRepository repository2 = AddFakePackageRepositoryForPackageSource ("Source2");
- var expectedRepositories = new FakePackageRepository[] {
- repository2
- };
-
- cache.CreateAggregateRepository ();
-
- IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository =
- fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;
-
- var actualRepositoriesAsList = new List<IPackageRepository> (repositoriesUsedToCreateAggregateRepository);
- IPackageRepository[] actualRepositories = actualRepositoriesAsList.ToArray ();
-
- CollectionAssert.AreEqual (expectedRepositories, actualRepositories);
- }
-
- [Test]
- public void CreateAggregatePackageRepository_TwoRegisteredPackageRepositories_AllRegisteredRepositoriesUsedToCreateAggregateRepositoryFromFactory ()
- {
- CreatePackageSources ();
- packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
- CreateCacheUsingPackageSources ();
-
- FakePackageRepository repository1 = AddFakePackageRepositoryForPackageSource ("Source1");
- FakePackageRepository repository2 = AddFakePackageRepositoryForPackageSource ("Source2");
- var expectedRepositories = new FakePackageRepository[] {
- repository1,
- repository2
- };
-
- cache.CreateAggregateRepository ();
-
- IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository =
- fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;
-
- var actualRepositoriesAsList = new List<IPackageRepository> (repositoriesUsedToCreateAggregateRepository);
- IPackageRepository[] actualRepositories = actualRepositoriesAsList.ToArray ();
-
- CollectionAssert.AreEqual (expectedRepositories, actualRepositories);
- }
-
- [Test]
- public void CreateAggregatePackageRepository_OnePackageRepositoryPassed_ReturnsAggregateRepositoryFromFactory ()
- {
- CreateCache ();
-
- var repositories = new FakePackageRepository[] {
- new FakePackageRepository ()
- };
- IPackageRepository aggregateRepository = cache.CreateAggregateRepository (repositories);
-
- FakePackageRepository expectedRepository = fakePackageRepositoryFactory.FakeAggregateRepository;
-
- Assert.AreEqual (expectedRepository, aggregateRepository);
- }
-
- [Test]
- public void CreateAggregatePackageRepository_OnePackageRepositoryPassed_RepositoryUsedToCreateAggregateRepository ()
- {
- CreateCache ();
-
- var repositories = new FakePackageRepository[] {
- new FakePackageRepository ()
- };
- cache.CreateAggregateRepository (repositories);
-
- IEnumerable<IPackageRepository> repositoriesUsedToCreateAggregateRepository =
- fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository;
-
- Assert.AreEqual (repositories, repositoriesUsedToCreateAggregateRepository);
- }
-
- [Test]
- public void RecentPackageRepository_NoRecentPackages_ReturnsRecentRepositoryCreatedByFactory ()
- {
- CreateCache ();
- IRecentPackageRepository repository = cache.RecentPackageRepository;
- FakeRecentPackageRepository expectedRepository = fakePackageRepositoryFactory.FakeRecentPackageRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void RecentPackageRepository_NoRecentPackages_CreatedWithAggregateRepository ()
- {
- CreateCache ();
- IRecentPackageRepository repository = cache.RecentPackageRepository;
-
- IPackageRepository expectedRepository = MachineCache.Default;
- IPackageRepository actualRepository = fakePackageRepositoryFactory.AggregateRepositoryPassedToCreateRecentPackageRepository;
-
- Assert.AreEqual (expectedRepository, actualRepository);
- }
-
- [Test]
- public void RecentPackageRepository_OneRecentPackage_RecentPackageUsedToCreateRecentPackageRepository ()
- {
- CreateCache ();
- RecentPackageInfo recentPackage = AddOneRecentPackage ();
-
- IRecentPackageRepository repository = cache.RecentPackageRepository;
-
- IList<RecentPackageInfo> actualRecentPackages = fakePackageRepositoryFactory.RecentPackagesPassedToCreateRecentPackageRepository;
-
- var expectedRecentPackages = new RecentPackageInfo[] {
- recentPackage
- };
-
- Assert.AreEqual (expectedRecentPackages, actualRecentPackages);
- }
-
- [Test]
- public void RecentPackageRepository_PropertyAccessedTwice_AggregateRepositoryCreatedOnce ()
- {
- CreateCache ();
- IRecentPackageRepository repository = cache.RecentPackageRepository;
- fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository = null;
- repository = cache.RecentPackageRepository;
-
- Assert.IsNull (fakePackageRepositoryFactory.RepositoriesPassedToCreateAggregateRepository);
- }
-
- [Test]
- public void CreateRecentPackageRepository_AggregateRepositoryPassedAndNoRecentPackagesPassed_UsesFactoryToCreateRepository ()
- {
- CreateCache ();
- IPackageRepository repository = CreateRecentPackageRepositoryPassingAggregateRepository ();
-
- FakeRecentPackageRepository expectedRepository = fakePackageRepositoryFactory.FakeRecentPackageRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void CreateRecentPackageRepository_AggregateRepositoryPassedAndNoRecentPackagesPassed_AggregateIsUsedToCreateRepository ()
- {
- CreateCache ();
- CreateRecentPackageRepositoryPassingAggregateRepository ();
-
- IPackageRepository actualRepository = fakePackageRepositoryFactory.AggregateRepositoryPassedToCreateRecentPackageRepository;
-
- Assert.AreEqual (fakeAggregateRepositoryPassedToCreateRecentPackageRepository, actualRepository);
- }
-
- [Test]
- public void CreateRecentPackageRepository_AggregateRepositoryPassedAndNoRecentPackagesPassed_RecentPackagesUsedToCreateRepository ()
- {
- CreateCache ();
- CreateRecentPackageRepositoryPassingAggregateRepository ();
-
- IList<RecentPackageInfo> recentPackages = fakePackageRepositoryFactory.RecentPackagesPassedToCreateRecentPackageRepository;
-
- Assert.AreEqual (recentPackagesPassedToCreateRecentPackageRepository, recentPackages);
- }
-
- [Test]
- public void CreateRecentPackageRepository_MethodCalledTwice_RecentPackageRepositoryCreatedOnce ()
- {
- CreateCache ();
- CreateRecentPackageRepositoryPassingAggregateRepository ();
- fakePackageRepositoryFactory.AggregateRepositoryPassedToCreateRecentPackageRepository = null;
- CreateRecentPackageRepositoryPassingAggregateRepository ();
-
- Assert.IsNull (fakePackageRepositoryFactory.AggregateRepositoryPassedToCreateRecentPackageRepository);
- }
-
- [Test]
- public void CreateRepository_NewRepositoryCreated_RepositoryCreatedEventFired ()
- {
- CreateCache ();
- PackageRepositoryFactoryEventArgs eventArgs = null;
- cache.RepositoryCreated += (sender, e) => eventArgs = e;
-
- cache.CreateRepository (nuGetPackageSource.Source);
-
- Assert.AreEqual (fakePackageRepositoryFactory.FakePackageRepository, eventArgs.Repository);
- }
-
- [Test]
- public void CreateRepository_RepositoryCreatedTwice_RepositoryCreatedEventIsNotFiredOnSecondCallToCreateRepository ()
- {
- CreateCache ();
- cache.CreateRepository (nuGetPackageSource.Source);
- PackageRepositoryFactoryEventArgs eventArgs = null;
- cache.RepositoryCreated += (sender, e) => eventArgs = e;
-
- cache.CreateRepository (nuGetPackageSource.Source);
-
- Assert.IsNull (eventArgs);
- }
-
- [Test]
- public void CreateAggregateRepository_SolutionClosedAndEnabledPackageSourcesChangedAfterCacheCreated_AggregateRepositoryContainsCorrectEnabledPackageRepositories ()
- {
- CreatePackageSources ();
- packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
- CreateCacheUsingPackageSources ();
- FakePackageRepository source1Repo = AddFakePackageRepositoryForPackageSource ("Source1");
- FakePackageRepository source2Repo = AddFakePackageRepositoryForPackageSource ("Source2");
- fakePackageRepositoryFactory.CreateAggregrateRepositoryAction = (repositories) => {
- return new AggregateRepository (repositories);
- };
- var initialAggregateRepository = cache.CreateAggregateRepository () as AggregateRepository;
- var expectedInitialRepositories = new FakePackageRepository [] {
- source1Repo,
- source2Repo
- };
- List<IPackageRepository> actualInitialRepositories = initialAggregateRepository.Repositories.ToList ();
- packageSourcesHelper.Options.ProjectService.RaiseSolutionUnloadedEvent ();
- packageSourcesHelper.Options.PackageSources.Clear ();
- packageSourcesHelper.Options.PackageSources.Add (new PackageSource ("Source3"));
- FakePackageRepository source3Repo = AddFakePackageRepositoryForPackageSource ("Source3");
- var expectedRepositories = new FakePackageRepository [] {
- source3Repo
- };
-
- var aggregateRepository = cache.CreateAggregateRepository () as AggregateRepository;
- List<IPackageRepository> actualRepositories = aggregateRepository.Repositories.ToList ();
-
- CollectionAssert.AreEqual (expectedInitialRepositories, actualInitialRepositories);
- CollectionAssert.AreEqual (expectedRepositories, actualRepositories);
- }
-
- [Test]
- public void CreateAggregatePriorityRepository_NoAggregatePackageSources_ReturnsPriorityPackageRepositoryThatUsesMachineCache ()
- {
- CreateCache ();
- machineCache.AddFakePackageWithVersion ("MyPackage", "1.0");
-
- IPackageRepository repository = cache.CreateAggregateWithPriorityMachineCacheRepository ();
- bool exists = repository.Exists ("MyPackage", new SemanticVersion ("1.0"));
-
- Assert.IsInstanceOf<PriorityPackageRepository> (repository);
- Assert.IsTrue (exists);
- }
-
- [Test]
- public void CreateAggregatePriorityRepository_NoAggregatePackageSources_ReturnsPriorityPackageRepositoryThatUsesAggregateRepository ()
- {
- CreatePackageSources ();
- packageSourcesHelper.AddTwoPackageSources ("Source1", "Source2");
- CreateCacheUsingPackageSources ();
- fakePackageRepositoryFactory.FakeAggregateRepository.AddFakePackageWithVersion ("MyPackage", "1.0");
-
- IPackageRepository repository = cache.CreateAggregateWithPriorityMachineCacheRepository ();
- bool exists = repository.Exists ("MyPackage", new SemanticVersion ("1.0"));
-
- Assert.IsTrue (exists);
- }
-
- [Test]
- public void CreateAggregateRepository_OnePackageSourceHasInvalidUri_NoExceptionThrownWhenCreatingAggregateRepositoryAndSearchingForPackages ()
- {
- CreatePackageSources ();
- packageSourcesHelper.RegisteredPackageSources.Clear ();
- var invalidPackageSource = new PackageSource (String.Empty, "InvalidSource");
- packageSourcesHelper.RegisteredPackageSources.Add (invalidPackageSource);
- var factory = new MonoDevelopPackageRepositoryFactory ();
- CreateCacheUsingPackageSources (factory);
- IPackageRepository repository = cache.CreateAggregateRepository ();
- var aggregateRepository = (MonoDevelopAggregateRepository)repository;
-
- Assert.IsFalse (aggregateRepository.AnyFailures ());
- Assert.DoesNotThrow (() => repository.Search ("abc", false));
- Assert.IsTrue (aggregateRepository.AnyFailures ());
- }
-
- [Test]
- public void CreateAggregateRepository_OnePackageSourceHasInvalidUriAndSearchExecutedMultipleTimes_ExceptionThrownByPackageRepositoryIsOnlyRecordedOnce ()
- {
- CreatePackageSources ();
- packageSourcesHelper.RegisteredPackageSources.Clear ();
- var invalidPackageSource = new PackageSource (String.Empty, "InvalidSource");
- packageSourcesHelper.RegisteredPackageSources.Add (invalidPackageSource);
- var factory = new MonoDevelopPackageRepositoryFactory ();
- CreateCacheUsingPackageSources (factory);
- IPackageRepository repository = cache.CreateAggregateRepository ();
- var aggregateRepository = (MonoDevelopAggregateRepository)repository;
-
- repository.Search ("abc", false);
- repository.Search ("abc", false);
- repository.Search ("abc", false);
-
- Assert.IsTrue (aggregateRepository.AnyFailures ());
- Assert.AreEqual (1, aggregateRepository.GetAggregateException ().InnerExceptions.Count);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSearchCriteriaTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSearchCriteriaTests.cs deleted file mode 100644 index 123013b58e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSearchCriteriaTests.cs +++ /dev/null @@ -1,82 +0,0 @@ -//
-// PackageSearchCriteriaTests.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 NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageSearchCriteriaTests
- {
- PackageSearchCriteria search;
-
- void CreateSearch (string text)
- {
- search = new PackageSearchCriteria (text);
- }
-
- [TestCase ("NUnit", false)]
- [TestCase ("NUnit version:*", true)]
- [TestCase ("NUnit version:", true)]
- [TestCase ("NUnit ver", false)]
- [TestCase ("NUnit VERSION:*", true)]
- [TestCase ("NUnit aversion:", false)]
- [TestCase ("NUnit Version:*", true)]
- [TestCase (" NUnit Version: ", true)]
- [TestCase (" NUnit Version:* ", true)]
- public void IsPackageVersionSearch (string searchText, bool expectedResult)
- {
- CreateSearch (searchText);
-
- bool result = search.IsPackageVersionSearch;
-
- Assert.AreEqual (expectedResult, result);
- }
-
- [TestCase ("NUnit version:", "1.0", true)]
- [TestCase ("NUnit version:*", "1.0", true)]
- [TestCase ("NUnit version:1.0", "1.0", true)]
- [TestCase ("NUnit version:1.0", "1.1", false)]
- [TestCase ("NUnit version:1", "1.0", true)]
- [TestCase ("NUnit version:1", "1.1", true)]
- [TestCase ("NUnit version:1", "1.9", true)]
- [TestCase ("NUnit version:1", "1.9.2", true)]
- [TestCase ("NUnit version:1", "2.0", false)]
- [TestCase (" NUnit version:1 ", "2.0", false)]
- [TestCase (" NUnit version:1 ", "1.9", true)]
- public void IsVersionMatch (string searchText, string versionToMatch, bool expectedResult)
- {
- CreateSearch (searchText);
-
- bool result = search.IsVersionMatch (new SemanticVersion (versionToMatch));
-
- Assert.AreEqual (expectedResult, result);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSearchResultViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSearchResultViewModelTests.cs new file mode 100644 index 0000000000..d2a033fe46 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSearchResultViewModelTests.cs @@ -0,0 +1,634 @@ +// +// PackageSearchResultViewModelTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using MonoDevelop.PackageManagement.Tests.Helpers; +using NuGet.Common; +using NuGet.Configuration; +using NuGet.Frameworks; +using NuGet.PackageManagement.UI; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class PackageSearchResultViewModelTests + { + TestablePackageSearchResultViewModel viewModel; + PackageItemListViewModel packageItemListViewModel; + TestableAllPackagesViewModel parent; + FakePackageMetadataProvider metadataProvider; + List<VersionInfo> packageVersions; + FakePackageSearchMetadata packageSearchMetadata; + FakePackageMetadataResource packageMetadataResource; + + void CreateViewModel () + { + CreatePackageItemListViewModel (); + CreateViewModel (packageItemListViewModel); + } + + PackageItemListViewModel CreatePackageItemListViewModel () + { + packageVersions = new List<VersionInfo> (); + packageItemListViewModel = new PackageItemListViewModel { + Id = "TestPackage", + Version = new NuGetVersion ("1.2.3"), + Versions = AsyncLazy.New (() => { + return Task.FromResult (packageVersions.AsEnumerable ()); + }) + }; + return packageItemListViewModel; + } + + void CreateViewModel (PackageItemListViewModel package) + { + metadataProvider = new FakePackageMetadataProvider (); + packageSearchMetadata = metadataProvider.AddPackageMetadata (package.Id, package.Version.ToString ()); + var solutionManager = new FakeSolutionManager (); + var project = new FakeDotNetProject (); + parent = new TestableAllPackagesViewModel (solutionManager, project); + viewModel = new TestablePackageSearchResultViewModel (parent, packageItemListViewModel); + } + + Task LoadPackageMetadata () + { + viewModel.LoadPackageMetadata (metadataProvider, CancellationToken.None); + return viewModel.LoadPackageMetadataTask; + } + + void AddSinglePackageDependencyToSearchMetadata () + { + var dependencies = new [] { + new PackageDependency ("Test") + }; + AddDependenciesToSearchMetadata (dependencies); + } + + void AddDependenciesToSearchMetadata (params PackageDependency [] dependencies) + { + var dependencyGroup = new PackageDependencyGroup ( + new NuGetFramework ("any"), + dependencies); + packageSearchMetadata.DependencySetsList.Add (dependencyGroup); + } + + Task ReadVersions () + { + viewModel.LoadPackageMetadata (metadataProvider, CancellationToken.None); + return viewModel.ReadVersionsTask; + } + + void AddVersionsToPackageItemListViewModel (params string[] versions) + { + var versionInfos = versions + .Select (version => new NuGetVersion (version)) + .Select (version => new VersionInfo (version)); + packageVersions.AddRange (versionInfos); + } + + void SelectPackageSourceInParentViewModel () + { + var metadataResourceProvider = new FakePackageMetadataResourceProvider (); + packageMetadataResource = metadataResourceProvider.PackageMetadataResource; + var source = new PackageSource ("http://test.com"); + var providers = new INuGetResourceProvider[] { + metadataResourceProvider + }; + var sourceRepository = new SourceRepository (source, providers); + parent.SelectedPackageSource = new SourceRepositoryViewModel (sourceRepository); + } + + async Task WaitForLoadPackageMetadataTask () + { + const int maximumDelayCount = 10; + int count = 0; + while (viewModel.LoadPackageMetadataTask == null && count < maximumDelayCount) { + await Task.Delay (10); + count++; + } + + if (viewModel.LoadPackageMetadataTask != null) { + await viewModel.LoadPackageMetadataTask; + } else { + throw new ApplicationException ("LoadPackageMetadataTask never started."); + } + } + + [Test] + public void HasLicenseUrl_PackageHasLicenseUrl_ReturnsTrue () + { + CreateViewModel (); + packageItemListViewModel.LicenseUrl = new Uri ("http://monodevelop.com"); + + Assert.IsTrue (viewModel.HasLicenseUrl); + } + + [Test] + public void HasLicenseUrl_PackageHasNoLicenseUrl_ReturnsFalse () + { + CreateViewModel (); + packageItemListViewModel.LicenseUrl = null; + + Assert.IsFalse (viewModel.HasLicenseUrl); + } + + [Test] + public void HasProjectUrl_PackageHasProjectUrl_ReturnsTrue () + { + CreateViewModel (); + packageItemListViewModel.ProjectUrl = new Uri ("http://monodevelop.com"); + + Assert.IsTrue (viewModel.HasProjectUrl); + } + + [Test] + public void HasProjectUrl_PackageHasNoProjectUrl_ReturnsFalse () + { + CreateViewModel (); + packageItemListViewModel.ProjectUrl = null; + + Assert.IsFalse (viewModel.HasProjectUrl); + } + + [Test] + public void IsDependencyInformationAvailable_DependenciesNotRead_ReturnsFalse () + { + CreateViewModel (); + + Assert.IsFalse (viewModel.IsDependencyInformationAvailable); + } + + [Test] + public async Task HasDependencies_PackageHasNoDependencies_ReturnsFalse () + { + CreateViewModel (); + await LoadPackageMetadata (); + + Assert.IsFalse (viewModel.HasDependencies); + } + + [Test] + public async Task HasDependencies_PackageHasDependency_ReturnsTrue () + { + CreateViewModel (); + AddSinglePackageDependencyToSearchMetadata (); + await LoadPackageMetadata (); + + Assert.IsTrue (viewModel.HasDependencies); + } + + [Test] + public async Task HasNoDependencies_PackageHasNoDependencies_ReturnsTrue () + { + CreateViewModel (); + await LoadPackageMetadata (); + + Assert.IsTrue (viewModel.HasNoDependencies); + } + + [Test] + public async Task HasNoDependencies_PackageHasOneDependency_ReturnsFalse () + { + CreateViewModel (); + AddSinglePackageDependencyToSearchMetadata (); + await LoadPackageMetadata (); + + Assert.IsFalse (viewModel.HasNoDependencies); + } + + [Test] + public void HasDownloadCount_DownloadCountIsZero_ReturnsTrue () + { + CreateViewModel (); + packageItemListViewModel.DownloadCount = 0; + + Assert.IsTrue (viewModel.HasDownloadCount); + } + + [Test] + public void HasDownloadCount_DownloadCountIsMinusOne_ReturnsFalse () + { + CreateViewModel (); + packageItemListViewModel.DownloadCount = -1; + + Assert.IsFalse (viewModel.HasDownloadCount); + } + + [Test] + public void HasLastPublished_PackageHasPublishedDate_ReturnsTrue () + { + CreateViewModel (); + packageItemListViewModel.Published = new DateTime (2011, 1, 2); + + Assert.IsTrue (viewModel.HasLastPublished); + } + + [Test] + public void HasLastPublished_PackageHasNoPublishedDate_ReturnsFalse () + { + CreateViewModel (); + packageItemListViewModel.Published = null; + + Assert.IsFalse (viewModel.HasLastPublished); + } + + [Test] + public void LastPublished_PackageHasPublishedDate_ReturnsPackagePublishedDate () + { + CreateViewModel (); + packageItemListViewModel.Published = new DateTime (2011, 1, 2); + + Assert.AreEqual (packageItemListViewModel.Published, viewModel.LastPublished); + } + + [Test] + public void LastPublished_PackageHasNoPublishedDate_ReturnsNull () + { + CreateViewModel (); + packageItemListViewModel.Published = null; + + Assert.IsNull (viewModel.LastPublished); + } + + [Test] + public void Summary_PackageHasSummary_PackageSummaryReturned () + { + CreateViewModel (); + packageItemListViewModel.Summary = "Expected summary"; + + string summary = viewModel.Summary; + + Assert.AreEqual ("Expected summary", summary); + } + + [Test] + public void Summary_PackageHasDescriptionButNoSummary_PackageDescriptionReturned () + { + CreateViewModel (); + packageItemListViewModel.Summary = String.Empty; + packageItemListViewModel.Description = "Expected description"; + + string summary = viewModel.Summary; + + Assert.AreEqual ("Expected description", summary); + } + + [Test] + public void Summary_PackageSummaryHasNewLinesAndExtraWhitespaceAtStartOfLine_SummaryHasNoNewLinesAndWhitespaceIsMinimized () + { + CreateViewModel (); + packageItemListViewModel.Summary = "First.\n Second.\n Third.\n"; + + string summary = viewModel.Summary; + + Assert.AreEqual ("First. Second. Third.", summary); + } + + [Test] + public void Name_PackageHasIdButNoTitle_ReturnsPackageId () + { + CreateViewModel (); + packageItemListViewModel.Id = "MyPackage"; + + string name = viewModel.Name; + + Assert.AreEqual ("MyPackage", name); + } + + [Test] + public void Name_PackageHasIdAndTitle_ReturnsPackageId () + { + CreateViewModel (); + packageItemListViewModel.Id = "MyPackage"; + packageItemListViewModel.Title = "My Package Title"; + + string name = viewModel.Name; + + Assert.AreEqual ("My Package Title", name); + } + + [Test] + public void GetNameMarkup_PackageHasId_ReturnsBoldPackageId () + { + CreateViewModel (); + packageItemListViewModel.Id = "MyPackage"; + + string name = viewModel.GetNameMarkup (); + + Assert.AreEqual ("<b>MyPackage</b>", name); + } + + [Test] + public void HasNoGalleryUrl_PackageHasNoGalleryUrl_ReturnsFalse () + { + CreateViewModel (); + + bool result = viewModel.HasGalleryUrl; + + Assert.IsFalse (result); + } + + [Test] + public void IsGalleryUrlMissing_PackageHasNoGalleryUrl_ReturnsTrue () + { + CreateViewModel (); + + bool result = viewModel.HasNoGalleryUrl; + + Assert.IsTrue (result); + } + + [Test] + public void GetDownloadCountOrVersionDisplayText_PackageDownloadCountIsMinusOne_ReturnsEmptyString () + { + CreateViewModel (); + packageItemListViewModel.DownloadCount = -1; + + string result = viewModel.GetDownloadCountOrVersionDisplayText (); + + Assert.AreEqual (String.Empty, result); + } + + [Test] + public void GetDownloadCountOrVersionDisplayText_PackageHasTenThousandDownloads_ReturnsDownloadCountFormattedForLocale () + { + CreateViewModel (); + packageItemListViewModel.DownloadCount = 10000; + + string result = viewModel.GetDownloadCountOrVersionDisplayText (); + + string expectedResult = 10000.ToString ("N0"); + Assert.AreEqual (expectedResult, result); + } + + [Test] + public void GetDownloadCountOrVersionDisplayText_PackageWasPartOfGroupIncludingAllVersions_ReturnsVersionNumberInsteadOfDownloadCount () + { + CreateViewModel (); + viewModel.ShowVersionInsteadOfDownloadCount = true; + packageItemListViewModel.DownloadCount = 10000; + packageItemListViewModel.Version = new NuGetVersion ("1.2.3.4"); + + string result = viewModel.GetDownloadCountOrVersionDisplayText (); + + Assert.AreEqual ("1.2.3.4", result); + } + + [Test] + public void SelectedVersion_PackageHasVersion_UsesLatestPackageVersionByDefault () + { + var package = CreatePackageItemListViewModel (); + package.Version = new NuGetVersion ("1.2.3"); + CreateViewModel (package); + + Assert.AreEqual ("1.2.3", viewModel.SelectedVersion.ToString ()); + } + + [Test] + public void UpdateFromPreviouslyCheckedViewModel_VersionSelectedIsLatestVersion_VersionsIsEmpty () + { + var package = CreatePackageItemListViewModel (); + package.Version = new NuGetVersion ("1.2.3"); + CreateViewModel (package); + var checkedViewModel = viewModel; + checkedViewModel.IsChecked = true; + package = CreatePackageItemListViewModel (); + package.Version = new NuGetVersion ("1.2.3"); + CreateViewModel (package); + + viewModel.UpdateFromPreviouslyCheckedViewModel (checkedViewModel); + + Assert.IsTrue (viewModel.IsChecked); + Assert.AreEqual ("1.2.3", viewModel.SelectedVersion.ToString ()); + Assert.AreEqual (0, viewModel.Versions.Count); + } + + /// <summary> + /// Here we ensure that the latest and selected version is available from the Versions + /// property otherwise the selected version cannot be selected in the Versions drop down + /// in the UI. + /// </summary> + [Test] + public void UpdateFromPreviouslyCheckedViewModel_VersionSelectedIsDifferentToLatestVersion_VersionsHasLatestAndSelectedVersion () + { + var package = CreatePackageItemListViewModel (); + package.Version = new NuGetVersion ("1.2.3"); + CreateViewModel (package); + var checkedViewModel = viewModel; + checkedViewModel.IsChecked = true; + checkedViewModel.SelectedVersion = new NuGetVersion ("1.0.2"); + package = CreatePackageItemListViewModel (); + package.Version = new NuGetVersion ("1.2.3"); + CreateViewModel (package); + + viewModel.UpdateFromPreviouslyCheckedViewModel (checkedViewModel); + + Assert.IsTrue (viewModel.IsChecked); + Assert.AreEqual ("1.0.2", viewModel.SelectedVersion.ToString ()); + Assert.AreEqual (2, viewModel.Versions.Count); + Assert.AreEqual ("1.2.3", viewModel.Versions[0].ToString ()); + Assert.AreEqual ("1.0.2", viewModel.Versions[1].ToString ()); + } + + /// <summary> + /// NuGet v3 does not have a published date until the metadata is read separately. + /// </summary> + [Test] + public async Task LoadPackageMetadata_ViewModelDidNotHavePublishedDate_PublishedDateReadFromLoadedMetadata () + { + CreateViewModel (); + packageItemListViewModel.Published = null; + packageSearchMetadata.Published = new DateTimeOffset (2000, 1, 30, 10, 58, 30, new TimeSpan ()); + await LoadPackageMetadata (); + + Assert.IsTrue (viewModel.IsDependencyInformationAvailable); + Assert.AreEqual (viewModel.LastPublished, packageSearchMetadata.Published); + } + + [Test] + public async Task LoadPackageMetadata_NoDependencies_PropertyChangedForDependencies () + { + CreateViewModel (); + bool dependenciesChanged = false; + viewModel.PropertyChanged += (sender, e) => { + if (e.PropertyName == "Dependencies") + dependenciesChanged = true; + }; + await LoadPackageMetadata (); + + Assert.IsTrue (viewModel.IsDependencyInformationAvailable); + Assert.IsTrue (dependenciesChanged); + } + + [Test] + public async Task GetPackageDependenciesDisplayText_TwoDependenciesWithVersionRange_DependenciesReturnedInText () + { + CreateViewModel (); + var dependencies = new [] { + new PackageDependency ("jQuery", new VersionRange (new NuGetVersion ("1.2.3"))), + new PackageDependency ("bootstrap") + }; + AddDependenciesToSearchMetadata (dependencies); + await LoadPackageMetadata (); + + string result = viewModel.GetPackageDependenciesDisplayText (); + + Assert.That (result, Contains.Substring ("jQuery (>= 1.2.3)")); + Assert.That (result, Contains.Substring ("bootstrap")); + } + + [Test] + public async Task ReadVersions_PackageSearchMetadataHasMultipleVersions_ViewModelHasVersionsSortedByNewestFirst () + { + CreateViewModel (); + AddVersionsToPackageItemListViewModel ("0.1", "0.2", "1.0"); + + await ReadVersions (); + + Assert.AreEqual (3, viewModel.Versions.Count); + Assert.AreEqual ("1.0", viewModel.Versions[0].ToString ()); + Assert.AreEqual ("0.2", viewModel.Versions[1].ToString ()); + Assert.AreEqual ("0.1", viewModel.Versions[2].ToString ()); + } + + [Test] + public async Task ReadVersions_PackageSearchMetadataHasMultipleVersions_PropertyChangedEventFiredForVersions () + { + CreateViewModel (); + AddVersionsToPackageItemListViewModel ("0.1", "0.2"); + bool propertyChanged = false; + viewModel.PropertyChanged += (sender, e) => { + if (e.PropertyName == "Versions") + propertyChanged = true; + }; + await ReadVersions (); + + Assert.IsTrue (propertyChanged); + } + + [Test] + public async Task ReadVersions_ViewModelHadVersionsAlready_VersionsClearedBeforePopulating () + { + CreateViewModel (); + viewModel.Versions.Add (new NuGetVersion ("9.99")); + AddVersionsToPackageItemListViewModel ("0.1"); + + await ReadVersions (); + + Assert.AreEqual (1, viewModel.Versions.Count); + Assert.AreEqual ("0.1", viewModel.Versions[0].ToString ()); + } + + [Test] + public async Task ReadVersions_RecentPackage_VersionInfoRequestedAgainFromSourceRepository () + { + CreateViewModel (); + packageItemListViewModel.Id = "Test"; + packageItemListViewModel.Version = new NuGetVersion ("1.2"); + viewModel.IsRecentPackage = true; + SelectPackageSourceInParentViewModel (); + packageMetadataResource.AddPackageMetadata ("Test", "1.1"); + packageMetadataResource.AddPackageMetadata ("Test", "1.0"); + packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + + await ReadVersions (); + + Assert.AreEqual (3, viewModel.Versions.Count); + Assert.AreEqual ("1.2", viewModel.Versions[0].ToString ()); + Assert.AreEqual ("1.1", viewModel.Versions[1].ToString ()); + Assert.AreEqual ("1.0", viewModel.Versions[2].ToString ()); + } + + [Test] + public async Task LoadPackageMetadata_RecentPackage_PackageDependencyInformationIsLoaded () + { + CreateViewModel (); + packageItemListViewModel.Id = "Test"; + packageItemListViewModel.Version = new NuGetVersion ("1.2"); + viewModel.IsRecentPackage = true; + SelectPackageSourceInParentViewModel (); + packageMetadataResource.AddPackageMetadata ("Test", "1.1"); + packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + var dependencies = new [] { + new PackageDependency ("jQuery") + }; + AddDependenciesToSearchMetadata (dependencies); + await ReadVersions (); + await WaitForLoadPackageMetadataTask (); + + string result = viewModel.GetPackageDependenciesDisplayText (); + + Assert.That (result, Contains.Substring ("jQuery")); + } + + [Test] + public async Task ReadVersions_RecentPackageAndParentIsNotSearchingForPrereleases_NonPrereleaseVersionInfoRequestedAgainFromSourceRepository () + { + CreateViewModel (); + packageItemListViewModel.Id = "Test"; + packageItemListViewModel.Version = new NuGetVersion ("1.2-beta1"); + viewModel.IsRecentPackage = true; + parent.IncludePrerelease = false; + SelectPackageSourceInParentViewModel (); + packageMetadataResource.AddPackageMetadata ("Test", "1.1"); + packageMetadataResource.AddPackageMetadata ("Test", "1.0-beta2"); + packageMetadataResource.AddPackageMetadata ("Test", "1.2-beta1"); + + await ReadVersions (); + + Assert.AreEqual (1, viewModel.Versions.Count); + Assert.AreEqual ("1.1", viewModel.Versions[0].ToString ()); + } + + [Test] + public async Task ReadVersions_RecentPackageAndParentIsSearchingForPrereleases_PrereleaseVersionInfoRequestedAgainFromSourceRepository () + { + CreateViewModel (); + packageItemListViewModel.Id = "Test"; + packageItemListViewModel.Version = new NuGetVersion ("1.2"); + viewModel.IsRecentPackage = true; + parent.IncludePrerelease = true; + SelectPackageSourceInParentViewModel (); + packageMetadataResource.AddPackageMetadata ("Test", "1.0-beta2"); + packageMetadataResource.AddPackageMetadata ("Test", "1.2-beta1"); + + await ReadVersions (); + + Assert.AreEqual (2, viewModel.Versions.Count); + Assert.AreEqual ("1.2-beta1", viewModel.Versions[0].ToString ()); + Assert.AreEqual ("1.0-beta2", viewModel.Versions[1].ToString ()); + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSourceViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSourceViewModelTests.cs index 1f4727ff65..7a4d32e87a 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSourceViewModelTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageSourceViewModelTests.cs @@ -24,9 +24,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using MonoDevelop.PackageManagement;
-using NuGet;
+using NuGet.Configuration;
using NUnit.Framework;
namespace MonoDevelop.PackageManagement.Tests
@@ -99,7 +98,7 @@ namespace MonoDevelop.PackageManagement.Tests CreatePackageSourceWithSourceUrl ("Test-url");
CreateViewModel (packageSource);
- Assert.AreEqual ("Test-url", viewModel.SourceUrl);
+ Assert.AreEqual ("Test-url", viewModel.Source);
}
[Test]
@@ -107,9 +106,9 @@ namespace MonoDevelop.PackageManagement.Tests {
CreatePackageSourceWithSourceUrl ("source-url");
CreateViewModel (packageSource);
- viewModel.SourceUrl = "changed";
+ viewModel.Source = "changed";
- Assert.AreEqual ("changed", viewModel.SourceUrl);
+ Assert.AreEqual ("changed", viewModel.Source);
}
[Test]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageViewModelTests.cs deleted file mode 100644 index 86800e3cec..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackageViewModelTests.cs +++ /dev/null @@ -1,808 +0,0 @@ -//
-// PackageViewModelTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackageViewModelTests
- {
- TestablePackageViewModel viewModel;
- FakePackage fakePackage;
- FakePackageManagementSolution fakeSolution;
- PackageManagementEvents packageManagementEvents;
- FakeUninstallPackageAction fakeUninstallPackageAction;
- FakeLogger fakeLogger;
- List<PackageManagementSelectedProject> fakeSelectedProjects;
- AvailablePackagesViewModel viewModelParent;
-
- void CreateFakeSolution ()
- {
- fakeSolution = new FakePackageManagementSolution ();
- fakeSolution.FakeActiveDotNetProject = ProjectHelper.CreateTestProject ();
- }
-
- void CreateViewModel ()
- {
- CreateFakeSolution ();
- CreateViewModel (fakeSolution);
- }
-
- void CreateViewModel (FakePackageManagementSolution solution)
- {
- viewModelParent = CreateViewModelParent (solution);
- viewModel = new TestablePackageViewModel (viewModelParent, solution);
- fakePackage = viewModel.FakePackage;
- this.fakeSolution = solution;
- packageManagementEvents = viewModel.PackageManagementEvents;
- fakeLogger = viewModel.FakeLogger;
- fakeUninstallPackageAction = solution.FakeProjectToReturnFromGetProject.FakeUninstallPackageAction;
- }
-
- AvailablePackagesViewModel CreateViewModelParent (FakePackageManagementSolution solution)
- {
- var taskFactory = new FakeTaskFactory ();
- var registeredPackageRepositories = new FakeRegisteredPackageRepositories ();
- var packageViewModelFactory = new FakePackageViewModelFactory ();
- var recentPackageRepository = new FakeRecentPackageRepository ();
-
- return new AvailablePackagesViewModel (
- solution,
- registeredPackageRepositories,
- recentPackageRepository,
- packageViewModelFactory,
- taskFactory);
- }
-
- void AddProjectToSolution ()
- {
- FakeDotNetProject project = ProjectHelper.CreateTestProject ();
- fakeSolution.FakeDotNetProjects.Add (project);
- }
-
- void CreateViewModelWithTwoProjectsSelected (string projectName1, string projectName2)
- {
- CreateFakeSolution ();
- AddTwoProjectsSelected (projectName1, projectName2);
- CreateViewModel (fakeSolution);
- }
-
- void AddTwoProjectsSelected (string projectName1, string projectName2)
- {
- AddProjectToSolution ();
- AddProjectToSolution ();
- fakeSolution.FakeDotNetProjects [0].Name = projectName1;
- fakeSolution.FakeDotNetProjects [1].Name = projectName2;
- fakeSolution.NoProjectsSelected ();
-
- fakeSolution.AddFakeProjectToReturnFromGetProject (projectName1);
- fakeSolution.AddFakeProjectToReturnFromGetProject (projectName2);
- }
-
- void SetPackageIdAndVersion (string id, string version)
- {
- fakePackage.Id = id;
- fakePackage.Version = new SemanticVersion (version);
- }
-
- void UserCancelsProjectSelection ()
- {
- packageManagementEvents.SelectProjects += (sender, e) => {
- e.IsAccepted = false;
- };
- }
-
- void UserAcceptsProjectSelection ()
- {
- packageManagementEvents.SelectProjects += (sender, e) => {
- e.IsAccepted = true;
- };
- }
-
- List<PackageManagementSelectedProject> CreateTwoFakeSelectedProjects ()
- {
- fakeSelectedProjects = new List<PackageManagementSelectedProject> ();
- var projectA = new FakePackageManagementProject ("Project A");
- fakeSelectedProjects.Add (new PackageManagementSelectedProject (projectA));
-
- var projectB = new FakePackageManagementProject ("Project B");
- fakeSelectedProjects.Add (new PackageManagementSelectedProject (projectB));
- return fakeSelectedProjects;
- }
-
- FakePackageOperation AddFakeInstallPackageOperationWithPackageThatRequiresLicenseAcceptance (PackageManagementSelectedProject selectedProject)
- {
- return AddFakeInstallPackageOperationWithPackage (selectedProject, requireLicenseAcceptance: true);
- }
-
- FakePackageOperation AddFakeInstallPackageOperationWithPackageThatDoesNotRequireLicenseAcceptance (PackageManagementSelectedProject selectedProject)
- {
- return AddFakeInstallPackageOperationWithPackage (selectedProject, requireLicenseAcceptance: false);
- }
-
- FakePackageOperation AddFakeInstallPackageOperationWithPackage (PackageManagementSelectedProject selectedProject, bool requireLicenseAcceptance)
- {
- var project = selectedProject.Project as FakePackageManagementProject;
- FakePackageOperation operation = project.AddFakeInstallOperation ();
- operation.FakePackage.RequireLicenseAcceptance = requireLicenseAcceptance;
- return operation;
- }
-
- FakePackageOperation AddFakeUninstallPackageOperationWithPackageThatRequiresLicenseAcceptance (PackageManagementSelectedProject selectedProject)
- {
- var project = selectedProject.Project as FakePackageManagementProject;
- FakePackageOperation uninstallOperation = project.AddFakeUninstallOperation ();
- uninstallOperation.FakePackage.RequireLicenseAcceptance = true;
- return uninstallOperation;
- }
-
- PackageManagementSelectedProject FirstFakeSelectedProject {
- get { return fakeSelectedProjects [0]; }
- }
-
- PackageManagementSelectedProject SecondFakeSelectedProject {
- get { return fakeSelectedProjects [1]; }
- }
-
- void ParentAllowsPrereleasePackages ()
- {
- viewModelParent.IncludePrerelease = true;
- }
-
- [Test]
- public void AddPackageCommand_CommandExecuted_InstallsPackage ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
-
- viewModel.AddPackageCommand.Execute (null);
-
- IPackage package = fakeSolution.FakeProjectToReturnFromGetProject.LastInstallPackageCreated.Package;
- Assert.AreEqual (fakePackage, package);
- }
-
- [Test]
- public void AddPackage_PackageAddedSuccessfully_SourcePackageRepositoryUsedToCreateProject ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
-
- viewModel.AddPackage ();
-
- Assert.AreEqual (fakePackage.Repository, fakeSolution.RepositoryPassedToGetProject);
- }
-
- [Test]
- public void AddPackage_PackageAddedSuccessfully_PackageOperationsUsedWhenInstallingPackage ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- PackageOperation[] expectedOperations = new PackageOperation[] {
- new PackageOperation (fakePackage, PackageAction.Install)
- };
-
- FakeInstallPackageAction action = fakeSolution.FakeProjectToReturnFromGetProject.LastInstallPackageCreated;
- CollectionAssert.AreEqual (expectedOperations, action.Operations);
- }
-
- [Test]
- public void HasLicenseUrl_PackageHasLicenseUrl_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.LicenseUrl = new Uri ("http://monodevelop.com");
-
- Assert.IsTrue (viewModel.HasLicenseUrl);
- }
-
- [Test]
- public void HasLicenseUrl_PackageHasNoLicenseUrl_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.LicenseUrl = null;
-
- Assert.IsFalse (viewModel.HasLicenseUrl);
- }
-
- [Test]
- public void HasProjectUrl_PackageHasProjectUrl_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.ProjectUrl = new Uri ("http://monodevelop.com");
-
- Assert.IsTrue (viewModel.HasProjectUrl);
- }
-
- [Test]
- public void HasProjectUrl_PackageHasNoProjectUrl_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.ProjectUrl = null;
-
- Assert.IsFalse (viewModel.HasProjectUrl);
- }
-
- [Test]
- public void HasReportAbuseUrl_PackageHasReportAbuseUrl_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.ReportAbuseUrl = new Uri ("http://monodevelop.com");
-
- Assert.IsTrue (viewModel.HasReportAbuseUrl);
- }
-
- [Test]
- public void HasReportAbuseUrl_PackageHasNoReportAbuseUrl_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.ReportAbuseUrl = null;
-
- Assert.IsFalse (viewModel.HasReportAbuseUrl);
- }
-
- [Test]
- public void IsAdded_ProjectHasPackageAdded_ReturnsTrue ()
- {
- CreateViewModel ();
- fakeSolution.FakeProjectToReturnFromGetProject.FakePackages.Add (fakePackage);
-
- Assert.IsTrue (viewModel.IsAdded);
- }
-
- [Test]
- public void IsAdded_ProjectDoesNotHavePackageInstalled_ReturnsFalse ()
- {
- CreateViewModel ();
- fakeSolution.FakeProjectToReturnFromGetProject.FakePackages.Clear ();
-
- Assert.IsFalse (viewModel.IsAdded);
- }
-
- [Test]
- public void RemovePackageCommand_CommandExecuted_UninstallsPackage ()
- {
- CreateViewModel ();
- viewModel.RemovePackageCommand.Execute (null);
-
- Assert.AreEqual (fakePackage, fakeUninstallPackageAction.Package);
- }
-
- [Test]
- public void RemovePackage_PackageRemovedSuccessfully_RepositoryUsedToCreateProject ()
- {
- CreateViewModel ();
- viewModel.RemovePackage ();
-
- Assert.AreEqual (fakePackage.Repository, fakeSolution.RepositoryPassedToGetProject);
- }
-
- [Test]
- public void PackageChanged_PackageRemovedSuccessfully_PropertyNotifyChangedFiredForIsAddedProperty ()
- {
- CreateViewModel ();
- string propertyChangedName = null;
- viewModel.PropertyChanged += (sender, e) => propertyChangedName = e.PropertyName;
- viewModel.RemovePackage ();
-
- Assert.AreEqual ("IsAdded", propertyChangedName);
- }
-
- [Test]
- public void PackageChanged_PackageRemovedSuccessfully_PropertyNotifyChangedFiredAfterPackageUninstalled ()
- {
- CreateViewModel ();
- IPackage packagePassedToUninstallPackageWhenPropertyNameChanged = null;
- viewModel.PropertyChanged += (sender, e) => {
- packagePassedToUninstallPackageWhenPropertyNameChanged = fakeUninstallPackageAction.Package;
- };
- viewModel.RemovePackage ();
-
- Assert.AreEqual (fakePackage, packagePassedToUninstallPackageWhenPropertyNameChanged);
- }
-
- [Test]
- public void HasDependencies_PackageHasNoDependencies_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.HasDependencies = false;
-
- Assert.IsFalse (viewModel.HasDependencies);
- }
-
- [Test]
- public void HasDependencies_PackageHasDependency_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.AddDependency ("Dependency");
-
- Assert.IsTrue (viewModel.HasDependencies);
- }
-
- [Test]
- public void HasNoDependencies_PackageHasNoDependencies_ReturnsTrue ()
- {
- CreateViewModel ();
-
- Assert.IsTrue (viewModel.HasNoDependencies);
- }
-
- [Test]
- public void HasNoDependencies_PackageHasOneDependency_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.AddDependency ("Dependency");
-
- Assert.IsFalse (viewModel.HasNoDependencies);
- }
-
- [Test]
- public void HasDownloadCount_DownloadCountIsZero_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.DownloadCount = 0;
-
- Assert.IsTrue (viewModel.HasDownloadCount);
- }
-
- [Test]
- public void HasDownloadCount_DownloadCountIsMinusOne_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.DownloadCount = -1;
-
- Assert.IsFalse (viewModel.HasDownloadCount);
- }
-
- [Test]
- public void HasLastPublished_PackageHasPublishedDate_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.Published = new DateTime (2011, 1, 2);
-
- Assert.IsTrue (viewModel.HasLastPublished);
- }
-
- [Test]
- public void HasLastPublished_PackageHasNoPublishedDate_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.Published = null;
-
- Assert.IsFalse (viewModel.HasLastPublished);
- }
-
- [Test]
- public void LastPublished_PackageHasPublishedDate_ReturnsPackagePublishedDate ()
- {
- CreateViewModel ();
- fakePackage.Published = new DateTime (2011, 1, 2);
-
- Assert.AreEqual (fakePackage.Published, viewModel.LastPublished);
- }
-
- [Test]
- public void LastPublished_PackageHasNoPublishedDate_ReturnsNull ()
- {
- CreateViewModel ();
- fakePackage.Published = null;
-
- Assert.IsNull (viewModel.LastPublished);
- }
-
- [Test]
- public void AddPackage_CheckLoggerUsed_PackageViewModelLoggerUsedWhenResolvingPackageOperations ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- ILogger expectedLogger = viewModel.OperationLoggerCreated;
- ILogger actualLogger = fakeSolution.FakeProjectToReturnFromGetProject.Logger;
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void AddPackage_PackageAddedSuccessfully_InstallingPackageMessageIsFirstMessageLogged ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- fakePackage.Id = "Test.Package";
- fakePackage.Version = new SemanticVersion (1, 2, 0, 55);
- viewModel.AddPackage ();
-
- string expectedMessage = "------- Installing...Test.Package 1.2.0.55 -------";
- string actualMessage = fakeLogger.FirstFormattedMessageLogged;
-
- Assert.AreEqual (expectedMessage, actualMessage);
- }
-
- [Test]
- public void AddPackage_PackageAddedSuccessfully_NextToLastMessageLoggedMarksEndOfInstallation ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- string expectedMessage = "==============================";
- string actualMessage = fakeLogger.NextToLastFormattedMessageLogged;
-
- Assert.AreEqual (expectedMessage, actualMessage);
- }
-
- [Test]
- public void AddPackage_PackageAddedSuccessfully_LastMessageLoggedIsEmptyLine ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- string expectedMessage = String.Empty;
- string actualMessage = fakeLogger.LastFormattedMessageLogged;
-
- Assert.AreEqual (expectedMessage, actualMessage);
- }
-
- [Test]
- public void RemovePackage_PackageRemovedSuccessfully_UninstallingPackageMessageIsFirstMessageLogged ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- fakePackage.Id = "Test.Package";
- fakePackage.Version = new SemanticVersion (1, 2, 0, 55);
- viewModel.RemovePackage ();
-
- string expectedMessage = "------- Uninstalling...Test.Package 1.2.0.55 -------";
- string actualMessage = fakeLogger.FirstFormattedMessageLogged;
-
- Assert.AreEqual (expectedMessage, actualMessage);
- }
-
- [Test]
- public void RemovePackage_PackageRemovedSuccessfully_NextToLastMessageLoggedMarksEndOfInstallation ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.RemovePackage ();
-
- string expectedMessage = "==============================";
- string actualMessage = fakeLogger.NextToLastFormattedMessageLogged;
-
- Assert.AreEqual (expectedMessage, actualMessage);
- }
-
- [Test]
- public void RemovePackage_PackageRemovedSuccessfully_LastMessageLoggedIsEmptyLine ()
- {
- CreateViewModel ();
- viewModel.RemovePackage ();
-
- string expectedMessage = String.Empty;
- string actualMessage = fakeLogger.LastFormattedMessageLogged;
-
- Assert.AreEqual (expectedMessage, actualMessage);
- }
-
- [Test]
- public void AddPackage_PackagesInstalledSuccessfully_ViewModelPackageUsedWhenResolvingPackageOperations ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- FakePackage expectedPackage = fakePackage;
- IPackage actualPackage = fakeSolution
- .FakeProjectToReturnFromGetProject
- .PackagePassedToGetInstallPackageOperations;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void AddPackage_PackagesInstalledSuccessfully_PackageDependenciesNotIgnoredWhenCheckingForPackageOperations ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- bool result = fakeSolution
- .FakeProjectToReturnFromGetProject
- .IgnoreDependenciesPassedToGetInstallPackageOperations;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void AddPackage_PackagesInstalledSuccessfully_PrereleaseVersionsNotAllowedWhenCheckingForPackageOperations ()
- {
- CreateViewModel ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- bool result = fakeSolution
- .FakeProjectToReturnFromGetProject
- .AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void AddPackage_ParentHasIncludePrereleaseSetToTrueWhenInstalling_PrereleaseVersionsAllowedWhenCheckingForPackageOperations ()
- {
- CreateViewModel ();
- ParentAllowsPrereleasePackages ();
- viewModel.AddOneFakeInstallPackageOperationForViewModelPackage ();
- viewModel.AddPackage ();
-
- bool result = fakeSolution
- .FakeProjectToReturnFromGetProject
- .AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void IsAdded_SolutionSelectedContainingOneProjectAndPackageIsInstalledInSolutionSharedRepository_ReturnsTrue ()
- {
- CreateFakeSolution ();
- AddProjectToSolution ();
- fakeSolution.NoProjectsSelected ();
- fakeSolution.FakeInstalledPackages.Add (fakePackage);
- CreateViewModel (fakeSolution);
-
- bool added = viewModel.IsAdded;
-
- Assert.IsTrue (added);
- }
-
- [Test]
- public void IsAdded_SolutionSelectedContainingOneProjectAndPackageIsNotInstalledInSolutionSharedRepository_ReturnsFalse ()
- {
- CreateViewModel ();
- AddProjectToSolution ();
- fakeSolution.NoProjectsSelected ();
-
- bool added = viewModel.IsAdded;
-
- Assert.IsFalse (added);
- }
-
- [Test]
- public void IsManaged_SolutionSelectedContainingTwoProjects_ReturnsTrue ()
- {
- CreateFakeSolution ();
- AddProjectToSolution ();
- AddProjectToSolution ();
- fakeSolution.NoProjectsSelected ();
- CreateViewModel (fakeSolution);
-
- bool managed = viewModel.IsManaged;
-
- Assert.IsTrue (managed);
- }
-
- [Test]
- public void IsManaged_SolutionSelectedContainingOneProject_ReturnsTrue ()
- {
- CreateFakeSolution ();
- AddProjectToSolution ();
- fakeSolution.NoProjectsSelected ();
- CreateViewModel (fakeSolution);
-
- bool managed = viewModel.IsManaged;
-
- Assert.IsTrue (managed);
- }
-
- [Test]
- public void IsManaged_SolutionWithOneProjectSelected_ReturnsFalse ()
- {
- CreateFakeSolution ();
- AddProjectToSolution ();
- fakeSolution.FakeActiveDotNetProject = fakeSolution.FakeDotNetProjects [0];
- CreateViewModel (fakeSolution);
-
- bool managed = viewModel.IsManaged;
-
- Assert.IsFalse (managed);
- }
-
- [Test]
- public void Summary_PackageHasSummary_PackageSummaryReturned ()
- {
- CreateViewModel ();
- fakePackage.Summary = "Expected summary";
-
- string summary = viewModel.Summary;
-
- Assert.AreEqual ("Expected summary", summary);
- }
-
- [Test]
- public void Summary_PackageHasDescriptionButNoSummary_PackageDescriptionReturned ()
- {
- CreateViewModel ();
- fakePackage.Summary = String.Empty;
- fakePackage.Description = "Expected description";
-
- string summary = viewModel.Summary;
-
- Assert.AreEqual ("Expected description", summary);
- }
-
- [Test]
- public void Name_PackageHasIdButNoTitle_ReturnsPackageId ()
- {
- CreateViewModel ();
- fakePackage.Id = "MyPackage";
-
- string name = viewModel.Name;
-
- Assert.AreEqual ("MyPackage", name);
- }
-
- [Test]
- public void Name_PackageHasIdAndTitle_ReturnsPackageId ()
- {
- CreateViewModel ();
- fakePackage.Id = "MyPackage";
- fakePackage.Title = "My Package Title";
-
- string name = viewModel.Name;
-
- Assert.AreEqual ("My Package Title", name);
- }
-
- [Test]
- public void GalleryUrl_PackageHasGalleryUrl_ReturnsUrl ()
- {
- CreateViewModel ();
- var expectedUrl = new Uri ("http://test.com/MyPackage");
- fakePackage.GalleryUrl = expectedUrl;
-
- Uri url = viewModel.GalleryUrl;
-
- Assert.AreEqual (expectedUrl, url);
- }
-
- [Test]
- public void HasGalleryUrl_PackageHasGalleryUrl_ReturnsTrue ()
- {
- CreateViewModel ();
- var expectedUrl = new Uri ("http://test.com/MyPackage");
- fakePackage.GalleryUrl = expectedUrl;
-
- bool result = viewModel.HasGalleryUrl;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void HasNoGalleryUrl_PackageHasNoGalleryUrl_ReturnsFalse ()
- {
- CreateViewModel ();
- fakePackage.GalleryUrl = null;
-
- bool result = viewModel.HasGalleryUrl;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void HasNoGalleryUrl_PackageHasGalleryUrl_ReturnsFalse ()
- {
- CreateViewModel ();
- var expectedUrl = new Uri ("http://test.com/MyPackage");
- fakePackage.GalleryUrl = expectedUrl;
-
- bool result = viewModel.HasNoGalleryUrl;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void IsGalleryUrlMissing_PackageHasNoGalleryUrl_ReturnsTrue ()
- {
- CreateViewModel ();
- fakePackage.GalleryUrl = null;
-
- bool result = viewModel.HasNoGalleryUrl;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void AddPackage_PackageRepositoryIsOperationAwareAndPackageAddedSuccessfully_InstallOperationStartedForPackage ()
- {
- CreateViewModel ();
- var operationAwareRepository = new FakeOperationAwarePackageRepository ();
- fakePackage.FakePackageRepository = operationAwareRepository;
- fakePackage.Id = "MyPackage";
-
- viewModel.AddPackage ();
-
- operationAwareRepository.AssertOperationWasStartedAndDisposed (RepositoryOperationNames.Install, "MyPackage");
- }
-
- [Test]
- public void ManagePackage_TwoProjectsNeitherSelectedAndSourceRepositoryIsOperationAware_InstallOperationStarted ()
- {
- CreateViewModelWithTwoProjectsSelected ("Project A", "Project B");
- UserAcceptsProjectSelection ();
- var operationAwareRepository = new FakeOperationAwarePackageRepository ();
- fakePackage.FakePackageRepository = operationAwareRepository;
- fakePackage.Id = "MyPackage";
-
- viewModel.ManagePackage ();
-
- operationAwareRepository.AssertOperationWasStartedAndDisposed (RepositoryOperationNames.Install, "MyPackage");
- }
-
- [Test]
- public void GetDownloadCountOrVersionDisplayText_PackageDownloadCountIsMinusOne_ReturnsEmptyString ()
- {
- CreateViewModel ();
- fakePackage.DownloadCount = -1;
-
- string result = viewModel.GetDownloadCountOrVersionDisplayText ();
-
- Assert.AreEqual (String.Empty, result);
- }
-
- [Test]
- public void GetDownloadCountOrVersionDisplayText_PackageHasTenThousandDownloads_ReturnsDownloadCountFormattedForLocale ()
- {
- CreateViewModel ();
- fakePackage.DownloadCount = 10000;
-
- string result = viewModel.GetDownloadCountOrVersionDisplayText ();
-
- string expectedResult = 10000.ToString ("N0");
- Assert.AreEqual (expectedResult, result);
- }
-
- [Test]
- public void GetDownloadCountOrVersionDisplayText_PackageWasPartOfGroupIncludingAllVersions_ReturnsVersionNumberInsteadOfDownloadCount ()
- {
- CreateViewModel ();
- viewModel.ShowVersionInsteadOfDownloadCount = true;
- fakePackage.DownloadCount = 10000;
- fakePackage.Version = new SemanticVersion ("1.2.3.4");
-
- string result = viewModel.GetDownloadCountOrVersionDisplayText ();
-
- Assert.AreEqual ("1.2.3.4", result);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackagesViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackagesViewModelTests.cs deleted file mode 100644 index 988738e90d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/PackagesViewModelTests.cs +++ /dev/null @@ -1,1560 +0,0 @@ -//
-// PackagesViewModelTests.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 System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class PackagesViewModelTests
- {
- TestablePackagesViewModel viewModel;
- FakeTaskFactory taskFactory;
- FakeRegisteredPackageRepositories registeredPackageRepositories;
-
- void CreateViewModel (FakeRegisteredPackageRepositories registeredPackageRepositories)
- {
- viewModel = new TestablePackagesViewModel (registeredPackageRepositories);
- registeredPackageRepositories.ActivePackageSource = registeredPackageRepositories.PackageSources [0];
- this.registeredPackageRepositories = registeredPackageRepositories;
- taskFactory = viewModel.FakeTaskFactory;
- }
-
- void CreateViewModel ()
- {
- CreateRegisteredRepositoriesService ();
- CreateViewModel (registeredPackageRepositories);
- }
-
- void CreateRegisteredRepositoriesService ()
- {
- registeredPackageRepositories = new FakeRegisteredPackageRepositories ();
- }
-
- void CompleteReadPackagesTask ()
- {
- taskFactory.ExecuteAllFakeTasks ();
- }
-
- void ClearReadPackagesTasks ()
- {
- taskFactory.ClearAllFakeTasks ();
- }
-
- [Test]
- public void IsPaged_OnePackageAndPageSizeIsFive_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddOneFakePackage ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- bool paged = viewModel.IsPaged;
-
- Assert.IsFalse (paged);
- }
-
- [Test]
- public void IsPaged_SixPackagesAndPageSizeIsFive_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- bool paged = viewModel.IsPaged;
-
- Assert.IsTrue (paged);
- }
-
- [Test]
- public void SelectedPageNumber_ByDefault_ReturnsOne ()
- {
- CreateViewModel ();
-
- int pageNumber = viewModel.SelectedPageNumber;
-
- Assert.AreEqual (1, pageNumber);
- }
-
- [Test]
- public void HasPreviousPage_SixPackagesSelectedPageNumberIsOneAndPageSizeIsFive_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 1;
-
- Assert.IsFalse (viewModel.HasPreviousPage);
- }
-
- [Test]
- public void HasPreviousPage_SixPackagesSelectedPageNumberIsTwoAndPageSizeIsFive_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
-
- Assert.IsTrue (viewModel.HasPreviousPage);
- }
-
- [Test]
- public void HasPreviousPage_SelectedPagesChangesFromFirstPageToSecond_PropertyChangedEventFiredForAllProperties ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.SelectedPageNumber = 1;
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- PropertyChangedEventArgs propertyChangedEvent = null;
- viewModel.PropertyChanged += (sender, e) => propertyChangedEvent = e;
- viewModel.SelectedPageNumber = 2;
-
- string propertyName = propertyChangedEvent.PropertyName;
-
- Assert.IsNull (propertyName);
- }
-
- [Test]
- public void HasNextPage_SixPackagesSelectedPageNumberIsOneAndPageSizeIsFive_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 1;
-
- Assert.IsTrue (viewModel.HasNextPage);
- }
-
- [Test]
- public void HasNextPage_SixPackagesSelectedPageNumberIsTwoAndPageSizeIsFive_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
-
- Assert.IsFalse (viewModel.HasNextPage);
- }
-
- [Test]
- public void HasNextPage_SixPackagesSelectedPageNumberIsTwoAndPageSizeIsTwo_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
-
- Assert.IsTrue (viewModel.HasNextPage);
- }
-
- [Test]
- public void Pages_SixPackagesSelectedPageNumberIsTwoAndPageSizeIsFive_ReturnsTwoPagesWithSecondOneSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 1 },
- new Page () { Number = 2, IsSelected = true }
- };
-
- var actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void Pages_SixPackagesSelectedPageNumberIsOneAndPageSizeIsFive_ReturnsTwoPagesWithFirstOneSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 1;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 1, IsSelected = true },
- new Page () { Number = 2 }
- };
-
- var actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void Pages_SixPackagesSelectedPageNumberIsOneAndPageSizeIsTwo_ReturnsThreePagesWithFirstOneSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 1;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 1, IsSelected = true },
- new Page () { Number = 2 },
- new Page () { Number = 3 }
- };
-
- var actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void Pages_SixPackagesSelectedPageNumberIsOneAndPageSizeIsTwoAndMaximumSelectablePagesIsTwo_ReturnsTwoPagesWithFirstOneSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 1;
- viewModel.MaximumSelectablePages = 2;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 1, IsSelected = true },
- new Page () { Number = 2 }
- };
-
- var actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void Pages_SixPackagesSelectedPageNumberIsOneAndPageSizeIsFiveGetPagesTwice_ReturnsTwoPagesWithFirstOneSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 1;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 1, IsSelected = true },
- new Page () { Number = 2 }
- };
-
- var actualPages = viewModel.Pages;
- actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void Pages_SixPackagesSelectedPageNumberIsThreeAndPageSizeIsTwoAndMaximumSelectablePagesIsTwo_ReturnsPagesTwoAndThreeWithPageThreeSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 3;
- viewModel.MaximumSelectablePages = 2;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 2 },
- new Page () { Number = 3, IsSelected = true }
- };
-
- var actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void Pages_TenPackagesSelectedPageNumberIsFiveAndPageSizeIsTwoAndMaximumSelectablePagesIsThree_ReturnsPagesThreeAndFourAndFive ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddTenFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 5;
- viewModel.MaximumSelectablePages = 3;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 3 },
- new Page () { Number = 4 },
- new Page () { Number = 5, IsSelected = true }
- };
-
- var actualPages = viewModel.Pages;
-
- PageCollectionAssert.AreEqual (expectedPages, actualPages);
- }
-
- [Test]
- public void ReadPackages_SecondQueryFinishesBeforeFirst_PackagesInViewModelAreForSecondQuery ()
- {
- CreateViewModel ();
- viewModel.AddThreeFakePackages ();
- FakePackage package = viewModel.AddFakePackage ("MyTest");
- viewModel.ReadPackages ();
- viewModel.SearchTerms = "MyTest";
-
- var expectedPackages = new FakePackage [] { package };
-
- viewModel.ReadPackages ();
- taskFactory.ExecuteTask (1);
- taskFactory.ExecuteTask (0);
- ClearReadPackagesTasks ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ReadPackages_RepositoryHasSixPackagesWhenSelectedPageIsOneAndPageSizeIsThree_ThreePackageViewModelsCreatedForFirstThreePackages ()
- {
- CreateViewModel ();
- viewModel.PageSize = 3;
- viewModel.SelectedPageNumber = 1;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- var expectedPackages = new List<FakePackage> ();
- expectedPackages.Add (viewModel.FakePackages [0]);
- expectedPackages.Add (viewModel.FakePackages [1]);
- expectedPackages.Add (viewModel.FakePackages [2]);
-
- ClearReadPackagesTasks ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void Pages_PageSizeChanged_PagesRecalcuatedBasedOnNewPageSize ()
- {
- CreateViewModel ();
- viewModel.PageSize = 10;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- int oldPageCount = viewModel.Pages.Count;
- viewModel.PageSize = 5;
- int newPageCount = viewModel.Pages.Count;
-
- Assert.AreEqual (2, newPageCount);
- Assert.AreEqual (1, oldPageCount);
- }
-
- [Test]
- public void Pages_SelectedPageNumberChanged_PagesRecalculatedBasedOnNewSelectedPage ()
- {
- CreateViewModel ();
- viewModel.PageSize = 3;
- viewModel.SelectedPageNumber = 1;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ClearReadPackagesTasks ();
- var oldPages = viewModel.Pages;
- viewModel.SelectedPageNumber = 2;
- CompleteReadPackagesTask ();
- var newPages = viewModel.Pages;
-
- Page[] expectedPages = new Page[] {
- new Page () { Number = 1 },
- new Page () { Number = 2, IsSelected = true }
- };
-
- PageCollectionAssert.AreEqual (expectedPages, newPages);
- }
-
- [Test]
- public void ShowNextPageCommand_TwoPagesAndFirstPageSelectedWhenCommandExecuted_PageTwoIsSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 3;
- viewModel.SelectedPageNumber = 1;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.ShowNextPageCommand.Execute (null);
-
- int selectedPage = viewModel.SelectedPageNumber;
-
- Assert.AreEqual (2, selectedPage);
- }
-
- [Test]
- public void ShowNextPageCommand_TwoPagesAndFirstPageSelectedWhenCommandExecuted_SecondPageOfPackagesDisplayed ()
- {
- CreateViewModel ();
- viewModel.AddThreeFakePackages ();
- viewModel.PageSize = 2;
- viewModel.SelectedPageNumber = 1;
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ClearReadPackagesTasks ();
- viewModel.ShowNextPageCommand.Execute (null);
- CompleteReadPackagesTask ();
-
- var expectedPackages = new List<FakePackage> ();
- expectedPackages.Add (viewModel.FakePackages [2]);
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ShowPreviousPageCommand_TwoPagesAndSecondPageSelectedWhenCommandExecuted_PageOneIsSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 3;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
-
- viewModel.ShowPreviousPageCommand.Execute (null);
-
- int selectedPage = viewModel.SelectedPageNumber;
-
- Assert.AreEqual (1, selectedPage);
- }
-
- [Test]
- public void ShowPreviousPageCommand_TwoPagesAndSecondPageSelectedWhenCommandExecuted_FirstPageOfPackagesDisplayed ()
- {
- CreateViewModel ();
- viewModel.AddThreeFakePackages ();
- viewModel.PageSize = 2;
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
- ClearReadPackagesTasks ();
-
- viewModel.ShowPreviousPageCommand.Execute (null);
- CompleteReadPackagesTask ();
-
- var expectedPackages = new List<FakePackage> ();
- expectedPackages.Add (viewModel.FakePackages [0]);
- expectedPackages.Add (viewModel.FakePackages [1]);
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void ShowPageCommand_PageNumberOneToBeShownWhenCurrentlySelectedPageIsTwo_PageOneIsSelected ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.SelectedPageNumber = 2;
-
- int pageNumber = 1;
- viewModel.ShowPageCommand.Execute (pageNumber);
-
- int selectedPage = viewModel.SelectedPageNumber;
-
- Assert.AreEqual (1, selectedPage);
- }
-
- [Test]
- public void Pages_ReadPackagesAndIsPagedCalled_PackagesReadFromRepositoryOnlyOnce ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- bool result = viewModel.IsPaged;
- int count = viewModel.Pages.Count;
-
- Assert.AreEqual (1, viewModel.GetAllPackagesCallCount);
- }
-
- [Test]
- public void ReadPackages_CalledThreeTimesAndThenSelectedPageChanged_ViewModelPropertiesChangedEventFiresOnceWhenSelectedPageChanged ()
- {
- CreateViewModel ();
- viewModel.PageSize = 3;
- viewModel.AddSixFakePackages ();
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- int count = 0;
- viewModel.PropertyChanged += (sender, e) => count++;
- viewModel.SelectedPageNumber = 2;
-
- Assert.AreEqual (1, count);
- }
-
- [Test]
- public void IsSearchable_ByDefault_ReturnsFalse ()
- {
- CreateViewModel ();
-
- Assert.IsFalse (viewModel.IsSearchable);
- }
-
- [Test]
- public void SearchCommand_SearchTextEntered_PackageViewModelsFilteredBySearchCriteria ()
- {
- CreateViewModel ();
- viewModel.IsSearchable = true;
- viewModel.AddSixFakePackages ();
-
- var package = new FakePackage () {
- Id = "SearchedForId",
- Description = "Test"
- };
- viewModel.FakePackages.Add (package);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ClearReadPackagesTasks ();
- viewModel.SearchTerms = "SearchedForId";
- viewModel.SearchCommand.Execute (null);
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- package
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void PackageExtensionsFind_TwoPackagesInCollection_FindsOnePackageId ()
- {
- List<IPackage> packages = new List<IPackage> ();
- var package1 = new FakePackage () {
- Id = "Test"
- };
- var package2 = new FakePackage () {
- Id = "Another"
- };
- packages.Add (package1);
- packages.Add (package2);
-
- IQueryable<IPackage> query = packages.AsQueryable ();
-
- IQueryable<IPackage> filteredResults = query.Find ("Test");
-
- IPackage foundPackage = filteredResults.First ();
-
- Assert.AreEqual ("Test", foundPackage.Id);
- }
-
- [Test]
- public void PackageExtensionsFind_TwoPackagesInCollectionAndQueryableResultsPutInBufferedEnumerable_OnePackageInBufferedEnumerable ()
- {
- List<IPackage> packages = new List<IPackage> ();
-
- // Need to add descriptiosn otherwise we get a null reference when enumerating results
- // in BufferedEnumerable
- var package1 = new FakePackage () {
- Id = "Test", Description = "b"
- };
- var package2 = new FakePackage () {
- Id = "Another", Description = "a"
- };
- packages.Add (package1);
- packages.Add (package2);
-
- IQueryable<IPackage> query = packages.AsQueryable ();
-
- IQueryable<IPackage> filteredResults = query.Find ("Test");
-
- var collection = new BufferedEnumerable<IPackage> (filteredResults, 10);
- IPackage foundPackage = collection.First ();
-
- Assert.AreEqual ("Test", foundPackage.Id);
- }
-
- [Test]
- public void Search_SearchTextChangedAndPackagesWerePagedBeforeSearch_PagesUpdatedAfterFilteringBySearchCriteria ()
- {
- CreateViewModel ();
- viewModel.IsSearchable = true;
- viewModel.PageSize = 2;
- viewModel.MaximumSelectablePages = 5;
- viewModel.AddSixFakePackages ();
-
- var package = new FakePackage () {
- Id = "SearchedForId",
- Description = "Test"
- };
- viewModel.FakePackages.Add (package);
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ObservableCollection<Page> pages = viewModel.Pages;
-
- ClearReadPackagesTasks ();
- viewModel.SearchTerms = "SearchedForId";
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- var expectedPages = new Page[] {
- new Page () { Number = 1, IsSelected = true }
- };
-
- PageCollectionAssert.AreEqual (expectedPages, pages);
- }
-
- [Test]
- public void Pages_SixPackagesButPackagesNotRead_HasNoPages ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
-
- Assert.AreEqual (0, viewModel.Pages.Count);
- }
-
- [Test]
- public void HasPreviousPage_SixPackagesAndSecondPageSelectedButPackagesNotRead_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.SelectedPageNumber = 2;
- viewModel.AddSixFakePackages ();
-
- Assert.IsFalse (viewModel.HasPreviousPage);
- }
-
- [Test]
- public void HasNextPage_SixPackagesAndFirstPageSelectedButPackagesNotRead_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.SelectedPageNumber = 1;
- viewModel.AddSixFakePackages ();
-
- Assert.IsFalse (viewModel.HasNextPage);
- }
-
- [Test]
- public void IsPaged_SixPackagesAndFirstPageSelectedButPackagesNotRead_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.SelectedPageNumber = 1;
- viewModel.AddSixFakePackages ();
-
- Assert.IsFalse (viewModel.IsPaged);
- }
-
- [Test]
- public void Search_SelectedPageInitiallyIsPageTwoAndThenUserSearches_SelectedPageNumberIsSetToPageOne ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
-
- var package = new FakePackage () {
- Id = "SearchedForId",
- Description = "Test"
- };
- viewModel.FakePackages.Add (package);
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.SelectedPageNumber = 2;
-
- ClearReadPackagesTasks ();
- viewModel.SearchTerms = "SearchedForId";
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- Assert.AreEqual (1, viewModel.SelectedPageNumber);
- }
-
- /// <summary>
- /// Ensures that the total number of packages is determined from all packages and not
- /// the filtered set. All packages will be retrieved from the repository
- /// if this is not done when we only want 30 retrieved in one go.
- /// </summary>
- [Test]
- public void ReadPackages_SixPackagesInRepository_TotalItemsSetBeforePackagesFiltered ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- int expectedTotal = 6;
- Assert.AreEqual (expectedTotal, viewModel.TotalItems);
- }
-
- [Test]
- public void Search_ThreePagesOfPackagesBeforeSearchReturnsNoPackages_IsPagedIsFalseWhenPropertyChangedEventFired ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.SearchTerms = "SearchedForId";
-
- ClearReadPackagesTasks ();
- bool paged = true;
- viewModel.PropertyChanged += (sender, e) => paged = viewModel.IsPaged;
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- Assert.IsFalse (paged);
- }
-
- [Test]
- public void Search_BeforeSearchFivePagesOfPackagesShownAndSearchReturnsTwoPages_TwoPagesShownAfterSearch ()
- {
- CreateViewModel ();
- viewModel.IsSearchable = true;
- viewModel.PageSize = 2;
- viewModel.MaximumSelectablePages = 5;
- viewModel.AddSixFakePackages ();
-
- viewModel.FakePackages.Add (new FakePackage ("SearchedForId1"));
- viewModel.FakePackages.Add (new FakePackage ("SearchedForId2"));
- viewModel.FakePackages.Add (new FakePackage ("SearchedForId3"));
-
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- ObservableCollection<Page> pages = viewModel.Pages;
-
- ClearReadPackagesTasks ();
- viewModel.SearchTerms = "SearchedForId";
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- var expectedPages = new Page[] {
- new Page () { Number = 1, IsSelected = true },
- new Page () { Number = 2 }
- };
-
- PageCollectionAssert.AreEqual (expectedPages, pages);
- }
-
- [Test]
- public void ShowPackageSources_ByDefault_ReturnsFalse ()
- {
- CreateViewModel ();
-
- Assert.IsFalse (viewModel.ShowPackageSources);
- }
-
- [Test]
- public void ReadPackages_OnePackageInRepository_CreatesTask ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- Assert.IsTrue (taskFactory.IsCreateTaskCalled);
- }
-
- [Test]
- public void ReadPackages_OnePackageInRepository_TaskStartMethodCalled ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- Assert.IsTrue (taskFactory.FirstFakeTaskCreated.IsStartCalled);
- }
-
- [Test]
- public void IsReadingPackages_ReadPackagesNotCalled_ReturnsFalse ()
- {
- CreateViewModel ();
-
- Assert.IsFalse (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void IsReadingPackages_ReadPackagesCalled_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.ReadPackages ();
-
- Assert.IsTrue (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void ReadPackages_OnePackageInRepositoryWhenBackgroundTaskExecuted_ReadsOnePackage ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- PackagesForSelectedPageResult result = taskFactory.FirstFakeTaskCreated.ExecuteTaskButNotContinueWith ();
-
- CollectionAssert.AreEqual (viewModel.FakePackages, result.Packages);
- }
-
- [Test]
- public void ReadPackages_OnePackageInRepositoryWhenFirstPartOfBackgroundTaskExecuted_PackageCountReadInBackgroundTask ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- PackagesForSelectedPageResult result = taskFactory.FirstFakeTaskCreated.ExecuteTaskButNotContinueWith ();
-
- Assert.AreEqual (1, result.TotalPackagesOnPage);
- }
-
- [Test]
- public void ReadPackages_OnePackageInRepositoryWhenBackgroundTaskExecutedAndResultsReturned_PackagesUpdatedInViewModel ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- CompleteReadPackagesTask ();
-
- PackageCollectionAssert.AreEqual (viewModel.FakePackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void IsReadingPackages_OnePackageInRepositoryWhenBackgroundTaskExecutedAndResultsReturned_SetToFalseAfterPackagesRead ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- CompleteReadPackagesTask ();
-
- Assert.IsFalse (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void IsReadingPackages_OnePackageInRepositoryWhenBackgroundTaskExecutedAndResultsReturned_NotifyPropertyChangedFiredAfterIsReadingPackagesSetToFalse ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
-
- bool readingPackages = true;
- viewModel.PropertyChanged += (sender, e) => readingPackages = viewModel.IsReadingPackages;
- CompleteReadPackagesTask ();
-
- Assert.IsFalse (readingPackages);
- }
-
- [Test]
- public void ReadPackages_SixPackagesInRepositoryAndPageSizeIsTwoWhenFirstPartOfBackgroundTaskExecuted_PackageCountReadInBackgroundTask ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
-
- viewModel.ReadPackages ();
-
- PackagesForSelectedPageResult result = taskFactory.FirstFakeTaskCreated.ExecuteTaskButNotContinueWith ();
-
- Assert.AreEqual (6, result.TotalPackages);
- }
-
- [Test]
- public void ReadPackages_SixPackagesInRepositoryAndPageSizeIsTwoWhenFirstPartOfBackgroundTaskExecuted_PageSizeNotChangedDuringBackgroundTaskExecution ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
-
- viewModel.ReadPackages ();
-
- taskFactory.FirstFakeTaskCreated.ExecuteTaskButNotContinueWith ();
-
- Assert.IsFalse (viewModel.IsPaged);
- }
-
- [Test]
- public void ReadPackages_SixPackagesInRepositoryAndPageSizeIsTwoWhenBackgroundTaskExecutedAndResultsReturned_ResultsArePaged ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
-
- viewModel.ReadPackages ();
-
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.IsPaged);
- }
-
- [Test]
- public void ReadPackages_CalledSecondTimeBeforeFirstReadPackagesTaskCompletes_FirstReadPackagesTaskIsCancelled ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
- viewModel.ReadPackages ();
-
- Assert.IsTrue (taskFactory.FirstFakeTaskCreated.IsCancelCalled);
- }
-
- [Test]
- public void ReadPackages_FirstReadPackagesTaskCompletesAfterBeingCancelled_PackagesNotUpdated ()
- {
- CreateViewModel ();
- viewModel.AddOneFakePackage ();
-
- viewModel.ReadPackages ();
- taskFactory.FirstFakeTaskCreated.IsCancelled = true;
- viewModel.ReadPackages ();
- taskFactory.FirstFakeTaskCreated.ExecuteTaskCompletely ();
-
- Assert.AreEqual (0, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void SelectedPage_ChangedTwoPageTwo_IsReadingPackagesReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.SelectedPageNumber = 2;
-
- Assert.IsTrue (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void ReadPackages_SixPackagesDisplayedWhenReadPackagesCalledAgain_DisplayedPackagesAreRemoved ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.ReadPackages ();
-
- Assert.AreEqual (0, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void SelectedPage_ChangedTwoPageTwo_DisplayedPackagesAreRemoved ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.SelectedPageNumber = 2;
-
- Assert.AreEqual (0, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void HasError_BackgroundTaskHasExceptionWhenItFinishes_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.ReadPackages ();
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- Assert.IsTrue (viewModel.HasError);
- }
-
- [Test]
- public void HasError_ByDefault_ReturnsFalse ()
- {
- CreateViewModel ();
-
- Assert.IsFalse (viewModel.HasError);
- }
-
- [Test]
- public void IsReadingPackages_BackgroundTaskHasExceptionWhenItFinishes_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.ReadPackages ();
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- Assert.IsFalse (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void PropertyChanged_BackgroundTaskHasExceptionWhenItFinishes_PropertyChangedEventFiredWhenTaskCompletes ()
- {
- CreateViewModel ();
- viewModel.ReadPackages ();
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- taskFactory.FirstFakeTaskCreated.ExecuteTaskButNotContinueWith ();
-
- string propertyName = "Nothing";
- viewModel.PropertyChanged += (sender, e) => propertyName = e.PropertyName;
- taskFactory.FirstFakeTaskCreated.ExecuteContinueWith ();
-
- Assert.IsNull (propertyName);
- }
-
- [Test]
- public void ReadPackages_BackgroundTaskHasExceptionWhenItFinishes_PackagesNotUpdated ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- var query = new PackagesForSelectedPageQuery (viewModel, null, null);
- taskFactory.FirstFakeTaskCreated.Result = new PackagesForSelectedPageResult (viewModel.FakePackages, query);
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- Assert.AreEqual (0, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void ErrorMessage_BackgroundTaskHasExceptionWhenItFinishes_ErrorMessageTakenFromException ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
-
- Exception ex = new Exception ("Test");
- AggregateException aggregateEx = new AggregateException (ex);
- taskFactory.FirstFakeTaskCreated.Exception = aggregateEx;
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- Assert.AreEqual ("Test", viewModel.ErrorMessage);
- }
-
- [Test]
- public void ErrorMessage_BackgroundTaskHasAggregateExceptionWithNestedInnerAggregateException_ErrorMessageTakenFromInnerException ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
-
- Exception innerEx1 = new Exception ("Test1");
- Exception innerEx2 = new Exception ("Test2");
- AggregateException innerAggregateEx = new AggregateException (innerEx1, innerEx2);
- AggregateException aggregateEx = new AggregateException (innerAggregateEx);
- taskFactory.FirstFakeTaskCreated.Exception = aggregateEx;
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- string expectedErrorMessage =
- "Test1" + Environment.NewLine +
- "Test2";
-
- Assert.AreEqual (expectedErrorMessage, viewModel.ErrorMessage);
- }
-
- [Test]
- public void ErrorMessage_BackgroundTaskHasAggregateExceptionWithTwoInnerExceptionsWhenItFinishes_ErrorMessageTakenFromAllInnerExceptions ()
- {
- CreateViewModel ();
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
-
- Exception innerEx1 = new Exception ("Test1");
- Exception innerEx2 = new Exception ("Test2");
- Exception innerEx3 = new Exception ("Test3");
- AggregateException aggregateEx = new AggregateException (innerEx1, innerEx2, innerEx3);
- taskFactory.FirstFakeTaskCreated.Exception = aggregateEx;
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- string expectedErrorMessage =
- "Test1" + Environment.NewLine +
- "Test2" + Environment.NewLine +
- "Test3";
-
- Assert.AreEqual (expectedErrorMessage, viewModel.ErrorMessage);
- }
-
- [Test]
- public void HasError_ErrorMessageDisplayedAndReadPackagesRetriedAfterFailure_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.ReadPackages ();
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
- viewModel.ReadPackages ();
-
- Assert.IsFalse (viewModel.HasError);
- }
-
- [Test]
- public void HasError_ErrorMessageDisplayedAndSelectedPageChangedAfterFailure_ReturnsFalse ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.SelectedPageNumber = 2;
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
-
- viewModel.SelectedPageNumber = 3;
-
- Assert.IsFalse (viewModel.HasError);
- }
-
- [Test]
- public void ReadPackages_PackagesReturnedNotSortedFromRepository_PackagesDisplayedSortedById ()
- {
- CreateViewModel ();
- viewModel.AddFakePackage ("Z");
- viewModel.AddFakePackage ("C");
- viewModel.AddFakePackage ("A");
- viewModel.AddFakePackage ("B");
- viewModel.ReadPackages ();
-
- CompleteReadPackagesTask ();
-
- var expectedPackages = new FakePackage[] {
- viewModel.FakePackages [2],
- viewModel.FakePackages [3],
- viewModel.FakePackages [1],
- viewModel.FakePackages [0]
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.PackageViewModels);
- }
-
- [Test]
- public void SelectedPageNumber_SixPackagesAndPageSizeIsFiveAndSelectedPageNumberIsChangedToTwo_OneReadPackagesTaskCreated ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.SelectedPageNumber = 2;
-
- Assert.AreEqual (1, taskFactory.FakeTasksCreated.Count);
- }
-
- [Test]
- public void SelectedPageNumber_SixPackagesAndSelectedPageNumberIsSetToPageOneButUnchanged_NoReadPackagesTaskCreated ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.SelectedPageNumber = 1;
-
- Assert.AreEqual (0, taskFactory.FakeTasksCreated.Count);
- }
-
- [Test]
- public void SelectedPageNumber_SixPackagesAndPageSizeIsFiveAndSelectedPageNumberIsChangedToTwo_PropertyChangedEventFiredAfterSelectedPageNumberChanged ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- int selectedPageNumber = 0;
- viewModel.PropertyChanged += (source, e) => selectedPageNumber = viewModel.SelectedPageNumber;
- viewModel.SelectedPageNumber = 2;
-
- Assert.AreEqual (2, selectedPageNumber);
- }
-
- [Test]
- public void SelectedPageNumber_SixPackagesAndPageSizeIsFiveAndSelectedPageNumberIsChangedToTwo_SelectedPageNumberChangedBeforeReadPackagesTaskStarted ()
- {
- CreateViewModel ();
- viewModel.PageSize = 5;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- taskFactory.RunTasksSynchronously = true;
- viewModel.SelectedPageNumber = 2;
-
- Assert.AreEqual (1, viewModel.PackageViewModels.Count);
- }
-
- [Test]
- public void Search_RepositoryHasPackageWithIdOfEmptyString_SearchCriteriaUsedIsNull ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.FakePackages.Add (new FakePackage () {
- Id = "",
- Description = "abc"
- });
- taskFactory.RunTasksSynchronously = true;
- viewModel.ReadPackages ();
-
- ClearReadPackagesTasks ();
-
- viewModel.SearchTerms = "";
- viewModel.Search ();
-
- Assert.IsNull (viewModel.SearchCriteriaPassedToFilterPackagesBySearchCriteria.SearchText);
- }
-
- [Test]
- public void Search_RepositoryHasPackageWithIdOfWhitespaceString_SearchCriteriaUsedIsNull ()
- {
- CreateViewModel ();
- viewModel.PageSize = 2;
- viewModel.FakePackages.Add (new FakePackage () {
- Id = "",
- Description = "abc"
- });
- taskFactory.RunTasksSynchronously = true;
- viewModel.ReadPackages ();
-
- ClearReadPackagesTasks ();
-
- viewModel.SearchTerms = " ";
- viewModel.Search ();
-
- Assert.IsNull (viewModel.SearchCriteriaPassedToFilterPackagesBySearchCriteria.SearchText);
- }
-
- [Test]
- public void IsDisposed_DisposeMethodCalled_ReturnsTrue ()
- {
- CreateViewModel ();
- viewModel.Dispose ();
-
- Assert.IsTrue (viewModel.IsDisposed);
- }
-
- [Test]
- public void IsDisposed_DisposeMethodNotCalled_ReturnsFalse ()
- {
- CreateViewModel ();
-
- Assert.IsFalse (viewModel.IsDisposed);
- }
-
- [Test]
- public void IncludePrerelease_ChangedToTrue_PackagesAreReadAgain ()
- {
- CreateViewModel ();
- viewModel.IncludePrerelease = false;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.IncludePrerelease = true;
-
- Assert.IsTrue (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void IncludePrerelease_ChangedToFalse_PackagesAreReadAgain ()
- {
- CreateViewModel ();
- viewModel.IncludePrerelease = true;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
-
- viewModel.IncludePrerelease = false;
-
- Assert.IsTrue (viewModel.IsReadingPackages);
- }
-
- [Test]
- public void IncludePrerelease_ChangedToTrue_PropertyChangedEventIsFired ()
- {
- CreateViewModel ();
- viewModel.IncludePrerelease = false;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
- PropertyChangedEventArgs propertyChangedEvent = null;
- viewModel.PropertyChanged += (sender, e) => propertyChangedEvent = e;
-
- viewModel.IncludePrerelease = true;
-
- Assert.IsNull (propertyChangedEvent.PropertyName);
- }
-
- [Test]
- public void IncludePrerelease_SetToTrueWhenAlreadyTrue_PropertyChangedEventIsNotFired ()
- {
- CreateViewModel ();
- viewModel.IncludePrerelease = true;
- viewModel.AddSixFakePackages ();
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- ClearReadPackagesTasks ();
- bool fired = false;
- viewModel.PropertyChanged += (sender, e) => fired = true;
-
- viewModel.IncludePrerelease = true;
-
- Assert.IsFalse (fired);
- }
-
- [Test]
- public void CheckedPackageViewModels_TwoPackagesAndOnePackageIsChecked_ReturnsOneCheckedPackage ()
- {
- CreateViewModel ();
- FakePackage package = viewModel.AddFakePackage ("MyPackage");
- var expectedPackages = new FakePackage [] { package };
- viewModel.AddFakePackage ("Z-Package");
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
-
- viewModel.PackageViewModels [0].IsChecked = true;
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.CheckedPackageViewModels);
- }
-
- [Test]
- public void CheckedPackageViewModels_OnePackageIsCheckedThenNewSearchReturnsNoPackages_ReturnsCheckedPackageEvenWhenNotVisible ()
- {
- CreateViewModel ();
- FakePackage package = viewModel.AddFakePackage ("MyPackage");
- var expectedPackages = new FakePackage [] { package };
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.PackageViewModels [0].IsChecked = true;
- viewModel.FakePackages.Clear ();
- viewModel.AddFakePackage ("AnotherPackage");
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.CheckedPackageViewModels);
- }
-
- [Test]
- public void CheckedPackageViewModels_OnePackageIsCheckedAndThenUnchecked_ReturnsNoCheckedPackages ()
- {
- CreateViewModel ();
- viewModel.AddFakePackage ("MyPackage");
- viewModel.AddFakePackage ("Z-Package");
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- PackageViewModel packageViewModel = viewModel.PackageViewModels [0];
- packageViewModel.IsChecked = true;
- packageViewModel.IsChecked = false;
-
- PackageCollectionAssert.AreEqual (new FakePackage [0], viewModel.CheckedPackageViewModels);
- }
-
- [Test]
- public void PackageViewModels_OnePackageIsCheckedAndNewSearchReturnsOriginalPackage_PackageViewHasIsCheckedSetToTrue ()
- {
- CreateViewModel ();
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.PackageViewModels [0].IsChecked = true;
- viewModel.FakePackages.Clear ();
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- PackageViewModel packageViewModel = viewModel.PackageViewModels [0];
-
- Assert.AreEqual ("MyPackage", packageViewModel.Id);
- Assert.IsTrue (packageViewModel.IsChecked);
- }
-
- [Test]
- public void PackageViewModels_OnePackageIsCheckedAndNewSearchReturnsOriginalPackageButWithDifferentVersion_PackageViewHasIsCheckedSetToFalse ()
- {
- CreateViewModel ();
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.PackageViewModels [0].IsChecked = true;
- viewModel.FakePackages.Clear ();
- viewModel.AddFakePackage ("MyPackage", "1.1");
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- PackageViewModel packageViewModel = viewModel.PackageViewModels [0];
-
- Assert.AreEqual ("MyPackage", packageViewModel.Id);
- Assert.IsFalse (packageViewModel.IsChecked);
- }
-
- [Test]
- public void CheckedPackageViewModels_OnePackageIsCheckedAndNewSearchReturnsMultipleVersionsOfOriginalPackage_OnlyPackageWithSameVersionIsChecked ()
- {
- CreateViewModel ();
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.PackageViewModels [0].IsChecked = true;
- viewModel.FakePackages.Clear ();
- viewModel.AddFakePackage ("MyPackage", "1.1");
- viewModel.AddFakePackage ("MyPackage", "1.2");
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.AddFakePackage ("MyPackage", "1.3");
- viewModel.AddFakePackage ("MyPackage", "1.4");
- viewModel.Search ();
- CompleteReadPackagesTask ();
-
- PackageViewModel packageViewModel = viewModel.CheckedPackageViewModels.FirstOrDefault ();
-
- Assert.AreEqual ("MyPackage", packageViewModel.Id);
- Assert.AreEqual ("1.0", packageViewModel.Version.ToString ());
- Assert.AreEqual (1, viewModel.CheckedPackageViewModels.Count);
- }
-
- [Test]
- public void PackageViewModels_OnePackageIsCheckedAndNewSearchReturnsOriginalPackageWhichIsThenUncheckedByUser_NoCheckedPackageViewModels ()
- {
- CreateViewModel ();
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- viewModel.PackageViewModels [0].IsChecked = true;
- viewModel.FakePackages.Clear ();
- viewModel.AddFakePackage ("MyPackage", "1.0");
- viewModel.Search ();
- CompleteReadPackagesTask ();
- PackageViewModel packageViewModel = viewModel.PackageViewModels [0];
-
- viewModel.PackageViewModels [0].IsChecked = false;
-
- PackageCollectionAssert.AreEqual (new FakePackage [0], viewModel.CheckedPackageViewModels);
- }
-
- [Test]
- public void CheckedPackageViewModels_OnePackageVersionIsCheckedThenDifferentVersionChecked_OldVersionIsUnchecked ()
- {
- CreateViewModel ();
- FakePackage oldPackage = viewModel.AddFakePackage ("MyPackage", "1.1");
- viewModel.AddFakePackage ("MyPackage", "1.2");
- viewModel.AddFakePackage ("MyPackage", "1.0");
- FakePackage newPackage = viewModel.AddFakePackage ("MyPackage", "1.3");
- viewModel.AddFakePackage ("MyPackage", "1.4");
- var expectedPackages = new FakePackage [] { newPackage };
- viewModel.ReadPackages ();
- CompleteReadPackagesTask ();
- PackageViewModel oldPackageVersionViewModel = viewModel
- .PackageViewModels
- .First (item => item.Version == oldPackage.Version);
- PackageViewModel newPackageVersionViewModel = viewModel
- .PackageViewModels
- .First (item => item.Version == newPackage.Version);
- oldPackageVersionViewModel.IsChecked = true;
-
- newPackageVersionViewModel.IsChecked = true;
-
- PackageCollectionAssert.AreEqual (expectedPackages, viewModel.CheckedPackageViewModels);
- Assert.IsFalse (oldPackageVersionViewModel.IsChecked);
- }
-
- [Test]
- public void ReadPackages_ReadPackagesCalledAgainAfterFirstOneFailed_ErrorIsCleared ()
- {
- CreateViewModel ();
- viewModel.ReadPackages ();
- var ex = new Exception ("Test");
- var aggregateEx = new AggregateException (ex);
- taskFactory.FirstFakeTaskCreated.Exception = aggregateEx;
- taskFactory.FirstFakeTaskCreated.IsFaulted = true;
- CompleteReadPackagesTask ();
- bool hasErrorAfterFirstRead = viewModel.HasError;
-
- viewModel.ReadPackages ();
-
- Assert.IsTrue (hasErrorAfterFirstRead);
- Assert.IsFalse (viewModel.HasError);
- Assert.AreEqual (String.Empty, viewModel.ErrorMessage);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProcessPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProcessPackageActionTests.cs deleted file mode 100644 index 213dbfb3e8..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProcessPackageActionTests.cs +++ /dev/null @@ -1,110 +0,0 @@ -//
-// ProcessPackageActionTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class ProcessPackageActionTests
- {
- TestableProcessPackageAction action;
- FakePackageManagementProject fakeProject;
- ExceptionThrowingProcessPackageAction exceptionThrowingAction;
-
- void CreateAction ()
- {
- action = new TestableProcessPackageAction ();
- fakeProject = action.FakeProject;
- }
-
- ILogger AddLoggerToAction ()
- {
- var logger = new NullLogger ();
- action.Logger = logger;
- return logger;
- }
-
- void CreateActionWithExceptionThrownInExecuteCore ()
- {
- exceptionThrowingAction = new ExceptionThrowingProcessPackageAction ();
- }
-
- [Test]
- public void Execute_LoggerIsNull_LoggerUsedByProjectIsPackageManagementLogger ()
- {
- CreateAction ();
- action.Execute ();
-
- ILogger actualLogger = fakeProject.Logger;
-
- Assert.IsInstanceOf<PackageManagementLogger> (actualLogger);
- }
-
- [Test]
- public void Execute_LoggerIsDefined_LoggerDefinedIsUsedByProjectManager ()
- {
- CreateAction ();
- ILogger expectedLogger = AddLoggerToAction ();
- action.Execute ();
-
- ILogger actualLogger = fakeProject.Logger;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void BeforeExecute_LoggerIsDefined_LoggerUsedByProjectIsConfiguredBeforeInstallPackageCalled ()
- {
- CreateAction ();
- ILogger expectedLogger = AddLoggerToAction ();
- action.CallBeforeExecute ();
-
- ILogger actualLogger = fakeProject.Logger;
-
- Assert.AreEqual (expectedLogger, actualLogger);
- }
-
- [Test]
- public void Execute_ExceptionThrownInExecuteCore_ExceptionThrownByExecuteMethod ()
- {
- CreateActionWithExceptionThrownInExecuteCore ();
- var expectedException = new Exception ("Error");
- exceptionThrowingAction.ExceptionToThrowInExecuteCore = expectedException;
-
- Exception exception = Assert.Throws<Exception> (() => exceptionThrowingAction.Execute ());
-
- Assert.AreEqual (expectedException, exception);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectPackagesFolderNodeTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectPackagesFolderNodeTests.cs index 660952167b..4bb871cb7a 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectPackagesFolderNodeTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectPackagesFolderNodeTests.cs @@ -27,11 +27,14 @@ using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.PackageManagement.NodeBuilders;
using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
+using NuGet.Versioning;
using NUnit.Framework;
namespace MonoDevelop.PackageManagement.Tests
@@ -40,12 +43,12 @@ namespace MonoDevelop.PackageManagement.Tests public class ProjectPackagesFolderNodeTests
{
TestableProjectPackagesFolderNode packagesFolderNode;
- FakeUpdatedPackagesInSolution updatedPackagesInSolution;
+ FakeUpdatedPackagesInWorkspace updatedPackagesInSolution;
FakeDotNetProject project;
void CreateNode ()
{
- updatedPackagesInSolution = new FakeUpdatedPackagesInSolution ();
+ updatedPackagesInSolution = new FakeUpdatedPackagesInWorkspace ();
project = new FakeDotNetProject ();
packagesFolderNode = new TestableProjectPackagesFolderNode (project, updatedPackagesInSolution);
}
@@ -54,22 +57,35 @@ namespace MonoDevelop.PackageManagement.Tests string packageId = "Id",
string version = "1.2.3")
{
- var semanticVersion = new SemanticVersion (version);
- var packageReference = new PackageReference (packageId, semanticVersion, null, null, false, false);
+ var semanticVersion = new NuGetVersion (version);
+ var identity = new PackageIdentity (packageId, semanticVersion);
+ var packageReference = new PackageReference (identity, null);
+ packagesFolderNode.PackageReferences.Add (packageReference);
+ return packageReference;
+ }
+
+ PackageReference AddFloatingPackageReferenceToProject (
+ string packageId,
+ string version)
+ {
+ var packageReference = TestPackageReferenceFactory.CreatePackageReferenceWithProjectJsonWildcardVersion (
+ packageId,
+ version
+ );
packagesFolderNode.PackageReferences.Add (packageReference);
return packageReference;
}
void AddUpdatedPackageForProject (string packageId, string version)
{
- var packageName = new PackageName (packageId, new SemanticVersion (version));
+ var packageName = new PackageIdentity (packageId, new NuGetVersion (version));
updatedPackagesInSolution.AddUpdatedPackages (project, packageName);
}
void AddUpdatedPackagesForProject (string packageId1, string version1, string packageId2, string version2)
{
- var packageName1 = new PackageName (packageId1, new SemanticVersion (version1));
- var packageName2 = new PackageName (packageId2, new SemanticVersion (version2));
+ var packageName1 = new PackageIdentity (packageId1, new NuGetVersion (version1));
+ var packageName2 = new PackageIdentity (packageId2, new NuGetVersion (version2));
updatedPackagesInSolution.AddUpdatedPackages (project, packageName1, packageName2);
}
@@ -83,11 +99,18 @@ namespace MonoDevelop.PackageManagement.Tests packagesFolderNode.PackageReferencesWithPackageInstalled.Add (packageReference);
}
+ Task RefreshNodePackages ()
+ {
+ packagesFolderNode.RefreshPackages ();
+ return packagesFolderNode.RefreshTaskCompletionSource.Task;
+ }
+
[Test]
- public void GetLabel_NoUpdatedPackages_ReturnsPackages ()
+ public async Task GetLabel_NoUpdatedPackages_ReturnsPackages ()
{
CreateNode ();
NoUpdatedPackages ();
+ await RefreshNodePackages ();
string label = packagesFolderNode.GetLabel ();
string secondaryLabel = packagesFolderNode.GetSecondaryLabel ();
@@ -119,11 +142,12 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetLabel_OneUpdatedPackage_ReturnsPackagesWithCount ()
+ public async Task GetLabel_OneUpdatedPackage_ReturnsPackagesWithCount ()
{
CreateNode ();
AddPackageReferenceToProject ("MyPackage", "1.0");
AddUpdatedPackageForProject ("MyPackage", "1.1");
+ await RefreshNodePackages ();
string label = packagesFolderNode.GetLabel ();
string secondaryLabel = packagesFolderNode.GetSecondaryLabel ();
@@ -133,12 +157,13 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetLabel_TwoUpdatedPackages_ReturnsPackagesWithCount ()
+ public async Task GetLabel_TwoUpdatedPackages_ReturnsPackagesWithCount ()
{
CreateNode ();
AddPackageReferenceToProject ("One", "1.0");
AddPackageReferenceToProject ("Two", "1.0");
AddUpdatedPackagesForProject ("One", "1.1", "Two", "1.3");
+ await RefreshNodePackages ();
string label = packagesFolderNode.GetLabel ();
string secondaryLabel = packagesFolderNode.GetSecondaryLabel ();
@@ -148,12 +173,13 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetPackageReferencesNodes_OnePackageReferenceButNoUpdatedPackages_ReturnsOneNode ()
+ public async Task GetPackageReferencesNodes_OnePackageReferenceButNoUpdatedPackages_ReturnsOneNode ()
{
CreateNode ();
PackageReference packageReference = AddPackageReferenceToProject ("MyPackage", "1.0");
PackageIsInstalledInProject (packageReference);
NoUpdatedPackages ();
+ await RefreshNodePackages ();
List<PackageReferenceNode> nodes = packagesFolderNode.GetPackageReferencesNodes ().ToList ();
@@ -165,11 +191,12 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetPackageReferencesNodes_OnePackageReferenceButPackageNotInstalledAndNoUpdatedPackages_ReturnsOneNode ()
+ public async Task GetPackageReferencesNodes_OnePackageReferenceButPackageNotInstalledAndNoUpdatedPackages_ReturnsOneNode ()
{
CreateNode ();
AddPackageReferenceToProject ("MyPackage", "1.0");
NoUpdatedPackages ();
+ await RefreshNodePackages ();
List<PackageReferenceNode> nodes = packagesFolderNode.GetPackageReferencesNodes ().ToList ();
@@ -181,12 +208,13 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetPackageReferencesNodes_OnePackageReferenceWithUpdatedPackages_ReturnsOneNodeWithUpdatedVersionInformationInLabel ()
+ public async Task GetPackageReferencesNodes_OnePackageReferenceWithUpdatedPackages_ReturnsOneNodeWithUpdatedVersionInformationInLabel ()
{
CreateNode ();
PackageReference packageReference = AddPackageReferenceToProject ("MyPackage", "1.0");
PackageIsInstalledInProject (packageReference);
AddUpdatedPackageForProject ("MyPackage", "1.2");
+ await RefreshNodePackages ();
List<PackageReferenceNode> nodes = packagesFolderNode.GetPackageReferencesNodes ().ToList ();
@@ -198,11 +226,12 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetPackageReferencesNodes_OnePackageReferenceWithUpdatedPackagesButPackageNotRestored_ReturnsOneNodeWithUpdatedVersionInformationInLabel ()
+ public async Task GetPackageReferencesNodes_OnePackageReferenceWithUpdatedPackagesButPackageNotRestored_ReturnsOneNodeWithUpdatedVersionInformationInLabel ()
{
CreateNode ();
AddPackageReferenceToProject ("MyPackage", "1.0");
AddUpdatedPackageForProject ("MyPackage", "1.2");
+ await RefreshNodePackages ();
List<PackageReferenceNode> nodes = packagesFolderNode.GetPackageReferencesNodes ().ToList ();
@@ -214,6 +243,40 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual (Stock.Reference, referenceNode.GetIconId ());
Assert.IsTrue (referenceNode.IsDisabled ());
}
+
+ [Test]
+ public async Task GetLabel_OneUpdatedPackageButInstalledPackageNotReadFromProjectYet_PackageCountNotShownUntilInstalledPackagesAreRead ()
+ {
+ CreateNode ();
+ AddPackageReferenceToProject ("MyPackage", "1.0");
+ AddUpdatedPackageForProject ("MyPackage", "1.1");
+ string labelBeforeInstalledPackagesRead = packagesFolderNode.GetLabel ();
+ string secondaryLabelBeforeInstalledPackagesRead = packagesFolderNode.GetSecondaryLabel ();
+ await RefreshNodePackages ();
+
+ string labelAfterInstalledPackagesRead = packagesFolderNode.GetLabel ();
+ string secondaryLabelAfterInstalledPackagesRead = packagesFolderNode.GetSecondaryLabel ();
+
+ Assert.AreEqual ("Packages", labelBeforeInstalledPackagesRead);
+ Assert.AreEqual (String.Empty, secondaryLabelBeforeInstalledPackagesRead);
+ Assert.AreEqual ("Packages", labelAfterInstalledPackagesRead);
+ Assert.AreEqual ("(1 update)", secondaryLabelAfterInstalledPackagesRead);
+ }
+
+ [Test]
+ public async Task GetLabel_ProjectJsonPackageReferenceUsesWildcardAndPackageIsNotInstalled_PackageIsShownAsInstalled ()
+ {
+ CreateNode ();
+ AddFloatingPackageReferenceToProject ("MyPackage", "1.2.3-*");
+ NoUpdatedPackages ();
+ await RefreshNodePackages ();
+
+ var referenceNode = packagesFolderNode.GetPackageReferencesNodes ().Single ();
+
+ Assert.AreEqual ("MyPackage", referenceNode.GetLabel ());
+ Assert.AreEqual ("Version 1.2.3-*", referenceNode.GetPackageVersionLabel ());
+ Assert.IsTrue (referenceNode.Installed);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectTargetFrameworkMonitorTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectTargetFrameworkMonitorTests.cs index 7be5ccceed..cdf7bc0910 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectTargetFrameworkMonitorTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ProjectTargetFrameworkMonitorTests.cs @@ -102,16 +102,19 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void ProjectTargetFrameworkChanged_ProjectTargetFrameworkChanged_EventFires ()
+ public void ProjectTargetFrameworkChanged_ProjectTargetFrameworkChanged_EventFiresAfterProjectIsSaved ()
{
CreateProjectTargetFrameworkMonitor ();
FakeDotNetProject project = LoadSolutionWithOneProject ();
CaptureProjectTargetFrameworkChangedEvents ();
project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ int eventArgsCountBeforeSave = eventArgs.Count;
+ project.RaiseSavedEvent ();
Assert.AreEqual (1, eventArgs.Count);
Assert.AreEqual (project, eventArgs [0].Project);
+ Assert.AreEqual (0, eventArgsCountBeforeSave);
}
[Test]
@@ -133,6 +136,7 @@ namespace MonoDevelop.PackageManagement.Tests CaptureProjectTargetFrameworkChangedEvents ();
project.RaiseModifiedEvent (project, "SomeOtherProperty");
+ project.RaiseSavedEvent ();
Assert.AreEqual (0, eventArgs.Count);
}
@@ -145,6 +149,7 @@ namespace MonoDevelop.PackageManagement.Tests CaptureProjectTargetFrameworkChangedEvents ();
project.RaiseModifiedEvent (project, targetFrameworkPropertyName.ToUpperInvariant ());
+ project.RaiseSavedEvent ();
Assert.AreEqual (1, eventArgs.Count);
Assert.AreEqual (project, eventArgs [0].Project);
@@ -159,6 +164,7 @@ namespace MonoDevelop.PackageManagement.Tests UnloadSolution ();
project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ project.RaiseSavedEvent ();
Assert.AreEqual (0, eventArgs.Count);
}
@@ -172,6 +178,7 @@ namespace MonoDevelop.PackageManagement.Tests FakeDotNetProject project = AddNewProjectToSolution ();
project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ project.RaiseSavedEvent ();
Assert.AreEqual (1, eventArgs.Count);
Assert.AreEqual (project, eventArgs [0].Project);
@@ -187,6 +194,7 @@ namespace MonoDevelop.PackageManagement.Tests UnloadSolution ();
project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ project.RaiseSavedEvent ();
Assert.AreEqual (0, eventArgs.Count);
}
@@ -201,6 +209,7 @@ namespace MonoDevelop.PackageManagement.Tests FakeDotNetProject project = AddNewProjectToSolution ();
project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ project.RaiseSavedEvent ();
Assert.AreEqual (0, eventArgs.Count);
}
@@ -270,6 +279,8 @@ namespace MonoDevelop.PackageManagement.Tests firstProject.RaiseModifiedEvent (firstProject, targetFrameworkPropertyName);
secondProject.RaiseModifiedEvent (secondProject, targetFrameworkPropertyName);
+ firstProject.RaiseSavedEvent ();
+ secondProject.RaiseSavedEvent ();
Assert.AreEqual (2, eventArgs.Count);
Assert.AreEqual (firstProject, eventArgs [0].Project);
@@ -288,6 +299,8 @@ namespace MonoDevelop.PackageManagement.Tests firstProject.RaiseModifiedEvent (firstProject, targetFrameworkPropertyName);
secondProject.RaiseModifiedEvent (secondProject, targetFrameworkPropertyName);
+ firstProject.RaiseSavedEvent ();
+ secondProject.RaiseSavedEvent ();
Assert.AreEqual (1, eventArgs.Count);
Assert.AreEqual (firstProject, eventArgs [0].Project);
@@ -306,6 +319,8 @@ namespace MonoDevelop.PackageManagement.Tests firstProject.RaiseModifiedEvent (firstProject, targetFrameworkPropertyName);
secondProject.RaiseModifiedEvent (secondProject, targetFrameworkPropertyName);
+ firstProject.RaiseSavedEvent ();
+ secondProject.RaiseSavedEvent ();
Assert.AreEqual (1, eventArgs.Count);
Assert.AreEqual (secondProject, eventArgs [0].Project);
@@ -325,6 +340,52 @@ namespace MonoDevelop.PackageManagement.Tests solution.RaiseProjectRemovedEvent (project);
originalProject.RaiseModifiedEvent (originalProject, targetFrameworkPropertyName);
+ originalProject.RaiseSavedEvent ();
+
+ Assert.AreEqual (0, eventArgs.Count);
+ }
+
+ [Test]
+ public void ProjectTargetFrameworkChanged_ProjectNotSaved_EventDoesNotFire ()
+ {
+ CreateProjectTargetFrameworkMonitor ();
+ FakeDotNetProject project = LoadSolutionWithOneProject ();
+ CaptureProjectTargetFrameworkChangedEvents ();
+
+ project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+
+ Assert.AreEqual (0, eventArgs.Count);
+ }
+
+ [Test]
+ public void ProjectTargetFrameworkChanged_ProjectTargetFrameworkChangedAndProjectSavedTwiceAfterwards_EventFiresOnce ()
+ {
+ CreateProjectTargetFrameworkMonitor ();
+ FakeDotNetProject project = LoadSolutionWithOneProject ();
+ CaptureProjectTargetFrameworkChangedEvents ();
+
+ project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ project.RaiseSavedEvent ();
+ project.RaiseSavedEvent ();
+
+ Assert.AreEqual (1, eventArgs.Count);
+ Assert.AreEqual (project, eventArgs [0].Project);
+ }
+
+ /// <summary>
+ /// Ensures the ProjectSaved event handler is removed when the solution is unloaded.
+ /// </summary>
+ /// <returns>The target framework changed project target framework changed solution unloaded then project saved event does not fire.</returns>
+ [Test]
+ public void ProjectTargetFrameworkChanged_ProjectTargetFrameworkChangedSolutionUnloadedThenProjectSaved_EventDoesNotFire ()
+ {
+ CreateProjectTargetFrameworkMonitor ();
+ FakeDotNetProject project = LoadSolutionWithOneProject ();
+ CaptureProjectTargetFrameworkChangedEvents ();
+ project.RaiseModifiedEvent (project, targetFrameworkPropertyName);
+ UnloadSolution ();
+
+ project.RaiseSavedEvent ();
Assert.AreEqual (0, eventArgs.Count);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentNuGetPackagesRepositoryTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentNuGetPackagesRepositoryTests.cs new file mode 100644 index 0000000000..9bd5595b66 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentNuGetPackagesRepositoryTests.cs @@ -0,0 +1,172 @@ +//
+// RecentNuGetPackagesRepositoryTests.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.Collections.Generic;
+using System.Linq;
+using MonoDevelop.PackageManagement.Tests.Helpers;
+using NuGet.PackageManagement.UI;
+using NUnit.Framework;
+
+namespace MonoDevelop.PackageManagement.Tests
+{
+ [TestFixture]
+ public class RecentNuGetPackagesRepositoryTests
+ {
+ RecentNuGetPackagesRepository repository;
+
+ void CreateRepository ()
+ {
+ repository = new RecentNuGetPackagesRepository ();
+ }
+
+ PackageSearchResultViewModel AddOnePackageToRepository (string id, string packageSource)
+ {
+ var viewModel = CreatePackage (id);
+ repository.AddPackage (viewModel, packageSource);
+ return viewModel;
+ }
+
+ PackageSearchResultViewModel CreatePackage (string id)
+ {
+ var packageViewModel = new PackageItemListViewModel {
+ Id = id
+ };
+ return new PackageSearchResultViewModel (null, packageViewModel);
+ }
+
+ IEnumerable<PackageSearchResultViewModel> AddTwoDifferentPackagesToRepository (string packageSource)
+ {
+ yield return AddOnePackageToRepository ("Test.Package.1", packageSource);
+ yield return AddOnePackageToRepository ("Test.Package.2", packageSource);
+ }
+
+ IEnumerable<PackageSearchResultViewModel> AddFourDifferentPackagesToRepository (string packageSource)
+ {
+ yield return AddOnePackageToRepository ("Test.Package.1", packageSource);
+ yield return AddOnePackageToRepository ("Test.Package.2", packageSource);
+ yield return AddOnePackageToRepository ("Test.Package.3", packageSource);
+ yield return AddOnePackageToRepository ("Test.Package.4", packageSource);
+ }
+
+ [Test]
+ public void GetPackages_RepositoryIsEmptyAndOnePackageAdded_ReturnsPackageAdded ()
+ {
+ CreateRepository ();
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ var package = AddOnePackageToRepository ("Test.Package", packageSourceUrl);
+
+ var packages = repository.GetPackages (packageSourceUrl);
+
+ Assert.AreEqual (package, packages.Single ());
+ }
+
+ [Test]
+ public void AddPackage_NoRecentPackages_PackageMarkedAsRecentPackage ()
+ {
+ CreateRepository ();
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ var package = CreatePackage ("Test");
+ package.IsRecentPackage = false;
+ repository.AddPackage (package, packageSourceUrl);
+
+ Assert.IsTrue (package.IsRecentPackage);
+ }
+
+ [Test]
+ public void GetPackages_RepositoryHasOnePackageAddedDifferentPackageSourceRequested_ReturnsNoPackages ()
+ {
+ CreateRepository ();
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ AddOnePackageToRepository ("Test.Package", packageSourceUrl);
+
+ var packages = repository.GetPackages ("http://another/nuget/v2");
+
+ Assert.AreEqual (0, packages.Count ());
+ }
+
+ [Test]
+ public void GetPackages_RepositoryIsEmptyAndTwoDifferentPackagesAdded_ReturnsPackagesInReverseOrderWithLastAddedFirst ()
+ {
+ CreateRepository ();
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ var packagesAdded = AddTwoDifferentPackagesToRepository (packageSourceUrl);
+
+ var packages = repository.GetPackages (packageSourceUrl);
+
+ var expectedPackages = packagesAdded.Reverse ();
+
+ CollectionAssert.AreEqual (expectedPackages, packages);
+ }
+
+ [Test]
+ public void GetPackages_RepositoryCanHoldThreePackagesAndFourPackagesAdded_ReturnsLastThreePackagesAddedInReverseOrder ()
+ {
+ CreateRepository ();
+ repository.MaximumPackagesCount = 3;
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ var packagesAdded = AddFourDifferentPackagesToRepository (packageSourceUrl);
+
+ var packages = repository.GetPackages (packageSourceUrl);
+
+ var expectedPackages = packagesAdded.Reverse ().Take (3);
+
+ CollectionAssert.AreEqual (expectedPackages, packages);
+ }
+
+ [Test]
+ public void GetPackages_RepositoryIsEmptyAndSamePackageIsAddedTwice_OnePackageReturned ()
+ {
+ CreateRepository ();
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ AddOnePackageToRepository ("Test", packageSourceUrl);
+ var package = AddOnePackageToRepository ("Test", packageSourceUrl);
+
+ var packages = repository.GetPackages (packageSourceUrl);
+
+ var expectedPackages = new [] {
+ package
+ };
+
+ CollectionAssert.AreEqual (expectedPackages, packages);
+ }
+
+ [Test]
+ public void AddPackage_RepositoryIsEmptyAndTwoPackagesAdded_BothRecentPackagesAdded ()
+ {
+ CreateRepository ();
+ string packageSourceUrl = "http://test.com/nuget/v2";
+ var package1 = AddOnePackageToRepository ("Test1", packageSourceUrl);
+ var package2 = AddOnePackageToRepository ("Test2", packageSourceUrl);
+
+ var expectedPackages = new [] {
+ package2,
+ package1
+ };
+
+ CollectionAssert.AreEqual (expectedPackages, repository.GetPackages (packageSourceUrl));
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentPackageInfoTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentPackageInfoTests.cs deleted file mode 100644 index fb35e28ed3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentPackageInfoTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -//
-// RecentPackageInfoTests.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 MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class RecentPackageInfoTests
- {
- [Test]
- public void ToString_IdAndVersionSpecified_ContainsIdAndVersion ()
- {
- var recentPackageInfo = new RecentPackageInfo ("id", new SemanticVersion ("1.0"));
-
- string actual = recentPackageInfo.ToString ();
-
- string expected = "[RecentPackageInfo Id=id, Version=1.0]";
- Assert.AreEqual (expected, actual);
- }
-
- [Test]
- public void IsMatch_PackageWithSameIdAndVersionPassed_ReturnsTrue ()
- {
- string id = "id";
- var version = new SemanticVersion (1, 0, 0, 0);
- var recentPackageInfo = new RecentPackageInfo (id, version);
- var package = new FakePackage (id);
- package.Version = version;
-
- bool result = recentPackageInfo.IsMatch (package);
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void IsMatch_PackageWithSameIdButDifferentVersionPassed_ReturnsFalse ()
- {
- string id = "id";
- var version = new SemanticVersion (1, 0, 0, 0);
- var recentPackageInfo = new RecentPackageInfo (id, version);
- var package = new FakePackage (id);
- package.Version = new SemanticVersion (2, 0, 0, 0);
-
- bool result = recentPackageInfo.IsMatch (package);
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void IsMatch_PackageWithDifferentIdButSameVersionPassed_ReturnsFalse ()
- {
- var version = new SemanticVersion (1, 0, 0, 0);
- var recentPackageInfo = new RecentPackageInfo ("id", version);
- var package = new FakePackage ("different-id");
- package.Version = version;
-
- bool result = recentPackageInfo.IsMatch (package);
-
- Assert.IsFalse (result);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentPackageRepositoryTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentPackageRepositoryTests.cs deleted file mode 100644 index 923997dae6..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RecentPackageRepositoryTests.cs +++ /dev/null @@ -1,231 +0,0 @@ -//
-// RecentPackageRepositoryTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class RecentPackageRepositoryTests
- {
- RecentPackageRepository repository;
- FakePackageRepository aggregateRepository;
- List<RecentPackageInfo> recentPackages;
-
- void CreateRepository ()
- {
- CreateRecentPackages ();
- CreateRepository (recentPackages);
- }
-
- void CreateRecentPackages ()
- {
- recentPackages = new List<RecentPackageInfo> ();
- aggregateRepository = new FakePackageRepository ();
- }
-
- void CreateRepository (IList<RecentPackageInfo> recentPackages)
- {
- repository = new RecentPackageRepository (recentPackages, aggregateRepository);
- }
-
- FakePackage AddOnePackageToRepository (string id)
- {
- var package = new FakePackage (id);
- repository.AddPackage (package);
- return package;
- }
-
- IEnumerable<IPackage> AddTwoDifferentPackagesToRepository ()
- {
- yield return AddOnePackageToRepository ("Test.Package.1");
- yield return AddOnePackageToRepository ("Test.Package.2");
- }
-
- IEnumerable<IPackage> AddFourDifferentPackagesToRepository ()
- {
- yield return AddOnePackageToRepository ("Test.Package.1");
- yield return AddOnePackageToRepository ("Test.Package.2");
- yield return AddOnePackageToRepository ("Test.Package.3");
- yield return AddOnePackageToRepository ("Test.Package.4");
- }
-
- FakePackage CreateRepositoryWithOneRecentPackageSavedInOptions ()
- {
- CreateRecentPackages ();
- var package = new FakePackage ("Test");
- aggregateRepository.FakePackages.Add (package);
- recentPackages.Add (new RecentPackageInfo (package));
- CreateRepository (recentPackages);
- return package;
- }
-
- [Test]
- public void Source_NewRecentRepositoryCreated_IsRecentPackages ()
- {
- CreateRepository ();
- Assert.AreEqual ("RecentPackages", repository.Source);
- }
-
- [Test]
- public void GetPackages_RepositoryIsEmptyAndOnePackageAdded_ReturnsPackageAdded ()
- {
- CreateRepository ();
- var package = AddOnePackageToRepository ("Test.Package");
-
- var packages = repository.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- package
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetPackages_RepositoryIsEmptyAndTwoDifferentPackagesAdded_ReturnsPackagesInReverseOrderWithLastAddedFirst ()
- {
- CreateRepository ();
- var packagesAdded = AddTwoDifferentPackagesToRepository ();
-
- var packages = repository.GetPackages ();
-
- var expectedPackages = packagesAdded.Reverse ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetPackages_RepositoryCanHoldThreePackagesAndFourPackagesAdded_ReturnsLastThreePackagesAddedInReverseOrder ()
- {
- CreateRepository ();
- repository.MaximumPackagesCount = 3;
- var packagesAdded = AddFourDifferentPackagesToRepository ();
-
- var packages = repository.GetPackages ();
-
- var expectedPackages = packagesAdded.Reverse ().Take (3);
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetPackages_RepositoryIsEmptyAndSamePackageIsAddedTwice_OnePackageReturned ()
- {
- CreateRepository ();
- AddOnePackageToRepository ("Test");
- var package = AddOnePackageToRepository ("Test");
-
- var packages = repository.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- package
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void AddPackage_RepositoryIsEmptyAndTwoPackagesAddedFromDifferentSources_BothRecentPackagesAdded ()
- {
- CreateRepository ();
- var package1 = AddOnePackageToRepository ("Test1");
- var package2 = AddOnePackageToRepository ("Test2");
-
- var expectedPackages = new IPackage[] {
- package2,
- package1
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, repository.GetPackages ());
- }
-
- public void Clear_OneRecentPackage_PackagesRemoved ()
- {
- CreateRepository ();
- AddOnePackageToRepository ("Test1");
-
- repository.Clear ();
-
- int count = repository.GetPackages ().Count ();
-
- Assert.AreEqual (0, count);
- }
-
- [Test]
- public void Clear_OneRecentPackageInOptions_RecentPackagesAreRemovedFromOptions ()
- {
- CreateRepositoryWithOneRecentPackageSavedInOptions ();
-
- repository.Clear ();
-
- int count = recentPackages.Count;
-
- Assert.AreEqual (0, count);
- }
-
- [Test]
- public void HasRecentPackages_NoSavedRecentPackages_ReturnsFalse ()
- {
- CreateRepository ();
-
- bool hasRecentPackages = repository.HasRecentPackages;
-
- Assert.IsFalse (hasRecentPackages);
- }
-
- [Test]
- public void HasRecentPackages_OneSavedRecentPackages_ReturnsTrue ()
- {
- CreateRepositoryWithOneRecentPackageSavedInOptions ();
-
- bool hasRecentPackages = repository.HasRecentPackages;
-
- Assert.IsTrue (hasRecentPackages);
- }
-
- [Test]
- public void GetPackages_TwoRecentPackagesButOneIsInvalid_OnlyValidPackageIsReturned ()
- {
- CreateRepository ();
- FakePackage package1 = AddOnePackageToRepository ("Test1");
- FakePackage package2 = AddOnePackageToRepository ("Test2");
- package2.IsValid = false;
-
- var expectedPackages = new IPackage[] {
- package1
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, repository.GetPackages ());
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReducedPackageOperationsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReducedPackageOperationsTests.cs deleted file mode 100644 index b230cf0802..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReducedPackageOperationsTests.cs +++ /dev/null @@ -1,188 +0,0 @@ -//
-// ReducedPackageOperationsTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class ReducedPackageOperationsTests
- {
- ReducedPackageOperations reducedPackageOperations;
- FakePackageOperationResolver fakePackageOperationResolver;
- List<IPackage> packages;
-
- void CreateReducedPackageOperations ()
- {
- packages = new List<IPackage> ();
- fakePackageOperationResolver = new FakePackageOperationResolver ();
- reducedPackageOperations = new ReducedPackageOperations (fakePackageOperationResolver, packages);
- }
-
- IPackage AddPackage (string id, string version)
- {
- IPackage package = CreatePackage (id, version);
- packages.Add (package);
-
- return package;
- }
-
- IPackage CreatePackage (string id, string version)
- {
- return new TestPackageHelper (id, version).Package;
- }
-
- PackageOperation AddInstallOperationForPackage (IPackage package)
- {
- var operation = new PackageOperation (package, PackageAction.Install);
- AddInstallOperationsForPackage (package, operation);
- return operation;
- }
-
- void AddInstallOperationsForPackage (IPackage package, params PackageOperation[] operations)
- {
- fakePackageOperationResolver.AddOperations (package, operations);
- }
-
- PackageOperation CreatePackageOperation (string id, string version, PackageAction action)
- {
- IPackage package = CreatePackage (id, version);
- return new PackageOperation (package, action);
- }
-
- void AssertReducedOperationsContains (PackageOperation operation)
- {
- Assert.IsTrue (reducedPackageOperations.Operations.ToList ().Contains (operation));
- }
-
- [Test]
- public void Reduce_OnePackage_ReturnsPackageOperationsFromResolverForPackage ()
- {
- CreateReducedPackageOperations ();
- IPackage package = AddPackage ("Test", "1.0");
- PackageOperation operation = AddInstallOperationForPackage (package);
-
- reducedPackageOperations.Reduce ();
-
- Assert.AreEqual (1, reducedPackageOperations.Operations.Count ());
- Assert.AreEqual (operation, reducedPackageOperations.Operations.First ());
- }
-
- [Test]
- public void Reduce_TwoPackages_ReturnsPackageOperationsForBothPackages ()
- {
- CreateReducedPackageOperations ();
- IPackage package1 = AddPackage ("Test", "1.0");
- IPackage package2 = AddPackage ("Test2", "1.0");
- PackageOperation operation1 = AddInstallOperationForPackage (package1);
- PackageOperation operation2 = AddInstallOperationForPackage (package2);
-
- reducedPackageOperations.Reduce ();
-
- Assert.AreEqual (2, reducedPackageOperations.Operations.Count ());
- AssertReducedOperationsContains (operation1);
- AssertReducedOperationsContains (operation2);
- }
-
- [Test]
- public void Reduce_OncePackageOperationInstallsPackageWhilstOneUninstallsSamePackage_PackageOperationNotIncludedInReducedSet ()
- {
- CreateReducedPackageOperations ();
- IPackage package = AddPackage ("Test", "1.0");
- PackageOperation installOperation = CreatePackageOperation ("Foo", "1.0", PackageAction.Install);
- PackageOperation uninstallOperation = CreatePackageOperation ("Foo", "1.0", PackageAction.Uninstall);
- AddInstallOperationsForPackage (package, installOperation, uninstallOperation);
-
- reducedPackageOperations.Reduce ();
-
- Assert.AreEqual (0, reducedPackageOperations.Operations.Count ());
- }
-
- [Test]
- public void Reduce_OnePackageOperationMatchesPackageBeingInstalled_ReturnsOnlyOnePackageInstallOperationForThisPackage ()
- {
- CreateReducedPackageOperations ();
- IPackage package1 = AddPackage ("Test", "1.0");
- IPackage package2 = AddPackage ("Test2", "1.0");
- PackageOperation operation1a = CreatePackageOperation ("Test", "1.0", PackageAction.Install);
- PackageOperation operation1b = CreatePackageOperation ("Test2", "1.0", PackageAction.Install);
- PackageOperation operation2 = CreatePackageOperation ("Test2", "1.0", PackageAction.Install);
- AddInstallOperationsForPackage (package1, operation1a, operation1b);
- AddInstallOperationsForPackage (package2, operation2);
-
- reducedPackageOperations.Reduce ();
-
- reducedPackageOperations
- .Operations
- .SingleOrDefault (o => o.Package.Id == "Test2");
- Assert.AreEqual (2, reducedPackageOperations.Operations.Count ());
- }
-
- [Test]
- public void Reduce_OnePackageOperationMatchesPackageBeingInstalledOnlyById_MatchingPackageOperationByIdIncludedInSet ()
- {
- CreateReducedPackageOperations ();
- IPackage package1 = AddPackage ("Test", "1.0");
- IPackage package2 = AddPackage ("Test2", "1.0");
- PackageOperation operation1a = CreatePackageOperation ("Test", "1.0", PackageAction.Install);
- PackageOperation operation1b = CreatePackageOperation ("Test2", "1.1", PackageAction.Install);
- PackageOperation operation2 = CreatePackageOperation ("Test2", "1.0", PackageAction.Install);
- AddInstallOperationsForPackage (package1, operation1a, operation1b);
- AddInstallOperationsForPackage (package2, operation2);
-
- reducedPackageOperations.Reduce ();
-
- Assert.AreEqual (3, reducedPackageOperations.Operations.Count ());
- }
-
- [Test]
- public void Reduce_OnePackageOperationMatchesPackageBeingInstalledByIdAndVersionButOneIsInstallAndOneIsUninstall_BothOperationsNotIncludedInSet ()
- {
- CreateReducedPackageOperations ();
- IPackage package1 = AddPackage ("Test", "1.0");
- IPackage package2 = AddPackage ("Test2", "1.0");
- PackageOperation operation1a = CreatePackageOperation ("Test", "1.0", PackageAction.Install);
- PackageOperation operation1b = CreatePackageOperation ("Test2", "1.0", PackageAction.Uninstall);
- PackageOperation operation2 = CreatePackageOperation ("Test2", "1.0", PackageAction.Install);
- AddInstallOperationsForPackage (package1, operation1a, operation1b);
- AddInstallOperationsForPackage (package2, operation2);
-
- reducedPackageOperations.Reduce ();
-
- reducedPackageOperations
- .Operations
- .SingleOrDefault (o => o.Package.Id == "Test");
- Assert.AreEqual (1, reducedPackageOperations.Operations.Count ());
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageRepositoriesTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageRepositoriesTests.cs deleted file mode 100644 index d13ffd344b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageRepositoriesTests.cs +++ /dev/null @@ -1,384 +0,0 @@ -//
-// RegisteredPackageRepositoriesTests.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 System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class RegisteredPackageRepositoriesTests
- {
- RegisteredPackageRepositories registeredRepositories;
- OneRegisteredPackageSourceHelper packageSourcesHelper;
- FakePackageRepositoryFactory fakeRepositoryCache;
-
- void CreateRegisteredPackageRepositories ()
- {
- CreatePackageSourcesHelper ();
- CreateRegisteredPackageRepositoriesWithExistingPackageSourcesHelper ();
- }
-
- void CreatePackageSourcesHelper ()
- {
- packageSourcesHelper = new OneRegisteredPackageSourceHelper ();
- }
-
- void CreateRegisteredPackageRepositoriesWithExistingPackageSourcesHelper ()
- {
- fakeRepositoryCache = new FakePackageRepositoryFactory ();
- registeredRepositories = new RegisteredPackageRepositories (fakeRepositoryCache, packageSourcesHelper.Options);
- }
-
- void AddPackageSourcesToSettings (params string[] sources)
- {
- var packageSources = sources.Select (source => new PackageSource (source));
- packageSourcesHelper.FakeSettings.AddFakePackageSources (packageSources);
- }
-
- void SetActivePackageSourceInSettings (PackageSource packageSource)
- {
- packageSourcesHelper.FakeSettings.SetFakeActivePackageSource (packageSource);
- }
-
- [Test]
- public void RecentPackageRepository_PropertyAccessed_ReturnsRecentPackageRepositoryFromCache ()
- {
- CreateRegisteredPackageRepositories ();
- IRecentPackageRepository recentRepository = registeredRepositories.RecentPackageRepository;
- FakeRecentPackageRepository expectedRepository = fakeRepositoryCache.FakeRecentPackageRepository;
-
- Assert.AreEqual (expectedRepository, recentRepository);
- }
-
- [Test]
- public void CreateRepository_PackageSourceSpecified_CreatesRepositoryFromCache ()
- {
- CreateRegisteredPackageRepositories ();
- IPackageRepository repository = registeredRepositories.CreateRepository (new PackageSource ("a"));
- FakePackageRepository expectedRepository = fakeRepositoryCache.FakePackageRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void CreateRepository_PackageSourceSpecified_PackageSourcePassedToCache ()
- {
- CreateRegisteredPackageRepositories ();
- var source = new PackageSource ("Test");
- registeredRepositories.CreateRepository (source);
- string actualSource = fakeRepositoryCache.FirstPackageSourcePassedToCreateRepository;
-
- Assert.AreEqual ("Test", actualSource);
- }
-
- [Test]
- public void CreateAggregateRepository_MethodCalled_ReturnsAggregateRepositoryCreatedFromCache ()
- {
- CreateRegisteredPackageRepositories ();
- IPackageRepository repository = registeredRepositories.CreateAggregateRepository ();
- FakePackageRepository expectedRepository = fakeRepositoryCache.FakeAggregateRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void HasMultiplePackageSources_OnePackageSource_ReturnsFalse ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddOnePackageSource ();
-
- bool result = registeredRepositories.HasMultiplePackageSources;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void HasMultiplePackageSources_TwoPackageSources_ReturnsTrue ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
-
- bool result = registeredRepositories.HasMultiplePackageSources;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void HasMultiplePackageSources_TwoPackageSourcesButOneIsDisabled_ReturnsFalse ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
- packageSourcesHelper.RegisteredPackageSources [0].IsEnabled = false;
-
- bool result = registeredRepositories.HasMultiplePackageSources;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void ActivePackageSource_TwoPackageSources_ByDefaultReturnsFirstPackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
-
- PackageSource expectedPackageSource = packageSourcesHelper.RegisteredPackageSources [0];
- PackageSource packageSource = registeredRepositories.ActivePackageSource;
-
- Assert.AreEqual (expectedPackageSource, packageSource);
- }
-
- [Test]
- public void ActivePackageSource_ChangedToSecondRegisteredPackageSources_ReturnsSecondPackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
-
- PackageSource expectedPackageSource = packageSourcesHelper.RegisteredPackageSources [1];
- registeredRepositories.ActivePackageSource = expectedPackageSource;
- PackageSource packageSource = registeredRepositories.ActivePackageSource;
-
- Assert.AreEqual (expectedPackageSource, packageSource);
- }
-
- [Test]
- public void ActivePackageSource_ChangedToNonNullPackageSource_SavedInOptions ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.Options.ActivePackageSource = null;
- var packageSource = new PackageSource ("http://source-url", "Test");
- packageSourcesHelper.Options.PackageSources.Add (packageSource);
-
- registeredRepositories.ActivePackageSource = packageSource;
-
- PackageSource actualPackageSource = packageSourcesHelper.Options.ActivePackageSource;
-
- Assert.AreEqual (packageSource, actualPackageSource);
- }
-
- [Test]
- public void ActivePackageSource_ActivePackageSourceNonNullInOptionsBeforeInstanceCreated_ActivePackageSourceReadFromOptions ()
- {
- CreatePackageSourcesHelper ();
- var packageSource = new PackageSource ("http://source-url", "Test");
- packageSourcesHelper.Options.PackageSources.Add (packageSource);
- packageSourcesHelper.Options.ActivePackageSource = packageSource;
- CreateRegisteredPackageRepositoriesWithExistingPackageSourcesHelper ();
-
- PackageSource actualPackageSource = registeredRepositories.ActivePackageSource;
-
- Assert.AreEqual (packageSource, actualPackageSource);
- }
-
- [Test]
- public void ActiveRepository_OneRegisteredSource_RepositoryCreatedFromRegisteredSource ()
- {
- CreateRegisteredPackageRepositories ();
- IPackageRepository activeRepository = registeredRepositories.ActiveRepository;
-
- string actualPackageSource = fakeRepositoryCache.FirstPackageSourcePassedToCreateRepository;
- PackageSource expectedPackageSource = packageSourcesHelper.PackageSource;
-
- Assert.AreEqual (expectedPackageSource.Source, actualPackageSource);
- }
-
- [Test]
- public void ActiveRepository_CalledTwice_RepositoryCreatedOnce ()
- {
- CreateRegisteredPackageRepositories ();
- IPackageRepository activeRepository = registeredRepositories.ActiveRepository;
- activeRepository = registeredRepositories.ActiveRepository;
-
- int count = fakeRepositoryCache.PackageSourcesPassedToCreateRepository.Count;
-
- Assert.AreEqual (1, count);
- }
-
- [Test]
- public void ActiveRepository_OneRegisteredSource_ReturnsPackageCreatedFromCache ()
- {
- CreateRegisteredPackageRepositories ();
- IPackageRepository activeRepository = registeredRepositories.ActiveRepository;
-
- IPackageRepository expectedRepository = fakeRepositoryCache.FakePackageRepository;
-
- Assert.AreEqual (expectedRepository, activeRepository);
- }
-
- [Test]
- public void ActivePackageRepository_ActivePackageSourceChangedToSecondRegisteredPackageSource_CreatesRepositoryUsingSecondPackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
-
- PackageSource expectedPackageSource = packageSourcesHelper.Options.PackageSources [1];
- registeredRepositories.ActivePackageSource = expectedPackageSource;
-
- IPackageRepository repository = registeredRepositories.ActiveRepository;
- string packageSource = fakeRepositoryCache.FirstPackageSourcePassedToCreateRepository;
-
- Assert.AreEqual (expectedPackageSource.Source, packageSource);
- }
-
- [Test]
- public void ActiveRepository_ActivePackageSourceChangedAfterActivePackageRepositoryCreated_CreatesNewRepositoryUsingActivePackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
-
- IPackageRepository initialRepository = registeredRepositories.ActiveRepository;
- fakeRepositoryCache.PackageSourcesPassedToCreateRepository.Clear ();
-
- PackageSource expectedPackageSource = packageSourcesHelper.Options.PackageSources [1];
- registeredRepositories.ActivePackageSource = expectedPackageSource;
-
- IPackageRepository repository = registeredRepositories.ActiveRepository;
- string packageSource = fakeRepositoryCache.FirstPackageSourcePassedToCreateRepository;
-
- Assert.AreEqual (expectedPackageSource.Source, packageSource);
- }
-
- [Test]
- public void ActiveRepository_ActivePackageSourceSetToSameValueAfterActivePackageRepositoryCreated_NewRepositoryNotCreated ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddOnePackageSource ();
-
- IPackageRepository initialRepository = registeredRepositories.ActiveRepository;
- fakeRepositoryCache.PackageSourcesPassedToCreateRepository.Clear ();
-
- PackageSource expectedPackageSource = packageSourcesHelper.Options.PackageSources [0];
- registeredRepositories.ActivePackageSource = expectedPackageSource;
-
- IPackageRepository repository = registeredRepositories.ActiveRepository;
-
- int count = fakeRepositoryCache.PackageSourcesPassedToCreateRepository.Count;
-
- Assert.AreEqual (0, count);
- }
-
- [Test]
- public void PackageSources_OnePackageSourceInOptions_ReturnsOnePackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddOnePackageSource ();
-
- RegisteredPackageSources packageSources = registeredRepositories.PackageSources;
- RegisteredPackageSources expectedPackageSources = packageSourcesHelper.Options.PackageSources;
-
- Assert.AreEqual (expectedPackageSources, packageSources);
- }
-
- [Test]
- public void ActivePackageRepository_ActivePackageSourceIsAggregate_ReturnsAggregatePackageRepository ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ();
-
- registeredRepositories.ActivePackageSource = RegisteredPackageSourceSettings.AggregatePackageSource;
-
- IPackageRepository repository = registeredRepositories.ActiveRepository;
- FakePackageRepository expectedRepository = fakeRepositoryCache.FakeAggregateRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void ActivePackageSource_AllPackageSourcesCleared_ReturnsNullAndDoesNotThrowArgumentOutOfRangeException ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.Options.ActivePackageSource = null;
- registeredRepositories.PackageSources.Clear ();
-
- PackageSource activePackageSource = registeredRepositories.ActivePackageSource;
-
- Assert.IsNull (activePackageSource);
- }
-
- [Test]
- public void UpdatePackageSources_SolutionLoadedAggregatePackageSourceIsActiveThenAllSourcesDisabledApartFromOne_ActivePackageSourceIsNotAggregatePackageSource ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ("One", "Two");
- var expectedPackageSource = new PackageSource ("Two") { IsEnabled = true };
- var updatedPackageSources = new PackageSource [] {
- new PackageSource ("One") { IsEnabled = false },
- expectedPackageSource
- };
- AddPackageSourcesToSettings ("One", "Two");
- SetActivePackageSourceInSettings (RegisteredPackageSourceSettings.AggregatePackageSource);
- packageSourcesHelper.Options.ProjectService.RaiseSolutionLoadedEvent ();
- registeredRepositories.ActivePackageSource = RegisteredPackageSourceSettings.AggregatePackageSource;
-
- registeredRepositories.UpdatePackageSources (updatedPackageSources);
-
- Assert.AreEqual (expectedPackageSource, registeredRepositories.ActivePackageSource);
- }
-
- [Test]
- public void UpdatePackageSources_PackageSourcesUpdatedInPreferencesWhenAggregatePackageSourceIsActive_ActiveRepositoryIsRecreated ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ("One", "Two");
- var updatedPackageSources = new PackageSource [] {
- new PackageSource ("One"),
- new PackageSource ("Two")
- };
- AddPackageSourcesToSettings ("One", "Two");
- SetActivePackageSourceInSettings (RegisteredPackageSourceSettings.AggregatePackageSource);
- registeredRepositories.ActivePackageSource = RegisteredPackageSourceSettings.AggregatePackageSource;
- IPackageRepository firstAggregateRepository = registeredRepositories.ActiveRepository;
- fakeRepositoryCache.FakeAggregateRepository = new FakePackageRepository ();
-
- registeredRepositories.UpdatePackageSources (updatedPackageSources);
- IPackageRepository secondAggregateRepository = registeredRepositories.ActiveRepository;
-
- Assert.AreNotSame (firstAggregateRepository, secondAggregateRepository);
- Assert.AreSame (secondAggregateRepository, fakeRepositoryCache.FakeAggregateRepository);
- }
-
- [Test]
- public void ActiveRepository_TwoPackageSourcesAndAllSourcesSelectedThenAllSourcesDisabled_NullExceptionIsNotThrown ()
- {
- CreateRegisteredPackageRepositories ();
- packageSourcesHelper.AddTwoPackageSources ("One", "Two");
- registeredRepositories.ActivePackageSource = RegisteredPackageSourceSettings.AggregatePackageSource;
- packageSourcesHelper.RegisteredPackageSources [0].IsEnabled = false;
- packageSourcesHelper.RegisteredPackageSources [1].IsEnabled = false;
- registeredRepositories.UpdatePackageSources (packageSourcesHelper.RegisteredPackageSources);
-
- IPackageRepository repository = null;
- Assert.DoesNotThrow (() => repository = registeredRepositories.ActiveRepository);
-
- //Assert.IsInstanceOf (
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageSourcesViewModelTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageSourcesViewModelTests.cs index c793eff96e..fc26959bb7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageSourcesViewModelTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RegisteredPackageSourcesViewModelTests.cs @@ -24,12 +24,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
+using NuGet.Configuration;
using NUnit.Framework;
namespace MonoDevelop.PackageManagement.Tests
@@ -39,35 +36,30 @@ namespace MonoDevelop.PackageManagement.Tests {
RegisteredPackageSourcesViewModel viewModel;
List<string> propertiesChanged;
- RegisteredPackageSources packageSources;
- RegisteredPackageRepositories registeredRepositories;
+ FakePackageSourceProvider packageSourceProvider;
+ List<PackageSource> packageSources;
void CreateViewModel ()
{
- var options = new TestablePackageManagementOptions ();
- packageSources = options.PackageSources;
- packageSources.Clear ();
-
- var cache = new PackageRepositoryCache (packageSources, new RecentPackageInfo [0]);
- registeredRepositories = new RegisteredPackageRepositories (cache, options);
-
- viewModel = new RegisteredPackageSourcesViewModel (registeredRepositories);
+ packageSourceProvider = new FakePackageSourceProvider ();
+ packageSources = packageSourceProvider.PackageSources;
+ viewModel = new RegisteredPackageSourcesViewModel (packageSourceProvider, new FolderBrowser ());
}
void CreateViewModelWithOnePackageSource ()
{
CreateViewModel ();
- AddPackageSourceToOptions ("Source 1", "http://url1");
+ AddPackageSourceToProvider ("Source 1", "http://url1");
}
void CreateViewModelWithTwoPackageSources ()
{
CreateViewModel ();
- AddPackageSourceToOptions ("Source 1", "http://url1");
- AddPackageSourceToOptions ("Source 2", "http://url2");
+ AddPackageSourceToProvider ("Source 1", "http://url1");
+ AddPackageSourceToProvider ("Source 2", "http://url2");
}
- void AddPackageSourceToOptions (string name, string url)
+ void AddPackageSourceToProvider (string name, string url)
{
var source = new PackageSource (url, name);
packageSources.Add (source);
@@ -127,12 +119,12 @@ namespace MonoDevelop.PackageManagement.Tests public void Load_PackageSourceModifiedAfterLoadAndSaveNotCalled_RegisteredPackageSourcesInOptionsUnchanged ()
{
CreateViewModel ();
- AddPackageSourceToOptions ("Test", "http://monodevelop.com");
+ AddPackageSourceToProvider ("Test", "http://monodevelop.com");
viewModel.Load ();
PackageSourceViewModel packageSourceViewModel = viewModel.PackageSourceViewModels [0];
packageSourceViewModel.Name = "Changed-Name";
- packageSourceViewModel.SourceUrl = "changed-url";
+ packageSourceViewModel.Source = "changed-url";
var expectedSources = new PackageSource[] {
new PackageSource ("http://monodevelop.com", "Test")
@@ -145,12 +137,12 @@ namespace MonoDevelop.PackageManagement.Tests public void Save_PackageSourceModifiedAfterLoad_RegisteredPackageSourcesInOptionsUpdated ()
{
CreateViewModel ();
- AddPackageSourceToOptions ("Test", "http://monodevelop.com");
+ AddPackageSourceToProvider ("Test", "http://monodevelop.com");
viewModel.Load ();
PackageSourceViewModel packageSourceViewModel = viewModel.PackageSourceViewModels [0];
packageSourceViewModel.Name = "Test-updated";
- packageSourceViewModel.SourceUrl = "url-updated";
+ packageSourceViewModel.Source = "url-updated";
viewModel.Save ();
@@ -165,7 +157,7 @@ namespace MonoDevelop.PackageManagement.Tests public void Save_OnePackageSourceAddedAfterLoadAndBeforeSave_TwoRegisteredPackageSourcesInOptions ()
{
CreateViewModel ();
- AddPackageSourceToOptions ("Test", "http://monodevelop.com/1");
+ AddPackageSourceToProvider ("Test", "http://monodevelop.com/1");
viewModel.Load ();
var newSource = new PackageSource ("http://monodevelop.com/2", "Test");
@@ -191,7 +183,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateViewModel ();
viewModel.Load ();
viewModel.NewPackageSourceName = "Test";
- viewModel.NewPackageSourceUrl = "http://monodevelop.com";
+ viewModel.NewPackageSourceUrl = "http://monodevelop.com";
viewModel.AddPackageSourceCommand.Execute (null);
@@ -208,7 +200,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateViewModel ();
viewModel.Load ();
viewModel.NewPackageSourceName = "Test";
- viewModel.NewPackageSourceUrl = null;
+ viewModel.NewPackageSourceUrl = null;
bool result = viewModel.AddPackageSourceCommand.CanExecute (null);
@@ -221,7 +213,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateViewModel ();
viewModel.Load ();
viewModel.NewPackageSourceName = "Test";
- viewModel.NewPackageSourceUrl = "http://codeplex.com";
+ viewModel.NewPackageSourceUrl = "http://codeplex.com";
bool result = viewModel.AddPackageSourceCommand.CanExecute (null);
@@ -234,7 +226,7 @@ namespace MonoDevelop.PackageManagement.Tests CreateViewModel ();
viewModel.Load ();
viewModel.NewPackageSourceName = null;
- viewModel.NewPackageSourceUrl = "http://codeplex.com";
+ viewModel.NewPackageSourceUrl = "http://codeplex.com";
bool result = viewModel.AddPackageSourceCommand.CanExecute (null);
@@ -246,7 +238,7 @@ namespace MonoDevelop.PackageManagement.Tests {
CreateViewModel ();
viewModel.Load ();
- viewModel.NewPackageSourceUrl = "http://url";
+ viewModel.NewPackageSourceUrl = "http://url";
viewModel.NewPackageSourceName = "abc";
viewModel.AddPackageSource ();
@@ -271,7 +263,7 @@ namespace MonoDevelop.PackageManagement.Tests {
CreateViewModel ();
viewModel.Load ();
- viewModel.NewPackageSourceUrl = "Test";
+ viewModel.NewPackageSourceUrl = "Test";
Assert.AreEqual ("Test", viewModel.NewPackageSourceUrl);
}
@@ -524,6 +516,42 @@ namespace MonoDevelop.PackageManagement.Tests Assert.IsTrue (propertyNames.Contains ("SelectedPackageSourceViewModel"));
}
+
+ [Test]
+ public void AddPackageSource_NewPackageSourceHasEmptyStringPassword_DoesNotThrowCryptographicExceptionAndNewPackageSourceAddedWithNullPassword ()
+ {
+ CreateViewModel ();
+ viewModel.Load ();
+ viewModel.NewPackageSourceUrl = "http://url";
+ viewModel.NewPackageSourceName = "abc";
+ viewModel.NewPackageSourcePassword = "";
+
+ Assert.DoesNotThrow (() => viewModel.AddPackageSource ());
+
+ PackageSourceViewModel expectedViewModel = viewModel.PackageSourceViewModels [0];
+
+ Assert.IsNull (expectedViewModel.Password);
+ Assert.AreEqual ("abc", expectedViewModel.Name);
+ Assert.AreEqual ("http://url", expectedViewModel.Source);
+ }
+
+ [Test]
+ public void AddPackageSource_NewPackageSourceHasPassword_DoesNotThrowCryptographicExceptionAndNewPackageSourceAddedWithPassword ()
+ {
+ CreateViewModel ();
+ viewModel.Load ();
+ viewModel.NewPackageSourceUrl = "http://url";
+ viewModel.NewPackageSourceName = "abc";
+ viewModel.NewPackageSourcePassword = "test";
+
+ Assert.DoesNotThrow (() => viewModel.AddPackageSource ());
+
+ PackageSourceViewModel expectedViewModel = viewModel.PackageSourceViewModels [0];
+
+ Assert.AreEqual ("test", expectedViewModel.Password);
+ Assert.AreEqual ("abc", expectedViewModel.Name);
+ Assert.AreEqual ("http://url", expectedViewModel.Source);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallNuGetPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallNuGetPackageActionTests.cs new file mode 100644 index 0000000000..28747468d5 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallNuGetPackageActionTests.cs @@ -0,0 +1,201 @@ +// +// ReinstallNuGetPackageActionTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using System.Linq; +using MonoDevelop.PackageManagement.Tests.Helpers; +using MonoDevelop.Projects; +using NuGet.Configuration; +using NuGet.PackageManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class ReinstallNuGetPackageActionTests + { + TestableReinstallNuGetPackageAction action; + FakeSolutionManager solutionManager; + FakeDotNetProject project; + FakeNuGetProject nugetProject; + List<SourceRepository> primaryRepositories; + IPackageManagementEvents packageManagementEvents; + FakeFileRemover fileRemover; + FakeNuGetPackageManager uninstallPackageManager; + FakeNuGetPackageManager installPackageManager; + + void CreateAction ( + string packageId = "Test", + string version = "2.1") + { + project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj"); + solutionManager = new FakeSolutionManager (); + nugetProject = new FakeNuGetProject (project); + solutionManager.NuGetProjects[project] = nugetProject; + + var repositoryProvider = solutionManager.SourceRepositoryProvider; + var source = new PackageSource ("http://test.com"); + repositoryProvider.AddRepository (source); + primaryRepositories = repositoryProvider.Repositories; + + action = new TestableReinstallNuGetPackageAction ( + project, + solutionManager); + + packageManagementEvents = action.PackageManagementEvents; + fileRemover = action.FileRemover; + + action.PackageId = packageId; + action.Version = new NuGetVersion (version); + + uninstallPackageManager = action.UninstallAction.PackageManager; + installPackageManager = action.InstallAction.PackageManager; + } + + void AddInstallPackageIntoProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Install); + action.InstallAction.PackageManager.InstallActions.Add (projectAction); + } + + void AddUninstallPackageIntoProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Uninstall); + action.UninstallAction.PackageManager.UninstallActions.Add (projectAction); + } + + [Test] + public void Execute_PackageExists_PackageIsForcefullyUninstalled () + { + CreateAction ("MyPackage", "1.2.3.4"); + AddUninstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + + action.Execute (); + + var executedAction = uninstallPackageManager.ExecutedActions.Single (); + Assert.AreEqual ("MyPackage", executedAction.PackageIdentity.Id); + Assert.AreEqual ("1.2.3.4", executedAction.PackageIdentity.Version.ToString ()); + Assert.AreEqual ("MyPackage", action.UninstallAction.PackageId); + Assert.IsTrue (action.UninstallAction.ForceRemove); + } + + [Test] + public void Execute_PackageExists_PackageIsInstalled () + { + CreateAction ("MyPackage", "1.2.3.4"); + AddInstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + + action.Execute (); + + var executedAction = installPackageManager.ExecutedActions.Single (); + Assert.AreEqual ("MyPackage", executedAction.PackageIdentity.Id); + Assert.AreEqual ("1.2.3.4", executedAction.PackageIdentity.Version.ToString ()); + Assert.AreEqual ("MyPackage", action.InstallAction.PackageId); + Assert.AreEqual ("1.2.3.4", action.InstallAction.Version.ToString ()); + Assert.IsFalse (action.InstallAction.LicensesMustBeAccepted); + Assert.IsFalse (action.InstallAction.PreserveLocalCopyReferences); + Assert.AreEqual (primaryRepositories, installPackageManager.PreviewInstallPrimarySources); + } + + [Test] + public void Execute_ReferenceHasLocalCopyFalseWhenUninstalled_ReferenceHasLocalCopyFalseAfterBeingReinstalled () + { + CreateAction ("MyPackage", "1.2.3.4"); + AddUninstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + AddInstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + uninstallPackageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + }; + bool installActionMaintainsLocalCopyReferences = false; + installPackageManager.BeforeExecuteAction = () => { + installActionMaintainsLocalCopyReferences = action.InstallAction.PreserveLocalCopyReferences; + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); + Assert.IsFalse (installActionMaintainsLocalCopyReferences, "Should be false since the reinstall action will maintain the local copies"); + } + + [Test] + public void Execute_PackagesConfigFileDeletedDuringUninstall_FileServicePackagesConfigFileDeletionIsCancelled () + { + CreateAction ("MyPackage", "1.2.3.4"); + AddUninstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath (); + bool? fileRemovedResult = null; + uninstallPackageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName); + }; + + action.Execute (); + + Assert.AreEqual (expectedFileName, fileRemover.FileRemoved); + Assert.IsFalse (fileRemovedResult.Value); + } + + [Test] + public void Execute_ScriptFileDeletedDuringUninstall_FileDeletionIsNotCancelled () + { + CreateAction ("MyPackage", "1.2.3.4"); + AddUninstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath (); + bool? fileRemovedResult = null; + uninstallPackageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName); + }; + + action.Execute (); + + Assert.IsTrue (fileRemovedResult.Value); + Assert.IsNull (fileRemover.FileRemoved); + } + + [Test] + public void Execute_PackageExists_PackageIsInstalledWithoutReOpeningReadmeFile () + { + CreateAction ("MyPackage", "1.2.3.4"); + AddInstallPackageIntoProjectAction ("MyPackage", "1.2.3.4"); + + action.Execute (); + + var executedAction = installPackageManager.ExecutedActions.Single (); + Assert.AreEqual ("MyPackage", executedAction.PackageIdentity.Id); + Assert.AreEqual ("MyPackage", action.InstallAction.PackageId); + Assert.IsFalse (action.InstallAction.OpenReadmeFile); + } + } +} + 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 deleted file mode 100644 index 06943b7899..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallPackageActionTests.cs +++ /dev/null @@ -1,185 +0,0 @@ -//
-// ReinstallPackageActionTests.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 MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using MonoDevelop.Projects;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class ReinstallPackageActionTests
- {
- ReinstallPackageAction action;
- PackageManagementEvents packageManagementEvents;
- FakePackageManagementProject project;
- FakeFileRemover fileRemover;
-
- void CreateAction (string packageId = "MyPackage", string packageVersion = "1.2.3.4")
- {
- project = new FakePackageManagementProject ();
- project.AddFakeInstallOperation ();
-
- packageManagementEvents = new PackageManagementEvents ();
-
- fileRemover = new FakeFileRemover ();
-
- action = new ReinstallPackageAction (project, packageManagementEvents, fileRemover);
- action.PackageId = packageId;
- action.PackageVersion = new SemanticVersion (packageVersion);
- }
-
- FakePackage AddPackageToSourceRepository (string packageId, string packageVersion)
- {
- return project.FakeSourceRepository.AddFakePackageWithVersion (packageId, packageVersion);
- }
-
- [Test]
- public void Execute_PackageExistsInSourceRepository_PackageIsUninstalled ()
- {
- CreateAction ("MyPackage", "1.2.3.4");
- FakePackage package = AddPackageToSourceRepository ("MyPackage", "1.2.3.4");
-
- action.Execute ();
-
- Assert.IsTrue (project.FakeUninstallPackageAction.IsExecuted);
- Assert.AreEqual (package, project.FakeUninstallPackageAction.Package);
- }
-
- [Test]
- public void Execute_PackageExistsInSourceRepository_PackageIsInstalled ()
- {
- CreateAction ("MyPackage", "1.2.3.4");
- FakePackage package = AddPackageToSourceRepository ("MyPackage", "1.2.3.4");
-
- action.Execute ();
-
- Assert.IsTrue (project.LastInstallPackageCreated.IsExecuteCalled);
- Assert.AreEqual (package, project.LastInstallPackageCreated.Package);
- }
-
- [Test]
- public void Execute_PackageExistsInSourceRepository_PackageIsForcefullyRemovedSoItDoesNotFailIfOtherPackagesDependOnIt ()
- {
- CreateAction ("MyPackage", "1.2.3.4");
- AddPackageToSourceRepository ("MyPackage", "1.2.3.4");
-
- action.Execute ();
-
- Assert.IsTrue (project.FakeUninstallPackageAction.ForceRemove);
- }
-
- [Test]
- public void Execute_ReferenceHasLocalCopyFalseWhenUninstalled_ReferenceHasLocalCopyFalseAfterBeingReinstalled ()
- {
- CreateAction ("MyPackage", "1.2.3.4");
- FakePackage package = AddPackageToSourceRepository ("MyPackage", "1.2.3.4");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- project.FakeUninstallPackageAction.ExecuteAction = () => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- referenceBeingRemoved.LocalCopy = false;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- };
- bool installActionMaintainsLocalCopyReferences = false;
- project.InstallPackageExecuteAction = () => {
- installActionMaintainsLocalCopyReferences = project.LastInstallPackageCreated.PreserveLocalCopyReferences;
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsFalse (secondReferenceBeingAdded.LocalCopy);
- Assert.IsFalse (installActionMaintainsLocalCopyReferences, "Should be false since the reinstall action will maintain the local copies");
- }
-
- [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);
- }
-
- [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);
- }
-
- [Test]
- public void Execute_PackageExistsInSourceRepository_PackageIsInstalledWithoutLicenseAgreementDialogShowns ()
- {
- CreateAction ("MyPackage", "1.2.3.4");
- AddPackageToSourceRepository ("MyPackage", "1.2.3.4");
-
- action.Execute ();
-
- Assert.IsTrue (project.LastInstallPackageCreated.IsExecuteCalled);
- Assert.IsFalse (project.LastInstallPackageCreated.LicensesMustBeAccepted);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallProjectPackagesActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallProjectPackagesActionTests.cs deleted file mode 100644 index 9fc767cacf..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ReinstallProjectPackagesActionTests.cs +++ /dev/null @@ -1,181 +0,0 @@ -//
-// ReinstallProjectPackagesActionTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class ReinstallProjectPackagesActionTests
- {
- ReinstallProjectPackagesAction action;
- FakePackageManagementProject project;
- PackageManagementEvents packageManagementEvents;
-
- void CreateAction ()
- {
- project = new FakePackageManagementProject ();
- packageManagementEvents = new PackageManagementEvents ();
- action = new ReinstallProjectPackagesAction (project, packageManagementEvents);
- }
-
- FakePackage AddPackageToProject (string packageId, string version = "1.0")
- {
- FakePackage package = FakePackage.CreatePackageWithVersion (packageId, version);
- project.FakePackages.Add (package);
- return package;
- }
-
- FakePackage AddPackageToProjectAndSourceRepository (string packageId, string version = "1.0")
- {
- FakePackage package = AddPackageToProject (packageId, version);
- project.FakeSourceRepository.FakePackages.Add (package);
- AddReinstallOperationsToProject (project.FakeSourceRepository.FakePackages);
- return package;
- }
-
- FakePackage AddPackageToSourceRepository (string packageId, string version = "1.0")
- {
- FakePackage package = FakePackage.CreatePackageWithVersion (packageId, version);
- project.FakeSourceRepository.FakePackages.Add (package);
- return package;
- }
-
- ReinstallPackageOperations AddReinstallOperationsToProject (IEnumerable<IPackage> packages)
- {
- List<PackageOperation> operations = packages
- .Select (p => new PackageOperation (p, PackageAction.Install))
- .ToList ();
-
- var reinstallOperations = new ReinstallPackageOperations (operations, packages);
- project.ReinstallOperations = reinstallOperations;
- return reinstallOperations;
- }
-
- [Test]
- public void Packages_OneProjectPackage_ReturnsOneProjectPackage ()
- {
- CreateAction ();
- FakePackage package = AddPackageToProject ("MyPackage");
- var expectedPackages = new FakePackage[] { package };
-
- List<IPackage> packages = action.Packages.ToList ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void Execute_ProjectPackageNotAvailableFromSourceRepository_ExceptionThrownForMissingPackage ()
- {
- CreateAction ();
- AddPackageToProject ("MyPackage");
-
- Exception ex = Assert.Throws <ApplicationException> (() => {
- action.Execute ();
- });
- Assert.That (ex.Message, Contains.Substring ("MyPackage"));
- }
-
- [Test]
- public void Execute_OneProjectPackage_PackageIsUninstalled ()
- {
- CreateAction ();
- FakePackage package = AddPackageToProjectAndSourceRepository ("MyPackage");
-
- action.Execute ();
-
- Assert.AreEqual (package, project.PackagePassedToUninstallPackage);
- Assert.IsTrue (project.ForceRemovePassedToUninstallPackage);
- Assert.IsFalse (project.RemoveDependenciesPassedToUninstallPackage);
- }
-
- [Test]
- public void Execute_OneProjectPackage_ReinstallPackageOperationsAreCreatedBasedOnPackagesFromSourceRepository ()
- {
- CreateAction ();
- AddPackageToProject ("MyPackage", "1.0");
- FakePackage sourceRepositoryPackage = AddPackageToSourceRepository ("MyPackage", "1.0");
- var expectedPackages = new FakePackage[] { sourceRepositoryPackage };
- AddReinstallOperationsToProject (expectedPackages);
-
- action.Execute ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, project.PackagesPassedToGetReinstallPackageOperations);
- }
-
- [Test]
- public void Execute_OneProjectPackage_ReinstallPackageOperationsAreRun ()
- {
- CreateAction ();
- AddPackageToProject ("MyPackage", "1.0");
- FakePackage sourceRepositoryPackage = AddPackageToSourceRepository ("MyPackage", "1.0");
- var expectedPackages = new FakePackage[] { sourceRepositoryPackage };
- ReinstallPackageOperations operations = AddReinstallOperationsToProject (expectedPackages);
-
- action.Execute ();
-
- Assert.AreEqual (operations.Operations, project.PackageOperationsRun);
- }
-
- [Test]
- public void Execute_OneProjectPackage_PackageReferencesAddedForPackagesReturnedWithReinstallOperations ()
- {
- CreateAction ();
- AddPackageToProject ("MyPackage", "1.0");
- AddPackageToSourceRepository ("MyPackage", "1.0");
- var expectedPackages = new FakePackage[] { FakePackage.CreatePackageWithVersion ("MyPackage", "1.0") };
- AddReinstallOperationsToProject (expectedPackages);
-
- action.Execute ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, project.PackageReferencesAdded);
- }
-
- [Test]
- public void Execute_OneProjectPackage_PackageRetargetingMessageIsLogged ()
- {
- CreateAction ();
- AddPackageToProjectAndSourceRepository ("MyPackage");
- string expectedMessage = GettextCatalog.GetString ("Retargeting packages...{0}", Environment.NewLine);
- var messages = new List<string> ();
- packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
- messages.Add (e.Message.ToString ());
- };
-
- action.Execute ();
-
- Assert.AreEqual (expectedMessage, messages.FirstOrDefault ());
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RestorePackagesActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RestorePackagesActionTests.cs deleted file mode 100644 index 78dd92bf9f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/RestorePackagesActionTests.cs +++ /dev/null @@ -1,365 +0,0 @@ -//
-// RestorePackagesAction.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NUnit.Framework;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class RestorePackagesActionTests
- {
- RestorePackagesAction action;
- FakePackageManagementSolution solution;
- FakePackageManagerFactory packageManagerFactory;
- FakePackageRepositoryFactory packageRepositoryCache;
- PackageManagementEvents packageEvents;
- List<PackageOperationMessage> messagesLogged;
- List<PackageRestoredEventArgs> packageRestoredEvents;
-
- void CreateSolution ()
- {
- packageManagerFactory = new FakePackageManagerFactory ();
- packageRepositoryCache = new FakePackageRepositoryFactory ();
- packageEvents = new PackageManagementEvents ();
- solution = new FakePackageManagementSolution ();
- }
-
- FakePackageManagementProject CreateSolutionWithOneProject ()
- {
- CreateSolution ();
- return solution.AddFakeProject ("MyProject");
- }
-
- void CreateAction ()
- {
- action = new RestorePackagesAction (
- solution,
- packageEvents,
- packageRepositoryCache,
- packageManagerFactory);
- }
-
- FakePackage AddPackageToPriorityRepository (string packageId, string packageVersion)
- {
- return packageRepositoryCache
- .FakePriorityPackageRepository
- .AddFakePackageWithVersion (packageId, packageVersion);
- }
-
- void CaptureMessagesLogged ()
- {
- messagesLogged = new List<PackageOperationMessage> ();
- packageEvents.PackageOperationMessageLogged += (sender, e) => {
- messagesLogged.Add (e.Message);
- };
- }
-
- FakeOperationAwarePackageRepository MakePriorityRepositoryOperationAware ()
- {
- var repository = new FakeOperationAwarePackageRepository ();
- packageRepositoryCache.FakePriorityPackageRepository = repository;
- return repository;
- }
-
- void PackageIsRestored (FakePackage package)
- {
- solution.SolutionPackageRepository.FakePackages.Add (package);
- }
-
- void AssertMessageLogged (string expectedMessage)
- {
- List<string> allMessages = messagesLogged.Select (message => message.ToString ()).ToList ();
- Assert.That (allMessages, Contains.Item (expectedMessage));
- }
-
- void AssertMessageIsNotLogged (string expectedMessage)
- {
- List<string> allMessages = messagesLogged.Select (message => message.ToString ()).ToList ();
- Assert.That (allMessages, Has.No.Contains (expectedMessage));
- }
-
- void AssertNoMessageLoggedThatContains (string expectedMessage)
- {
- List<string> allMessages = messagesLogged.Select (message => message.ToString ()).ToList ();
- Assert.That (allMessages, Has.No.ContainsSubstring (expectedMessage));
- }
-
- void CapturePackageRestoredEvents ()
- {
- packageRestoredEvents = new List<PackageRestoredEventArgs> ();
- packageEvents.PackageRestored += (sender, e) => {
- packageRestoredEvents.Add (e);
- };
- }
-
- [Test]
- public void Execute_ProjectHasOneUnrestoredPackage_PackageFromPriorityRepositoryIsInstalled ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
-
- action.Execute ();
-
- Assert.AreEqual (package, packageManagerFactory.FakePackageManager.PackagePassedToInstallPackage);
- Assert.IsTrue (packageManagerFactory.FakePackageManager.IgnoreWalkInfoPassedToInstallPackage);
- Assert.IsTrue (packageManagerFactory.FakePackageManager.IgnoreDependenciesPassedToInstallPackage);
- Assert.IsTrue (packageManagerFactory.FakePackageManager.AllowPrereleaseVersionsPassedToInstallPackage);
- Assert.AreEqual (packageRepositoryCache.FakePriorityPackageRepository, packageManagerFactory.PackageRepositoryPassedToCreatePackageManager);
- Assert.AreEqual (solution.SolutionPackageRepository, packageManagerFactory.SolutionPackageRepositoryPassedToCreatePackageManager);
- }
-
- [Test]
- public void Execute_ProjectHasOneUnrestoredPackage_PackageManagerHasLoggerConfigured ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
-
- action.Execute ();
-
- Assert.IsInstanceOf<PackageManagementLogger> (packageManagerFactory.FakePackageManager.Logger);
- }
-
- [Test]
- public void Execute_ProjectHasOneUnrestoredPackage_RestoringPackagesMessageLogged ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
- CaptureMessagesLogged ();
-
- action.Execute ();
-
- Assert.AreEqual ("Restoring packages...", messagesLogged [0].ToString ());
- }
-
- [Test]
- public void Execute_ProjectHasOneUnrestoredPackage_RestoreOperationAddedToHttpHeader ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakeOperationAwarePackageRepository repository = MakePriorityRepositoryOperationAware ();
- AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
-
- action.Execute ();
-
- repository.AssertOperationWasStartedAndDisposed (
- RepositoryOperationNames.Restore,
- "MyPackage",
- "1.0");
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageWhichIsRestored_PackageIsNotInstalledAgain ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.0");
- PackageIsRestored (package);
- CreateAction ();
-
- action.Execute ();
-
- Assert.IsFalse (packageManagerFactory.FakePackageManager.IsPackageInstalled);
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageWhichIsRestored_AllPackagesAlreadyRestoredMessageIsLogged ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.2.3.4");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.2.3.4");
- PackageIsRestored (package);
- CreateAction ();
- CaptureMessagesLogged ();
-
- action.Execute ();
-
- AssertMessageLogged ("All packages are already restored.");
- AssertMessageLogged ("Skipping 'MyPackage 1.2.3.4' because it is already restored.");
- }
-
- [Test]
- public void Execute_ProjectHasOnePackageWhichIsNotRestored_AllPackagesAreAlreadyRestoredMessageIsNotLogged ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
- CaptureMessagesLogged ();
-
- action.Execute ();
-
- AssertMessageIsNotLogged ("All packages are already restored.");
- AssertMessageLogged ("1 package restored successfully.");
- }
-
- [Test]
- public void Execute_ProjectHasTwoMissingPackages_PackagesRestoredSuccessfullyMessageIsLogged ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- project.AddPackageReference ("MyOtherPackage", "1.2");
- AddPackageToPriorityRepository ("MyPackage", "1.0");
- AddPackageToPriorityRepository ("MyOtherPackage", "1.2");
- CreateAction ();
- CaptureMessagesLogged ();
-
- action.Execute ();
-
- AssertMessageIsNotLogged ("All packages are already restored.");
- AssertMessageLogged ("2 packages restored successfully.");
- }
-
- [Test]
- public void Execute_TwoProjectsEachWithSameMissingPackage_PackageIsRestoredOnce ()
- {
- CreateSolution ();
- FakePackageManagementProject project1 = solution.AddFakeProject ("MyProject1");
- FakePackageManagementProject project2 = solution.AddFakeProject ("MyProject2");
- project1.AddPackageReference ("MyPackage", "1.2.3.4");
- project2.AddPackageReference ("MyPackage", "1.2.3.4");
- AddPackageToPriorityRepository ("MyPackage", "1.2.3.4");
- CreateAction ();
- CaptureMessagesLogged ();
-
- action.Execute ();
-
- Assert.AreEqual (1, packageManagerFactory.FakePackageManager.PackagesInstalled.Count);
- Assert.AreEqual ("MyPackage", packageManagerFactory.FakePackageManager.PackagePassedToInstallPackage.Id);
- Assert.AreEqual ("1.2.3.4", packageManagerFactory.FakePackageManager.PackagePassedToInstallPackage.Version.ToString ());
- AssertMessageLogged ("1 package restored successfully.");
- }
-
- [Test]
- public void Execute_ProjectHasOneUnrestoredSolutionLevelPackage_PackageIsInstalled ()
- {
- CreateSolutionWithOneProject ();
- solution.AddPackageReference ("MyPackage", "1.0");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
-
- action.Execute ();
-
- Assert.AreEqual (package, packageManagerFactory.FakePackageManager.PackagePassedToInstallPackage);
- Assert.IsTrue (packageManagerFactory.FakePackageManager.IgnoreWalkInfoPassedToInstallPackage);
- Assert.IsTrue (packageManagerFactory.FakePackageManager.IgnoreDependenciesPassedToInstallPackage);
- Assert.IsTrue (packageManagerFactory.FakePackageManager.AllowPrereleaseVersionsPassedToInstallPackage);
- }
-
- [Test]
- public void Execute_SolutionHasTwoProjectsWithMissingPackagesButOneProjectAddedToActionForRestore_OnlyOneProjectIsRestored ()
- {
- CreateSolution ();
- FakePackageManagementProject project1 = solution.AddFakeProject ("MyProject1");
- FakePackageManagementProject project2 = solution.AddFakeProject ("MyProject2");
- project1.AddPackageReference ("MyPackage1", "1.2.3.4");
- project2.AddPackageReference ("MyPackage2", "1.2.3.4");
- AddPackageToPriorityRepository ("MyPackage1", "1.2.3.4");
- AddPackageToPriorityRepository ("MyPackage2", "1.2.3.4");
- CreateAction ();
- var dotNetProject = new FakeDotNetProject ();
- dotNetProject.Name = "MyProject1";
- solution.FakeProjectsToReturnFromGetProject.Add ("MyProject1", project1);
- action.Project = dotNetProject;
-
- action.Execute ();
-
- Assert.AreEqual (1, packageManagerFactory.FakePackageManager.PackagesInstalled.Count);
- Assert.AreEqual ("MyPackage1", packageManagerFactory.FakePackageManager.PackagePassedToInstallPackage.Id);
- }
-
- [Test]
- public void Execute_OneUnrestoredSolutionLevelPackageButOneProjectAddedToActionForRestore_SolutionLevelPackageIsNotRestored ()
- {
- CreateSolutionWithOneProject ();
- solution.AddPackageReference ("MyPackage", "1.0");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.0");
- FakePackageManagementProject project1 = solution.AddFakeProject ("MyProject1");
- FakePackageManagementProject project2 = solution.AddFakeProject ("MyProject2");
- project1.AddPackageReference ("MyPackage1", "1.2.3.4");
- project2.AddPackageReference ("MyPackage2", "1.2.3.4");
- AddPackageToPriorityRepository ("MyPackage1", "1.2.3.4");
- AddPackageToPriorityRepository ("MyPackage2", "1.2.3.4");
- CreateAction ();
- var dotNetProject = new FakeDotNetProject ();
- dotNetProject.Name = "MyProject1";
- solution.FakeProjectsToReturnFromGetProject.Add ("MyProject1", project1);
- action.Project = dotNetProject;
-
- action.Execute ();
-
- Assert.AreEqual (1, packageManagerFactory.FakePackageManager.PackagesInstalled.Count);
- Assert.AreEqual ("MyPackage1", packageManagerFactory.FakePackageManager.PackagePassedToInstallPackage.Id);
- }
-
- [Test]
- public void Execute_ProjectHasOneUnrestoredPackage_PackageRestoredEventFiredForPackage ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
- CapturePackageRestoredEvents ();
- var dotNetProject = new FakeDotNetProject ();
- dotNetProject.Name = "MyProject";
- solution.FakeProjectsToReturnFromGetProject.Add ("MyProject", project);
- action.Project = dotNetProject;
-
- action.Execute ();
-
- PackageRestoredEventArgs eventArgs = packageRestoredEvents [0];
- Assert.AreEqual (package, eventArgs.Package);
- }
-
- [Test]
- public void Execute_SolutionHasOneProjectWithOneUnrestoredPackage_PackageRestoredEventFiredForPackage ()
- {
- FakePackageManagementProject project = CreateSolutionWithOneProject ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage package = AddPackageToPriorityRepository ("MyPackage", "1.0");
- CreateAction ();
- CapturePackageRestoredEvents ();
-
- action.Execute ();
-
- PackageRestoredEventArgs eventArgs = packageRestoredEvents [0];
- Assert.AreEqual (package, eventArgs.Package);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SettingProviderTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SettingProviderTests.cs index 07c464a8f8..954353394f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SettingProviderTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SettingProviderTests.cs @@ -70,7 +70,9 @@ namespace MonoDevelop.PackageManagement.Tests public void TearDown ()
{
// This resets SettingsProvider.LoadDefaultSettings.
- TestablePackageManagementOptions.CreateSettingsProvider (fakeSettings, projectService);
+ SettingsProvider.LoadDefaultSettings = (fileSystem, configFile, machineSettings) => {
+ return fakeSettings;
+ };
}
[Test]
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryPathTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryPathTests.cs index 058761fc55..b70cb49b83 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryPathTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryPathTests.cs @@ -37,18 +37,18 @@ namespace MonoDevelop.PackageManagement.Tests {
SolutionPackageRepositoryPath repositoryPath;
FakeProject project;
- TestablePackageManagementOptions options;
FakeSolution solution;
+ FakeSettingsProvider settingsProvider;
FakeSettings settings;
void CreateSolutionPackageRepositoryPath ()
{
- repositoryPath = new SolutionPackageRepositoryPath (project, options);
+ repositoryPath = new SolutionPackageRepositoryPath (project, settingsProvider);
}
void CreateSolutionPackageRepositoryPath (ISolution solution)
{
- repositoryPath = new SolutionPackageRepositoryPath (solution, options);
+ repositoryPath = new SolutionPackageRepositoryPath (solution, settingsProvider);
}
void CreateTestProject ()
@@ -61,10 +61,10 @@ namespace MonoDevelop.PackageManagement.Tests solution = new FakeSolution (fileName);
}
- void CreateOptions ()
+ void CreateSettings ()
{
- options = new TestablePackageManagementOptions ();
- settings = options.FakeSettings;
+ settingsProvider = new FakeSettingsProvider ();
+ settings = settingsProvider.FakeSettings;
}
void SolutionNuGetConfigFileHasCustomPackagesPath (string fullPath)
@@ -75,16 +75,15 @@ namespace MonoDevelop.PackageManagement.Tests [Test]
public void PackageRepositoryPath_ProjectAndSolutionHaveDifferentFolders_IsConfiguredPackagesFolderInsideSolutionFolder ()
{
- CreateOptions ();
+ CreateSettings ();
CreateTestProject ();
CreateSolution (@"d:\projects\MyProject\MySolution.sln");
solution.BaseDirectory = @"d:\projects\MyProject\".ToNativePath ();
project.ParentSolution = solution;
- options.PackagesDirectory = "MyPackages";
CreateSolutionPackageRepositoryPath ();
string path = repositoryPath.PackageRepositoryPath;
- string expectedPath = @"d:\projects\MyProject\MyPackages".ToNativePath ();
+ string expectedPath = @"d:\projects\MyProject\packages".ToNativePath ();
Assert.AreEqual (expectedPath, path);
}
@@ -92,41 +91,21 @@ namespace MonoDevelop.PackageManagement.Tests [Test]
public void PackageRepositoryPath_PassSolutionToConstructor_IsConfiguredPackagesFolderInsideSolutionFolder ()
{
- CreateOptions ();
+ CreateSettings ();
CreateSolution (@"d:\projects\MySolution\MySolution.sln");
- options.PackagesDirectory = "Packages";
CreateSolutionPackageRepositoryPath (solution);
string path = repositoryPath.PackageRepositoryPath;
- string expectedPath = @"d:\projects\MySolution\Packages".ToNativePath ();
+ string expectedPath = @"d:\projects\MySolution\packages".ToNativePath ();
Assert.AreEqual (expectedPath, path);
}
[Test]
- public void GetInstallPath_GetInstallPathForPackage_ReturnsPackagePathInsideSolutionPackagesRepository ()
- {
- CreateOptions ();
- CreateSolution (@"d:\projects\Test\MySolution\MyProject.sln");
- options.PackagesDirectory = "MyPackages";
- CreateSolutionPackageRepositoryPath (solution);
-
- var package = FakePackage.CreatePackageWithVersion ("MyPackage", "1.2.1.40");
-
- string installPath = repositoryPath.GetInstallPath (package);
-
- string expectedInstallPath =
- @"d:\projects\Test\MySolution\MyPackages\MyPackage.1.2.1.40".ToNativePath ();
-
- Assert.AreEqual (expectedInstallPath, installPath);
- }
-
- [Test]
public void PackageRepositoryPath_SolutionHasNuGetFileThatOverridesDefaultPackagesRepositoryPath_OverriddenPathReturned ()
{
- CreateOptions ();
+ CreateSettings ();
CreateSolution (@"d:\projects\MySolution\MySolution.sln");
- options.PackagesDirectory = "Packages";
SolutionNuGetConfigFileHasCustomPackagesPath (@"d:\Team\MyPackages");
CreateSolutionPackageRepositoryPath (solution);
string expectedPath = @"d:\Team\MyPackages".ToNativePath ();
@@ -139,9 +118,8 @@ namespace MonoDevelop.PackageManagement.Tests [Test]
public void PackageRepositoryPath_SolutionHasNuGetFileThatOverridesDefaultPackagesRepositoryPathAndPathContainsDotDots_OverriddenPathReturnedWithoutDotDots ()
{
- CreateOptions ();
+ CreateSettings ();
CreateSolution (@"d:\projects\MySolution\MySolution.sln");
- options.PackagesDirectory = "Packages";
SolutionNuGetConfigFileHasCustomPackagesPath (@"d:\projects\MySolution\..\..\Team\MyPackages");
CreateSolutionPackageRepositoryPath (solution);
string expectedPath = @"d:\Team\MyPackages".ToNativePath ();
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryTests.cs index 0952b5ca56..4a922b11fd 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryTests.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/SolutionPackageRepositoryTests.cs @@ -24,11 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Collections.Generic;
using System.Linq;
-
-using MonoDevelop.PackageManagement;
using NuGet;
using NUnit.Framework;
using MonoDevelop.PackageManagement.Tests.Helpers;
@@ -39,10 +35,9 @@ namespace MonoDevelop.PackageManagement.Tests public class SolutionPackageRepositoryTests
{
TestableSolutionPackageRepository repository;
- TestablePackageManagementOptions options;
+ FakeSettingsProvider settingsProvider;
FakeSolution solution;
FakePackageRepositoryFactory fakeRepositoryFactory;
- FakeSharedPackageRepository fakeSharedRepository;
void CreateSolution (string fileName)
{
@@ -52,24 +47,23 @@ namespace MonoDevelop.PackageManagement.Tests void CreateFakeRepositoryFactory ()
{
fakeRepositoryFactory = new FakePackageRepositoryFactory ();
- fakeSharedRepository = fakeRepositoryFactory.FakeSharedRepository;
}
- void CreateOptions ()
+ void CreateSettings ()
{
- options = new TestablePackageManagementOptions ();
+ settingsProvider = new FakeSettingsProvider ();
}
- void CreateRepository (ISolution solution, TestablePackageManagementOptions options)
+ void CreateRepository (ISolution solution, FakeSettingsProvider settings)
{
CreateFakeRepositoryFactory ();
- repository = new TestableSolutionPackageRepository (solution, fakeRepositoryFactory, options);
+ repository = new TestableSolutionPackageRepository (solution, fakeRepositoryFactory, settings);
}
void CreateRepository (ISolution solution)
{
- CreateOptions ();
- CreateRepository (solution, options);
+ CreateSettings ();
+ CreateRepository (solution, settingsProvider);
}
void CreateRepository ()
@@ -115,54 +109,6 @@ namespace MonoDevelop.PackageManagement.Tests }
[Test]
- public void GetInstallPath_GetInstallPathForPackage_ReturnsPackagePathInsideSolutionPackagesRepository ()
- {
- CreateSolution (@"d:\projects\Test\MySolution\MyProject.sln");
- CreateOptions ();
- options.PackagesDirectory = "MyPackages";
- CreateRepository (solution, options);
-
- var package = FakePackage.CreatePackageWithVersion ("MyPackage", "1.0.1.40");
-
- string installPath = repository.GetInstallPath (package);
-
- string expectedInstallPath =
- @"d:\projects\Test\MySolution\MyPackages\MyPackage.1.0.1.40".ToNativePath ();
-
- Assert.AreEqual (expectedInstallPath, installPath);
- }
-
- [Test]
- public void GetPackagesByDependencyOrder_OnePackageInSharedRepository_ReturnsOnePackage ()
- {
- CreateRepository ();
- AddPackageToSharedRepository ("Test");
-
- List<FakePackage> expectedPackages = fakeSharedRepository.FakePackages;
-
- List<IPackage> actualPackages = repository.GetPackagesByDependencyOrder ().ToList ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, actualPackages);
- }
-
- [Test]
- public void GetPackagesByDependencyOrder_OnePackageInSharedRepository_SharedRepositoryCreatedWithPathResolverForSolutionPackagesFolder ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- FakePackage package = AddPackageToSharedRepository ("Test", "1.0");
-
- repository.GetPackagesByDependencyOrder ().ToList ();
-
- IPackagePathResolver pathResolver = fakeRepositoryFactory.PathResolverPassedToCreateSharedRepository;
- string installPath = pathResolver.GetInstallPath (package);
-
- string expectedInstallPath = @"d:\projects\myproject\packages\Test.1.0".ToNativePath ();
-
- Assert.AreEqual (expectedInstallPath, installPath);
- }
-
- [Test]
public void Constructor_CreateInstance_SharedRepositoryCreatedWithFileSystemForSolutionPackagesFolder ()
{
CreateSolution (@"d:\projects\myproject\myproject.sln");
@@ -189,122 +135,5 @@ namespace MonoDevelop.PackageManagement.Tests Assert.AreEqual (expectedRootPath, rootPath);
}
-
- [Test]
- public void GetPackagesByDependencyOrder_TwoPackagesInSharedRepositoryFirstPackageDependsOnSecond_ReturnsSecondPackageFirst ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- FakePackage firstPackage = AddPackageToSharedRepository ("First");
- firstPackage.AddDependency ("Second");
- FakePackage secondPackage = AddPackageToSharedRepository ("Second");
-
- List<IPackage> actualPackages = repository.GetPackagesByDependencyOrder ().ToList ();
-
- var expectedPackages = new IPackage[] {
- secondPackage,
- firstPackage
- };
-
- Assert.AreEqual (expectedPackages, actualPackages);
- }
-
- [Test]
- public void GetPackagesByReverseDependencyOrder_TwoPackagesInSharedRepositorySecondPackageDependsOnFirst_ReturnsSecondPackageFirst ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- FakePackage firstPackage = AddPackageToSharedRepository ("First");
- FakePackage secondPackage = AddPackageToSharedRepository ("Second");
- secondPackage.AddDependency ("First");
-
- List<IPackage> actualPackages = repository.GetPackagesByReverseDependencyOrder ().ToList ();
-
- var expectedPackages = new IPackage[] {
- secondPackage,
- firstPackage
- };
-
- Assert.AreEqual (expectedPackages, actualPackages);
- }
-
- [Test]
- public void IsInstalled_PackageIsInSharedRepository_ReturnsTrue ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- FakePackage firstPackage = AddPackageToSharedRepository ("First");
-
- bool installed = repository.IsInstalled (firstPackage);
-
- Assert.IsTrue (installed);
- }
-
- [Test]
- public void IsInstalled_PackageIsNotInSharedRepository_ReturnsFalse ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- FakePackage testPackage = new FakePackage ("Test");
-
- bool installed = repository.IsInstalled (testPackage);
-
- Assert.IsFalse (installed);
- }
-
- [Test]
- public void GetPackages_OnePackageIsInSharedRepository_ReturnsOnePackage ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- FakePackage firstPackage = AddPackageToSharedRepository ("First");
-
- IQueryable<IPackage> packages = repository.GetPackages ();
-
- var expectedPackages = new FakePackage[] {
- firstPackage
- };
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void IsRestored_PackageReferenceHasNullVersion_ReturnsFalse ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- PackageReference packageReference = CreatePackageReference ("MyPackage", null);
-
- bool restored = repository.IsRestored (packageReference);
-
- Assert.IsFalse (restored);
- }
-
- [Test]
- public void IsRestored_OnePackageLookupPathForPackageReference_ReturnTrue ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- PackageReference packageReference = CreatePackageReference ("MyPackage", "1.2.3.4");
- AddFileToLocalRepositoryLookupPath (
- packageReference,
- @"d:\projects\myproject\packages\MyPackage.1.2.3.4\MyPackage.1.2.3.4.nupkg");
-
- bool restored = repository.IsRestored (packageReference);
-
- Assert.IsTrue (restored);
- }
-
- [Test]
- public void IsRestored_NoPackageLookupPathsForPackageReference_ReturnFalse ()
- {
- CreateSolution (@"d:\projects\myproject\myproject.sln");
- CreateRepository (solution);
- PackageReference packageReference = CreatePackageReference ("MyPackage", "1.2.3.4");
-
- bool restored = repository.IsRestored (packageReference);
-
- Assert.IsFalse (restored);
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepositoryFactoryEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/TestableInstrumentationService.cs index ecf70fad17..1dd55e69f6 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakePackageRepositoryFactoryEvents.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/TestableInstrumentationService.cs @@ -1,44 +1,48 @@ -//
-// FakePackageRepositoryFactoryEvents.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 MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- class FakePackageRepositoryFactoryEvents : IPackageRepositoryFactoryEvents
- {
- public event EventHandler<PackageRepositoryFactoryEventArgs> RepositoryCreated;
-
- public void RaiseRepositoryCreatedEvent (PackageRepositoryFactoryEventArgs e)
- {
- if (RepositoryCreated != null) {
- RepositoryCreated (this, e);
- }
- }
- }
-}
-
+// +// TestableInstrumentationService.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; + +namespace MonoDevelop.PackageManagement.Tests +{ + class TestableInstrumentationService : PackageManagementInstrumentationService + { + public IDictionary<string, string> InstallPackageMetadata; + + public override void IncrementInstallPackageCounter (IDictionary<string, string> metadata) + { + InstallPackageMetadata = metadata; + } + + public IDictionary<string, string> UninstallPackageMetadata; + + public override void IncrementUninstallPackageCounter (IDictionary<string, string> metadata) + { + UninstallPackageMetadata = metadata; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ThreadSafePackageManagementEventsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ThreadSafePackageManagementEventsTests.cs deleted file mode 100644 index 9151e6067d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/ThreadSafePackageManagementEventsTests.cs +++ /dev/null @@ -1,607 +0,0 @@ -//
-// ThreadSafePackageManagementEventsTests.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 System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class ThreadSafePackageManagementEventsTests
- {
- ThreadSafePackageManagementEvents threadSafeEvents;
- PackageManagementEvents unsafeEvents;
- bool eventHandlerFired;
- bool isGuiSyncDispatchCalled;
-
- void CreateEvents ()
- {
- isGuiSyncDispatchCalled = false;
- unsafeEvents = new PackageManagementEvents ();
- threadSafeEvents = new ThreadSafePackageManagementEvents (unsafeEvents, RunGuiSyncDispatch);
- }
-
- void RunGuiSyncDispatch (Action action)
- {
- isGuiSyncDispatchCalled = true;
- action.Invoke ();
- }
-
- void OnEventHandlerFired (object sender, EventArgs e)
- {
- eventHandlerFired = true;
- }
-
- [Test]
- public void OnPackageOperationsStarting_NoInvokeRequired_NonThreadSafePackageOperationsStartingMethodCalled ()
- {
- CreateEvents ();
- bool called = false;
- unsafeEvents.PackageOperationsStarting += (sender, e) => called = true;
- threadSafeEvents.OnPackageOperationsStarting ();
-
- Assert.IsTrue (called);
- }
-
- [Test]
- public void OnPackageOperationError_NoInvokeRequired_NonThreadSafeOnPackageOperationErrorMethodCalled ()
- {
- CreateEvents ();
- Exception exception = null;
- unsafeEvents.PackageOperationError += (sender, e) => exception = e.Exception;
- var expectedException = new Exception ("test");
-
- threadSafeEvents.OnPackageOperationError (expectedException);
-
- Assert.AreEqual (expectedException, exception);
- }
-
- [Test]
- public void OnAcceptLicenses_NoInvokeRequired_NonThreadSafeOnAcceptLicensesMethodCalled ()
- {
- CreateEvents ();
- IEnumerable<IPackage> packages = null;
- unsafeEvents.AcceptLicenses += (sender, e) => packages = e.Packages;
- var expectedPackages = new List<IPackage> ();
-
- threadSafeEvents.OnAcceptLicenses (expectedPackages);
-
- Assert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void OnAcceptLicenses_NoInvokeRequired_NonThreadSafeOnAcceptLicensesMethodCalledAndReturnsResult ()
- {
- CreateEvents ();
- unsafeEvents.AcceptLicenses += (sender, e) => e.IsAccepted = false;
-
- bool result = threadSafeEvents.OnAcceptLicenses (null);
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void OnParentPackageInstalled_NoInvokeRequired_NonThreadSafeOnParentPackageInstalledMethodCalled ()
- {
- CreateEvents ();
- IPackage package = null;
- IPackageManagementProject project = null;
- unsafeEvents.ParentPackageInstalled += (sender, e) => {
- package = e.Package;
- project = e.Project;
- };
- var expectedPackage = new FakePackage ();
- var expectedProject = new FakePackageManagementProject ();
-
- threadSafeEvents.OnParentPackageInstalled (expectedPackage, expectedProject);
-
- Assert.AreEqual (expectedPackage, package);
- }
-
- [Test]
- public void OnParentPackageUninstalled_NoInvokeRequired_NonThreadSafeOnParentPackageUninstalledMethodCalled ()
- {
- CreateEvents ();
- IPackage package = null;
- IPackageManagementProject project = null;
- unsafeEvents.ParentPackageUninstalled += (sender, e) => {
- package = e.Package;
- project = e.Project;
- };
- var expectedPackage = new FakePackage ();
- var expectedProject = new FakePackageManagementProject ();
-
- threadSafeEvents.OnParentPackageUninstalled (expectedPackage, expectedProject);
-
- Assert.AreEqual (expectedPackage, package);
- }
-
- [Test]
- public void OnPackageOperationMessageLogged_NoInvokeRequired_NonThreadSafeOnPackageOperationMessageLoggedMethodCalled ()
- {
- CreateEvents ();
- MessageLevel actualLevel = MessageLevel.Debug;
- string actualMessage = null;
- unsafeEvents.PackageOperationMessageLogged += (sender, e) => {
- actualLevel = e.Message.Level;
- actualMessage = e.Message.ToString ();
- };
-
- var messageLevel = MessageLevel.Warning;
- string message = "abc {0}";
- string arg = "test";
- threadSafeEvents.OnPackageOperationMessageLogged (messageLevel, message, arg);
-
- Assert.AreEqual (messageLevel, actualLevel);
- Assert.AreEqual ("abc test", actualMessage);
- }
-
- [Test]
- public void AcceptLicenses_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.AcceptLicenses += (sender, e) => fired = true;
- unsafeEvents.OnAcceptLicenses (null);
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void AcceptLicenses_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.AcceptLicenses += OnEventHandlerFired;
- threadSafeEvents.AcceptLicenses -= OnEventHandlerFired;
- unsafeEvents.OnAcceptLicenses (null);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void PackageOperationsStarting_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.PackageOperationsStarting += (sender, e) => fired = true;
- unsafeEvents.OnPackageOperationsStarting ();
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void PackageOperationsStarting_UnsafeEventFiredAndInvokeRequired_ThreadSafeEventIsSafelyInvoked ()
- {
- CreateEvents ();
- threadSafeEvents.PackageOperationsStarting += OnEventHandlerFired;
- unsafeEvents.OnPackageOperationsStarting ();
-
- Assert.IsTrue (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void PackageOperationsStarting_UnsafeEventFiredAndInvokeRequiredButNoEventHandlerRegistered_ThreadSafeEventIsNotInvoked ()
- {
- CreateEvents ();
- unsafeEvents.OnPackageOperationsStarting ();
-
- Assert.IsFalse (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void PackageOperationsStarting_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.PackageOperationsStarting += OnEventHandlerFired;
- threadSafeEvents.PackageOperationsStarting -= OnEventHandlerFired;
- unsafeEvents.OnPackageOperationsStarting ();
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void PackageOperationError_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.PackageOperationError += (sender, e) => fired = true;
- unsafeEvents.OnPackageOperationError (new Exception ());
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void PackageOperationError_UnsafeEventFiredAndInvokeRequired_ThreadSafeEventIsSafelyInvoked ()
- {
- CreateEvents ();
- threadSafeEvents.PackageOperationError += OnEventHandlerFired;
- var expectedException = new Exception ("Test");
-
- unsafeEvents.OnPackageOperationError (expectedException);
-
- Assert.IsTrue (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void PackageOperationError_UnsafeEventFiredAndInvokeRequiredButNoEventHandlerRegistered_ThreadSafeEventIsNotInvoked ()
- {
- CreateEvents ();
- unsafeEvents.OnPackageOperationError (new Exception ());
-
- Assert.IsFalse (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void PackageOperationError_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.PackageOperationError += OnEventHandlerFired;
- threadSafeEvents.PackageOperationError -= OnEventHandlerFired;
- unsafeEvents.OnPackageOperationError (new Exception ());
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void ParentPackageInstalled_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.ParentPackageInstalled += (sender, e) => fired = true;
- unsafeEvents.OnParentPackageInstalled (null, null);
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void ParentPackageInstalled_UnsafeEventFiredAndInvokeRequired_ThreadSafeEventIsSafelyInvoked ()
- {
- CreateEvents ();
- threadSafeEvents.ParentPackageInstalled += OnEventHandlerFired;
- var expectedPackage = new FakePackage ();
-
- unsafeEvents.OnParentPackageInstalled (expectedPackage, null);
-
- Assert.IsTrue (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void ParentPackageInstalled_UnsafeEventFiredAndInvokeRequiredButNoEventHandlerRegistered_ThreadSafeEventIsNotInvoked ()
- {
- CreateEvents ();
- unsafeEvents.OnParentPackageInstalled (new FakePackage (), null);
-
- Assert.IsFalse (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void ParentPackageInstalled_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.ParentPackageInstalled += OnEventHandlerFired;
- threadSafeEvents.ParentPackageInstalled -= OnEventHandlerFired;
- unsafeEvents.OnParentPackageInstalled (null, null);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void ParentPackageUninstalled_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.ParentPackageUninstalled += (sender, e) => fired = true;
- unsafeEvents.OnParentPackageUninstalled (null, null);
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void ParentPackageUninstalled_UnsafeEventFiredAndInvokeRequired_ThreadSafeEventIsSafelyInvoked ()
- {
- CreateEvents ();
- threadSafeEvents.ParentPackageUninstalled += OnEventHandlerFired;
- var expectedPackage = new FakePackage ();
-
- unsafeEvents.OnParentPackageUninstalled (expectedPackage, null);
-
- Assert.IsTrue (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void ParentPackageUninstalled_UnsafeEventFiredAndInvokeRequiredButNoEventHandlerRegistered_ThreadSafeEventIsNotInvoked ()
- {
- CreateEvents ();
- unsafeEvents.OnParentPackageUninstalled (new FakePackage (), null);
-
- Assert.IsFalse (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void ParentPackageUninstalled_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.ParentPackageUninstalled += OnEventHandlerFired;
- threadSafeEvents.ParentPackageUninstalled -= OnEventHandlerFired;
- unsafeEvents.OnParentPackageUninstalled (null, null);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void PackageOperationMessageLogged_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.PackageOperationMessageLogged += (sender, e) => fired = true;
- unsafeEvents.OnPackageOperationMessageLogged (MessageLevel.Info, String.Empty, new object[0]);
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void PackageOperationMessageLogged_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.PackageOperationMessageLogged += OnEventHandlerFired;
- threadSafeEvents.PackageOperationMessageLogged -= OnEventHandlerFired;
- unsafeEvents.OnPackageOperationMessageLogged (MessageLevel.Info, String.Empty, new object[0]);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void Dispose_PackageOperationsStartingHandlerExistsAndThreadUnsafeEventFiredAfterDispose_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.PackageOperationsStarting += OnEventHandlerFired;
-
- threadSafeEvents.Dispose ();
- unsafeEvents.OnPackageOperationsStarting ();
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void Dispose_PackageOperationErrorHandlerExistsAndThreadUnsafeEventFiredAfterDispose_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.PackageOperationError += OnEventHandlerFired;
-
- threadSafeEvents.Dispose ();
- unsafeEvents.OnPackageOperationError (new Exception ());
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void Dispose_ParentPackageInstalledHandlerExistsAndThreadUnsafeEventFiredAfterDispose_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.ParentPackageInstalled += OnEventHandlerFired;
-
- threadSafeEvents.Dispose ();
- unsafeEvents.OnParentPackageInstalled (new FakePackage (), null);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void Dispose_ParentParentPackageUninstalledHandlerExistsAndThreadUnsafeEventFiredAfterDispose_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.ParentPackageUninstalled += OnEventHandlerFired;
-
- threadSafeEvents.Dispose ();
- unsafeEvents.OnParentPackageUninstalled (new FakePackage (), null);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void OnSelectProjects_NoInvokeRequired_NonThreadSafeOnSelectProjectsMethodCalled ()
- {
- CreateEvents ();
- IEnumerable<IPackageManagementSelectedProject> selectedProjects = null;
- unsafeEvents.SelectProjects += (sender, e) => selectedProjects = e.SelectedProjects;
- var expectedSelectedProjects = new List<IPackageManagementSelectedProject> ();
-
- threadSafeEvents.OnSelectProjects (expectedSelectedProjects);
-
- Assert.AreEqual (expectedSelectedProjects, selectedProjects);
- }
-
- [Test]
- public void OnSelectLicenses_NoInvokeRequired_NonThreadSafeOnSelectProjectsMethodCalledAndReturnsResult ()
- {
- CreateEvents ();
- unsafeEvents.SelectProjects += (sender, e) => e.IsAccepted = true;
- var projects = new List<IPackageManagementSelectedProject> ();
- bool result = threadSafeEvents.OnSelectProjects (projects);
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void SelectProjects_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.SelectProjects += (sender, e) => fired = true;
- var projects = new List<IPackageManagementSelectedProject> ();
- unsafeEvents.OnSelectProjects (projects);
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void SelectProjects_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.SelectProjects += OnEventHandlerFired;
- threadSafeEvents.SelectProjects -= OnEventHandlerFired;
- var projects = new List<IPackageManagementSelectedProject> ();
- unsafeEvents.OnSelectProjects (projects);
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void OnResolveFileConflict_NoInvokeRequired_NonThreadSafeOnResolveFileConflictMethodCalledWithMessage ()
- {
- CreateEvents ();
- string message = null;
- unsafeEvents.ResolveFileConflict += (sender, e) => message = e.Message.ToString ();
-
- threadSafeEvents.OnResolveFileConflict ("message");
-
- Assert.AreEqual ("message", message);
- }
-
- [Test]
- public void OnResolveFileConflict_NoInvokeRequired_ValueReturnedFromNonThreadSafeOnResolveFileConflict ()
- {
- CreateEvents ();
- unsafeEvents.ResolveFileConflict += (sender, e) => {
- e.Resolution = FileConflictResolution.OverwriteAll;
- };
-
- FileConflictResolution result = threadSafeEvents.OnResolveFileConflict ("message");
-
- Assert.AreEqual (FileConflictResolution.OverwriteAll, result);
- }
-
- [Test]
- public void OnResolveFileConflict_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.ResolveFileConflict += (sender, e) => fired = true;
- unsafeEvents.OnResolveFileConflict ("message");
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void ResolveFileConflict_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.ResolveFileConflict += (sender, e) => fired = true;
- unsafeEvents.OnResolveFileConflict ("message");
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void ResolveFileConflict_UnsafeEventFiredAfterEventHandlerRemoved_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.ResolveFileConflict += OnEventHandlerFired;
- threadSafeEvents.ResolveFileConflict -= OnEventHandlerFired;
- unsafeEvents.OnResolveFileConflict ("message");
-
- Assert.IsFalse (eventHandlerFired);
- }
-
- [Test]
- public void OnParentPackagesUpdated_NoInvokeRequired_NonThreadSafeOnParentPackagesUpdatedMethodCalled ()
- {
- CreateEvents ();
- IEnumerable<IPackage> packages = null;
- unsafeEvents.ParentPackagesUpdated += (sender, e) => packages = e.Packages;
- var expectedPackages = new FakePackage[] { new FakePackage () };
-
- threadSafeEvents.OnParentPackagesUpdated (expectedPackages);
-
- Assert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void ParentPackagesUpdated_UnsafeEventFired_ThreadSafeEventFired ()
- {
- CreateEvents ();
- bool fired = false;
- threadSafeEvents.ParentPackagesUpdated += (sender, e) => fired = true;
- unsafeEvents.OnParentPackagesUpdated (null);
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void ParentPackagesUpdated_UnsafeEventFiredAndInvokeRequired_ThreadSafeEventIsSafelyInvoked ()
- {
- CreateEvents ();
- threadSafeEvents.ParentPackagesUpdated += OnEventHandlerFired;
- var expectedPackages = new FakePackage[] { new FakePackage () };
-
- unsafeEvents.OnParentPackagesUpdated (expectedPackages);
-
- Assert.IsTrue (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void ParentPackagesUpdated_UnsafeEventFiredAndInvokeRequiredButNoEventHandlerRegistered_ThreadSafeEventIsNotInvoked ()
- {
- CreateEvents ();
- var packages = new FakePackage[] { new FakePackage () };
- unsafeEvents.OnParentPackagesUpdated (packages);
-
- Assert.IsFalse (isGuiSyncDispatchCalled);
- }
-
- [Test]
- public void Dispose_ParentPackagesUpdatedHandlerExistsAndThreadUnsafeEventFiredAfterDispose_ThreadSafeEventIsNotFired ()
- {
- CreateEvents ();
- eventHandlerFired = false;
- threadSafeEvents.ParentPackagesUpdated += OnEventHandlerFired;
- threadSafeEvents.Dispose ();
-
- unsafeEvents.OnParentPackagesUpdated (new FakePackage[0]);
-
- Assert.IsFalse (eventHandlerFired);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UninstallNuGetPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UninstallNuGetPackageActionTests.cs new file mode 100644 index 0000000000..f0bf7f8da7 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UninstallNuGetPackageActionTests.cs @@ -0,0 +1,154 @@ +// +// UninstallNuGetPackageActionTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 MonoDevelop.PackageManagement.Tests.Helpers; +using NuGet.PackageManagement; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class UninstallNuGetPackageActionTests + { + TestableUninstallNuGetPackageAction action; + FakeSolutionManager solutionManager; + FakeDotNetProject project; + FakeNuGetProject nugetProject; + FakeNuGetPackageManager packageManager; + + void CreateAction (string packageId = "Test") + { + project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj"); + solutionManager = new FakeSolutionManager (); + nugetProject = new FakeNuGetProject (project); + solutionManager.NuGetProjects[project] = nugetProject; + + action = new TestableUninstallNuGetPackageAction ( + solutionManager, + project); + + packageManager = action.PackageManager; + + action.PackageId = packageId; + } + + void AddUninstallPackageIntoProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Uninstall); + packageManager.UninstallActions.Add (projectAction); + } + + [Test] + public void Execute_PackageIdIsSet_ActionsResolvedFromNuGetPackageManager () + { + CreateAction ("Test"); + + action.Execute (); + + Assert.AreEqual (nugetProject, packageManager.PreviewUninstallProject); + Assert.AreEqual ("Test", packageManager.PreviewUninstallPackageId); + Assert.AreEqual (action.ProjectContext, packageManager.PreviewUninstallProjectContext); + Assert.IsFalse (packageManager.PreviewUninstallContext.ForceRemove); + Assert.IsFalse (packageManager.PreviewUninstallContext.RemoveDependencies); + } + + [Test] + public void Execute_PackageIdAndVersionIsSet_ActionsAvailableForInstrumentation () + { + CreateAction (); + AddUninstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (action.GetNuGetProjectActions(), packageManager.UninstallActions); + } + + [Test] + public void Execute_PackageIdAndVersionIsSet_InstallsPackageUsingResolvedActions () + { + CreateAction ("Test"); + AddUninstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (packageManager.UninstallActions, packageManager.ExecutedActions); + Assert.AreEqual (nugetProject, packageManager.ExecutedNuGetProject); + Assert.AreEqual (action.ProjectContext, packageManager.ExecutedProjectContext); + } + + [Test] + public void Execute_ForceRemoveIsTrue_PackageIsForcefullyRemoved () + { + CreateAction ("Test"); + action.ForceRemove = true; + + action.Execute (); + + Assert.IsTrue (packageManager.PreviewUninstallContext.ForceRemove); + } + + [Test] + public void ForceRemove_NewInstance_IsFalseByDefault () + { + CreateAction ("Test"); + + Assert.IsFalse (action.ForceRemove); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_OnAfterExecuteActionsIsCalled () + { + CreateAction ("Test"); + AddUninstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (packageManager.UninstallActions, nugetProject.ActionsPassedToOnAfterExecuteActions); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_PostProcessingIsRun () + { + CreateAction ("Test"); + + action.Execute (); + + Assert.AreEqual (action.ProjectContext, nugetProject.PostProcessProjectContext); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_OnBeforeUninstallIsCalled () + { + CreateAction ("Test"); + AddUninstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (packageManager.UninstallActions, nugetProject.ActionsPassedToOnBeforeUninstall); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UninstallPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UninstallPackageActionTests.cs deleted file mode 100644 index 23ab02a146..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UninstallPackageActionTests.cs +++ /dev/null @@ -1,285 +0,0 @@ -//
-// UninstallPackageActionTests.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.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UninstallPackageActionTests
- {
- UninstallPackageAction action;
- PackageManagementEvents packageManagementEvents;
- UninstallPackageHelper uninstallPackageHelper;
- FakePackageManagementProject fakeProject;
-
- void CreateAction ()
- {
- packageManagementEvents = new PackageManagementEvents ();
- fakeProject = new FakePackageManagementProject ();
- action = new UninstallPackageAction (fakeProject, packageManagementEvents);
- uninstallPackageHelper = new UninstallPackageHelper (action);
- }
-
- FakePackage AddOnePackageToProjectSourceRepository (string packageId)
- {
- return fakeProject.FakeSourceRepository.AddFakePackage (packageId);
- }
-
- FakePackage AddOnePackageToProjectSourceRepository (string packageId, string version)
- {
- return fakeProject.FakeSourceRepository.AddFakePackageWithVersion (packageId, version);
- }
-
- void AddFileToPackageBeingUninstalled (string fileName)
- {
- var package = new FakePackage ();
- package.AddFile (fileName);
-
- action.Package = package;
- }
-
- [Test]
- public void Execute_PackageObjectPassed_UninstallsPackageFromProject ()
- {
- CreateAction ();
-
- uninstallPackageHelper.UninstallTestPackage ();
-
- var actualPackage = fakeProject.PackagePassedToUninstallPackage;
- var expectedPackage = uninstallPackageHelper.TestPackage;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackageAndPackageRepositoryPassed_OnPackageUninstalledCalledWithPackage ()
- {
- CreateAction ();
- IPackage actualPackage = null;
- packageManagementEvents.ParentPackageUninstalled += (sender, e) => {
- actualPackage = e.Package;
- };
-
- uninstallPackageHelper.UninstallTestPackage ();
-
- var expectedPackage = uninstallPackageHelper.TestPackage;
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackageObjectPassedAndForceRemoveIsFalse_PackageIsNotForcefullyRemoved ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- uninstallPackageHelper.ForceRemove = false;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- bool forceRemove = fakeProject.ForceRemovePassedToUninstallPackage;
-
- Assert.IsFalse (forceRemove);
- }
-
- [Test]
- public void Execute_PackageObjectPassedAndForceRemoveIsTrue_PackageIsForcefullyRemoved ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- uninstallPackageHelper.ForceRemove = true;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- bool forceRemove = fakeProject.ForceRemovePassedToUninstallPackage;
-
- Assert.IsTrue (forceRemove);
- }
-
- [Test]
- public void Execute_PackageObjectPassedAndRemoveDependenciesIsFalse_PackageDependenciesAreNotRemoved ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- uninstallPackageHelper.RemoveDependencies = false;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- bool removeDependencies = fakeProject.RemoveDependenciesPassedToUninstallPackage;
-
- Assert.IsFalse (removeDependencies);
- }
-
- [Test]
- public void Execute_PackageObjectPassedAndRemoveDependenciesIsTrue_PackageDependenciesAreRemoved ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- uninstallPackageHelper.RemoveDependencies = true;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- bool removeDependencies = fakeProject.RemoveDependenciesPassedToUninstallPackage;
-
- Assert.IsTrue (removeDependencies);
- }
-
- [Test]
- public void Execute_PackageIdSpecifiedAndForceRemoveIsTrue_PackageIsForcefullyRemoved ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- uninstallPackageHelper.ForceRemove = true;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- bool forceRemove = fakeProject.ForceRemovePassedToUninstallPackage;
-
- Assert.IsTrue (forceRemove);
- }
-
- [Test]
- public void Execute_PackageIdSpecifiedAndRemoveDependenciesIsTrue_PackageDependenciesAreRemoved ()
- {
- CreateAction ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- uninstallPackageHelper.RemoveDependencies = true;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- bool removeDependencies = fakeProject.RemoveDependenciesPassedToUninstallPackage;
-
- Assert.IsTrue (removeDependencies);
- }
-
- [Test]
- public void Execute_VersionSpecified_VersionUsedWhenSearchingForPackage ()
- {
- CreateAction ();
-
- AddOnePackageToProjectSourceRepository ("PackageId", "1.2.0.0");
- AddOnePackageToProjectSourceRepository ("PackageId", "1.0.0.0");
- FakePackage package = AddOnePackageToProjectSourceRepository ("PackageId", "1.1.0");
-
- uninstallPackageHelper.Version = package.Version;
- uninstallPackageHelper.UninstallPackageById ("PackageId");
-
- var actualPackage = fakeProject.PackagePassedToUninstallPackage;
-
- Assert.AreEqual (package, actualPackage);
- }
-
- [Test]
- public void ForceRemove_DefaultValue_ReturnsFalse ()
- {
- CreateAction ();
- Assert.IsFalse (action.ForceRemove);
- }
-
- [Test]
- public void RemoveDependencies_DefaultValue_ReturnsFalse ()
- {
- CreateAction ();
- Assert.IsFalse (action.RemoveDependencies);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasUninstallPowerShellScript_ReturnsTrue ()
- {
- CreateAction ();
- AddFileToPackageBeingUninstalled (@"tools\uninstall.ps1");
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasNoFiles_ReturnsFalse ()
- {
- CreateAction ();
- action.Package = new FakePackage ();
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsFalse (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasUninstallPowerShellScriptInUpperCase_ReturnsTrue ()
- {
- CreateAction ();
- AddFileToPackageBeingUninstalled (@"tools\UNINSTALL.PS1");
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void AllowPreleasePackages_DefaultValue_IsTrue ()
- {
- CreateAction ();
-
- Assert.IsTrue (action.AllowPrereleaseVersions);
- }
-
- [Test]
- public void Execute_PackageHasPowerShellUninstallScript_PowerShellInfoLogged ()
- {
- CreateAction ();
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.0");
- action.Package = package;
- package.AddFile (@"tools\uninstall.ps1");
- var messagesLogged = new List<string> ();
- packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
- if (e.Message.Level == MessageLevel.Info) {
- messagesLogged.Add (e.Message.ToString ());
- }
- };
-
- action.Execute ();
-
- Assert.That (messagesLogged, Contains.Item ("WARNING: Test Package contains PowerShell scripts which will not be run."));
- }
-
- [Test]
- public void Execute_PackageHasPowerShellInstallScript_NoPowerShellWarningLogged ()
- {
- CreateAction ();
- FakePackage package = FakePackage.CreatePackageWithVersion ("Test", "1.0");
- action.Package = package;
- package.AddFile (@"tools\install.ps1");
- var messagesLogged = new List<string> ();
- packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
- messagesLogged.Add (e.Message.ToString ());
- };
-
- action.Execute ();
-
- Assert.IsFalse (messagesLogged.Any (message => message.Contains ("PowerShell")));
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllNuGetPackagesInProjectActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllNuGetPackagesInProjectActionTests.cs new file mode 100644 index 0000000000..c93f73c0c4 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllNuGetPackagesInProjectActionTests.cs @@ -0,0 +1,485 @@ +// +// UpdateAllNuGetPackagesInProjectActionTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using MonoDevelop.PackageManagement.Tests.Helpers; +using MonoDevelop.Projects; +using NuGet.Configuration; +using NuGet.PackageManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Resolver; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + public class UpdateAllNuGetPackagesInProjectActionTests + { + TestableUpdateAllNuGetPackagesInProjectAction action; + FakeSolutionManager solutionManager; + FakeDotNetProject project; + FakeNuGetProject nugetProject; + List<SourceRepository> primaryRepositories; + FakeNuGetPackageManager packageManager; + FakePackageMetadataResource packageMetadataResource; + PackageManagementEvents packageManagementEvents; + FakeFileRemover fileRemover; + FakePackageRestoreManager restoreManager; + + void CreateAction () + { + project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj"); + solutionManager = new FakeSolutionManager (); + nugetProject = new FakeNuGetProject (project); + solutionManager.NuGetProjects[project] = nugetProject; + + var metadataResourceProvider = new FakePackageMetadataResourceProvider (); + packageMetadataResource = metadataResourceProvider.PackageMetadataResource; + var source = new PackageSource ("http://test.com"); + var providers = new INuGetResourceProvider[] { + metadataResourceProvider + }; + var sourceRepository = new SourceRepository (source, providers); + primaryRepositories = new [] { + sourceRepository + }.ToList (); + solutionManager.SourceRepositoryProvider.Repositories.AddRange (primaryRepositories); + + action = new TestableUpdateAllNuGetPackagesInProjectAction ( + solutionManager, + project); + + packageManager = action.PackageManager; + packageManagementEvents = action.PackageManagementEvents; + fileRemover = action.FileRemover; + restoreManager = action.RestoreManager; + } + + void AddInstallPackageIntoProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Install); + packageManager.UpdateActions.Add (projectAction); + } + + void AddUninstallPackageFromProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Uninstall); + packageManager.UpdateActions.Add (projectAction); + } + + void AddPackageToProject (string packageId, string version) + { + nugetProject.AddPackageReference (packageId, version); + } + + void AddUnrestoredPackageForProject (string projectName) + { + restoreManager.AddUnrestoredPackageForProject (projectName, solutionManager.SolutionDirectory); + } + + [Test] + public void Execute_PackagesAreRestoredAndNoPrereleasePackages_ActionsResolvedFromNuGetPackageManager () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (primaryRepositories, packageManager.PreviewUpdatePrimarySources); + Assert.AreEqual (new SourceRepository[0], packageManager.PreviewUpdateSecondarySources); + Assert.AreEqual (nugetProject, packageManager.PreviewUpdateProject); + Assert.IsNull (packageManager.PreviewUpdatePackageId); + Assert.IsFalse (packageManager.PreviewUpdateResolutionContext.IncludePrerelease); + Assert.AreEqual (VersionConstraints.None, packageManager.PreviewUpdateResolutionContext.VersionConstraints); + Assert.IsFalse (packageManager.PreviewUpdateResolutionContext.IncludeUnlisted); + Assert.AreEqual (DependencyBehavior.Lowest, packageManager.PreviewUpdateResolutionContext.DependencyBehavior); + } + + [Test] + public void Execute_PackagesAreRestoredAndNoPrereleasePackages_ActionsAvailableForInstrumentation () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (action.GetNuGetProjectActions (), packageManager.UpdateActions); + } + + [Test] + public void Execute_PackagesAreRestoredAndNoPrereleasePackages_UpdatesPackageUsingResolvedActions () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddInstallPackageIntoProjectAction ("A", "2.1"); + + action.Execute (); + + Assert.AreEqual (packageManager.UpdateActions, packageManager.ExecutedActions); + Assert.AreEqual (nugetProject, packageManager.ExecutedNuGetProject); + Assert.AreEqual (action.ProjectContext, packageManager.ExecutedProjectContext); + } + + [Test] + public void Execute_ProjectHasPrereleasePackage_ActionsResolvedFromNuGetPackageManagerAllowingPrereleasePackages () + { + CreateAction (); + AddPackageToProject ("Test", "1.0.1-alpha"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.IsTrue (packageManager.PreviewUpdateResolutionContext.IncludePrerelease); + } + + [Test] + public void Execute_NoActions_NoUpdateFoundEventFires () + { + CreateAction (); + IDotNetProject noUpdateFoundForProject = null; + packageManagementEvents.NoUpdateFound += (sender, e) => { + noUpdateFoundForProject = e.Project; + }; + + action.Execute (); + + Assert.AreEqual (project, noUpdateFoundForProject); + } + + [Test] + public void Execute_OneAction_NoUpdateFoundEventDoesNotFire () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + IDotNetProject noUpdateFoundForProject = null; + packageManagementEvents.NoUpdateFound += (sender, e) => { + noUpdateFoundForProject = e.Project; + }; + + action.Execute (); + + Assert.IsNull (noUpdateFoundForProject); + } + + [Test] + public void Execute_NoActions_NoActionsExecuted () + { + CreateAction (); + IDotNetProject noUpdateFoundForProject = null; + packageManagementEvents.NoUpdateFound += (sender, e) => { + noUpdateFoundForProject = e.Project; + }; + + action.Execute (); + + Assert.IsNull (packageManager.ExecutedActions); + Assert.AreEqual (project, noUpdateFoundForProject); + } + + [Test] + public void Execute_OnePackageNotRestored_PackageIsRestored () + { + CreateAction (); + solutionManager.SolutionDirectory = @"d:\projects\MyProject".ToNativePath (); + project.Name = "MyProject"; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddUnrestoredPackageForProject ("MyProject"); + + action.Execute (); + + Assert.AreEqual (solutionManager.SolutionDirectory, restoreManager.RestoreMissingPackagesSolutionDirectory); + Assert.AreEqual (action.ProjectContext, restoreManager.RestoreMissingPackagesProjectContext); + Assert.AreEqual (nugetProject, restoreManager.RestoreMissingPackagesProject); + } + + [Test] + public void Execute_OnePackageNotRestored_ProjectReferencesRefreshed () + { + CreateAction (); + solutionManager.SolutionDirectory = @"d:\projects\MyProject".ToNativePath (); + project.Name = "MyProject"; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddUnrestoredPackageForProject ("MyProject"); + + action.Execute (); + + Assert.IsTrue (project.IsReferenceStatusRefreshed); + } + + [Test] + public void Execute_OnePackageNotRestored_PackagesRestoredEventIsFired () + { + CreateAction (); + solutionManager.SolutionDirectory = @"d:\projects\MyProject".ToNativePath (); + project.Name = "MyProject"; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddUnrestoredPackageForProject ("MyProject"); + bool packagesRestored = false; + packageManagementEvents.PackagesRestored += (sender, e) => packagesRestored = true; + + action.Execute (); + + Assert.IsTrue (packagesRestored); + } + + [Test] + public void Execute_OnePackageNotRestoredAndPackageRestoreFails_ExceptionThrownAndRestoreFailureMessageLogged () + { + CreateAction (); + solutionManager.SolutionDirectory = @"d:\projects\MyProject".ToNativePath (); + project.Name = "MyProject"; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddUnrestoredPackageForProject ("MyProject"); + string messageLogged = null; + packageManagementEvents.PackageOperationMessageLogged += (sender, e) => { + messageLogged = e.Message.ToString (); + }; + restoreManager.BeforeRestoreMissingPackagesAsync = () => { + var exception = new Exception ("RestoreErrorMessage"); + restoreManager.RaisePackageRestoreFailedEvent (exception, "MyProject"); + }; + + var ex = Assert.Throws<AggregateException> (() => { + action.Execute (); + }); + + Assert.AreEqual ("Package restore failed for project MyProject: RestoreErrorMessage", messageLogged); + Assert.AreEqual ("Package restore failed.", ex.GetBaseException ().Message); + } + + [Test] + public void Execute_PackagesConfigFileDeletedDuringUpdate_FileServicePackagesConfigFileDeletionIsCancelled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName); + }; + + action.Execute (); + + Assert.AreEqual (expectedFileName, fileRemover.FileRemoved); + Assert.IsFalse (fileRemovedResult.Value); + } + + [Test] + public void Execute_ScriptFileDeletedDuringUpdate_FileDeletionIsNotCancelled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName); + }; + + action.Execute (); + + Assert.IsTrue (fileRemovedResult.Value); + Assert.IsNull (fileRemover.FileRemoved); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyTrue_ReferenceAddedHasLocalCopyTrue () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = true; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsTrue (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyTrueButCaseIsDifferent_ReferenceAddedHasLocalCopyTrue () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "nunit.framework"); + referenceBeingRemoved.LocalCopy = true; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsTrue (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyFalse_ReferenceAddedHasLocalCopyFalse () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + firstReferenceBeingAdded.LocalCopy = true; + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyFalseButCaseIsDifferent_ReferenceAddedHasLocalCopyFalse () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + firstReferenceBeingAdded.LocalCopy = true; + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "nunit.framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_PackagesConfigFileNamedAfterProjectDeletedDuringUpdate_FileServicePackagesConfigFileDeletionIsCancelled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + string expectedFileName = @"d:\projects\MyProject\packages.MyProject.config".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName); + }; + action.Execute (); + + Assert.AreEqual (expectedFileName, fileRemover.FileRemoved); + Assert.IsFalse (fileRemovedResult.Value); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_OnAfterExecuteActionsIsCalled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (packageManager.UpdateActions, nugetProject.ActionsPassedToOnAfterExecuteActions); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_PostProcessingIsRun () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (action.ProjectContext, nugetProject.PostProcessProjectContext); + } + + [Test] + public void Execute_PackageHasALicenseToBeAcceptedWhichIsAccepted_UserPromptedToAcceptLicenses () + { + CreateAction (); + action.LicenseAcceptanceService.AcceptLicensesReturnValue = true; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + + action.Execute (); + + var license = action.LicenseAcceptanceService.PackageLicensesAccepted.Single (); + Assert.AreEqual ("Test", license.PackageId); + Assert.AreEqual (metadata.LicenseUrl, license.LicenseUrl); + Assert.AreEqual (metadata.Authors, license.PackageAuthor); + Assert.AreEqual (metadata.Title, license.PackageTitle); + Assert.AreEqual ("Test", license.PackageIdentity.Id); + Assert.AreEqual ("1.2", license.PackageIdentity.Version.ToString ()); + } + + [Test] + public void Execute_PackageHasALicenseToBeAcceptedWhichIsNotAccepted_ExceptionThrown () + { + CreateAction (); + action.LicenseAcceptanceService.AcceptLicensesReturnValue = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + + Exception ex = Assert.Throws (typeof(AggregateException), () => action.Execute ()); + + Assert.AreEqual ("Licenses not accepted.", ex.GetBaseException ().Message); + } + + [Test] + public void Execute_OnePackageIsUpdated_OpenReadmeFileForPackageIfItExists () + { + CreateAction (); + AddPackageToProject ("Test", "1.0"); + AddUninstallPackageFromProjectAction ("Test", "1.0"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + var packageIdentity = packageManager.OpenReadmeFilesForPackages.Single (); + Assert.AreEqual (nugetProject, packageManager.OpenReadmeFilesForProject); + Assert.AreEqual (action.ProjectContext, packageManager.OpenReadmeFilesWithProjectContext); + Assert.AreEqual ("Test", packageIdentity.Id); + Assert.AreEqual ("1.2", packageIdentity.Version.ToString ()); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllPackagesInProjectTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllPackagesInProjectTests.cs deleted file mode 100644 index 45861805d4..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllPackagesInProjectTests.cs +++ /dev/null @@ -1,247 +0,0 @@ -//
-// UpdateAllPackagesInProjectTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UpdateAllPackagesInProjectTests
- {
- UpdateAllPackagesInProject updateAllPackagesInProject;
- FakePackageManagementProject fakeProject;
- List<UpdatePackageAction> updateActions;
-
- void CreateUpdateAllPackagesInProject ()
- {
- fakeProject = new FakePackageManagementProject ();
- updateAllPackagesInProject = new UpdateAllPackagesInProject (fakeProject);
- }
-
- void AddPackageToProject (string packageId, string version = "1.0")
- {
- var package = new FakePackage (packageId, version);
- fakeProject.FakePackagesInReverseDependencyOrder.Add (package);
- }
-
- void CallCreateActions ()
- {
- IEnumerable<UpdatePackageAction> actions = updateAllPackagesInProject.CreateActions ();
- updateActions = actions.ToList ();
- }
-
- UpdatePackageAction FirstUpdateAction {
- get { return updateActions [0]; }
- }
-
- [Test]
- public void CreateActions_OnePackageInProject_ReturnsOneAction ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- CallCreateActions ();
-
- Assert.AreEqual (1, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_OnePackageInProject_ActionCreatedFromProject ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- CallCreateActions ();
-
- UpdatePackageAction action = updateActions [0];
- UpdatePackageAction expectedAction = fakeProject.FirstFakeUpdatePackageActionCreated;
-
- Assert.AreEqual (expectedAction, action);
- }
-
- [Test]
- public void CreateActions_OnePackageInProject_PackageIdSpecifiedInAction ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- CallCreateActions ();
-
- string id = FirstUpdateAction.PackageId;
-
- Assert.AreEqual ("Test", id);
- }
-
- [Test]
- public void CreateActions_OnePackageInProject_PackageVersionSpecifiedInActionIsNull ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- CallCreateActions ();
-
- SemanticVersion version = FirstUpdateAction.PackageVersion;
-
- Assert.IsNull (version);
- }
-
- [Test]
- public void CreateActions_NoPackagesInProject_ReturnsNoActions ()
- {
- CreateUpdateAllPackagesInProject ();
- CallCreateActions ();
-
- Assert.AreEqual (0, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_TwoPackagesInProject_TwoUpdateActionsCreated ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test1");
- AddPackageToProject ("Test2");
- CallCreateActions ();
-
- Assert.AreEqual (2, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_TwoPackagesInProject_TwoPackageIdsSpecifiedInActions ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test1");
- AddPackageToProject ("Test2");
- CallCreateActions ();
-
- Assert.AreEqual ("Test1", updateActions [0].PackageId);
- Assert.AreEqual ("Test2", updateActions [1].PackageId);
- }
-
- [Test]
- public void CreateActions_OnePackageInProject_UpdateIfPackageDoesNotExistInProjectIsFalse ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- CallCreateActions ();
-
- bool update = FirstUpdateAction.UpdateIfPackageDoesNotExistInProject;
-
- Assert.IsFalse (update);
- }
-
- [Test]
- public void CreateActions_OnePackageInProjectAndUpdateDependenciesSetToFalse_ActionUpdateDependenciesIsFalse ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- updateAllPackagesInProject.UpdateDependencies = false;
-
- CallCreateActions ();
-
- bool update = FirstUpdateAction.UpdateDependencies;
-
- Assert.IsFalse (update);
- }
-
- [Test]
- public void UpdateDependencies_NewInstance_ReturnsTrue ()
- {
- CreateUpdateAllPackagesInProject ();
- bool update = updateAllPackagesInProject.UpdateDependencies;
-
- Assert.IsTrue (update);
- }
-
- [Test]
- public void CreateActions_OnePackageInProjectAndAllowPrereleaseVersionsSetToFalse_ActionPrereleaseVersionsIsFalse ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- updateAllPackagesInProject.AllowPrereleaseVersions = false;
-
- CallCreateActions ();
-
- bool allow = FirstUpdateAction.AllowPrereleaseVersions;
-
- Assert.IsFalse (allow);
- }
-
- [Test]
- public void CreateActions_OnePackageInProjectAndAllowPrereleaseVersionsSetToTrue_ActionPrereleaseVersionsIsTrue ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- updateAllPackagesInProject.AllowPrereleaseVersions = true;
-
- CallCreateActions ();
-
- bool allow = FirstUpdateAction.AllowPrereleaseVersions;
-
- Assert.IsTrue (allow);
- }
-
- [Test]
- public void AllowPrereleaseVersions_NewInstance_ReturnsFalse ()
- {
- CreateUpdateAllPackagesInProject ();
- bool allow = updateAllPackagesInProject.AllowPrereleaseVersions;
-
- Assert.IsFalse (allow);
- }
-
- [Test]
- public void CreateActions_OnePackageInProjectAndUpdateDependenciesSetToTrue_ActionUpdateDependenciesIsTrue ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test");
- updateAllPackagesInProject.UpdateDependencies = true;
-
- CallCreateActions ();
-
- bool update = FirstUpdateAction.UpdateDependencies;
-
- Assert.IsTrue (update);
- }
-
- [Test]
- public void CreateActions_TwoPackagesInProjectOnePrereleaseOneStable_AllowPrereleaseIsTrueForPrereleasePackage ()
- {
- CreateUpdateAllPackagesInProject ();
- AddPackageToProject ("Test1", "1.0.0-alpha");
- AddPackageToProject ("Test2", "1.0.0");
- CallCreateActions ();
-
- Assert.AreEqual ("Test1", updateActions [0].PackageId);
- Assert.AreEqual ("Test2", updateActions [1].PackageId);
- Assert.AreEqual (true, updateActions [0].AllowPrereleaseVersions);
- Assert.AreEqual (false, updateActions [1].AllowPrereleaseVersions);
- }
- }
-}
-
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllPackagesInSolutionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllPackagesInSolutionTests.cs deleted file mode 100644 index 6e923e2d59..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateAllPackagesInSolutionTests.cs +++ /dev/null @@ -1,281 +0,0 @@ -//
-// UpdateAllPackagesInSolutionTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UpdateAllPackagesInSolutionTests
- {
- UpdateAllPackagesInSolution updateAllPackagesInSolution;
- FakePackageManagementSolution fakeSolution;
- List<UpdatePackageAction> updateActions;
- FakePackageRepository fakeSourceRepository;
-
- void CreateUpdateAllPackagesInSolution ()
- {
- fakeSolution = new FakePackageManagementSolution ();
- fakeSourceRepository = new FakePackageRepository ();
- updateAllPackagesInSolution = new UpdateAllPackagesInSolution (fakeSolution, fakeSourceRepository);
- }
-
- void AddPackageToSolution (string packageId, string version = "1.0")
- {
- var package = new FakePackage (packageId, version);
- fakeSolution.FakePackagesInReverseDependencyOrder.Add (package);
- }
-
- FakePackageManagementProject AddProjectToSolution (string projectName)
- {
- return fakeSolution.AddFakeProject (projectName);
- }
-
- void CallCreateActions ()
- {
- IEnumerable<UpdatePackageAction> actions = updateAllPackagesInSolution.CreateActions ();
- updateActions = actions.ToList ();
- }
-
- UpdatePackageAction FirstUpdateAction {
- get { return updateActions [0]; }
- }
-
- FakePackageManagementProject FirstProjectInSolution {
- get { return fakeSolution.FakeProjects [0]; }
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProject_ReturnsOneAction ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- CallCreateActions ();
-
- Assert.AreEqual (1, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProject_UpdateActionCreatedFromProject ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- CallCreateActions ();
-
- UpdatePackageAction action = FirstUpdateAction;
- UpdatePackageAction expectedAction = FirstProjectInSolution.FirstFakeUpdatePackageActionCreated;
-
- Assert.AreEqual (expectedAction, action);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProject_UpdateActionCreatedUsingSourceRepositoryPassedInConstructor ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- CallCreateActions ();
-
- IPackageRepository repository = fakeSolution.SourceRepositoryPassedToGetProjects;
- FakePackageRepository expectedRepository = fakeSourceRepository;
-
- Assert.AreEqual (expectedRepository, repository);
- }
-
- [Test]
- public void CreateActions_NoPackagesInSolution_NoActionsReturned ()
- {
- CreateUpdateAllPackagesInSolution ();
- CallCreateActions ();
-
- Assert.AreEqual (0, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_TwoPackagesInSolutionWithOneProject_ReturnsTwoActions ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test1");
- AddPackageToSolution ("Test2");
- CallCreateActions ();
-
- Assert.AreEqual (2, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_TwoPackagesInSolutionWithOneProject_ReturnsTwoActionsWithPackageIdsForTwoPackages ()
- {
- CreateUpdateAllPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test1");
- AddPackageToSolution ("Test2");
- CallCreateActions ();
-
- string[] packageIds = new string[] {
- project.FirstFakeUpdatePackageActionCreated.PackageId,
- project.SecondFakeUpdatePackageActionCreated.PackageId
- };
-
- string[] expectedPackageIds = new string[] {
- "Test1",
- "Test2"
- };
-
- Assert.AreEqual (expectedPackageIds, packageIds);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithTwoProjects_ReturnsTwoActions ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject1");
- AddProjectToSolution ("MyProject2");
- AddPackageToSolution ("Test");
- CallCreateActions ();
-
- Assert.AreEqual (2, updateActions.Count);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithTwoProjects_ReturnsTwoActionsCreatedFromProjects ()
- {
- CreateUpdateAllPackagesInSolution ();
- FakePackageManagementProject project1 = AddProjectToSolution ("MyProject1");
- FakePackageManagementProject project2 = AddProjectToSolution ("MyProject2");
- AddPackageToSolution ("Test");
- CallCreateActions ();
-
- var expectedActions = new UpdatePackageAction[] {
- project1.FirstFakeUpdatePackageActionCreated,
- project2.FirstFakeUpdatePackageActionCreated
- };
-
- Assert.AreEqual (expectedActions, updateActions);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProject_UpdateActionDoesNotUpdatePackageIfProjectDoesNotHavePackage ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- CallCreateActions ();
-
- bool updateIfPackageDoesNotExist = FirstUpdateAction.UpdateIfPackageDoesNotExistInProject;
-
- Assert.IsFalse (updateIfPackageDoesNotExist);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProjectAndUpdateDependenciesIsFalse_UpdateActionDoesNotUpdateDependencies ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- updateAllPackagesInSolution.UpdateDependencies = false;
- CallCreateActions ();
-
- bool updateDependencies = FirstUpdateAction.UpdateDependencies;
-
- Assert.IsFalse (updateDependencies);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProjectAndUpdateDependenciesIsTrue_UpdateActionDoesUpdateDependencies ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- updateAllPackagesInSolution.UpdateDependencies = true;
- CallCreateActions ();
-
- bool updateDependencies = FirstUpdateAction.UpdateDependencies;
-
- Assert.IsTrue (updateDependencies);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProjectAndAllowPrereleaseVersionsIsFalse_UpdateActionDoesNotAllowPrereleases ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- updateAllPackagesInSolution.AllowPrereleaseVersions = false;
- CallCreateActions ();
-
- bool allowPrereleases = FirstUpdateAction.AllowPrereleaseVersions;
-
- Assert.IsFalse (allowPrereleases);
- }
-
- [Test]
- public void CreateActions_OnePackageInSolutionWithOneProjectAndAllowPrereleaseVersionsIsTrue_UpdateActionDoesAllowPrereleases ()
- {
- CreateUpdateAllPackagesInSolution ();
- AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test");
- updateAllPackagesInSolution.AllowPrereleaseVersions = true;
- CallCreateActions ();
-
- bool allowPrereleases = FirstUpdateAction.AllowPrereleaseVersions;
-
- Assert.IsTrue (allowPrereleases);
- }
-
- [Test]
- public void CreateActions_NoPackagesInSolution_UpdatePackageDependenciesIsTrueByDefault ()
- {
- CreateUpdateAllPackagesInSolution ();
-
- Assert.IsTrue (updateAllPackagesInSolution.UpdateDependencies);
- }
-
- [Test]
- public void CreateActions_TwoPackagesOneStableOnePrereleaseInSolutionWithOneProject_ReturnsTwoActionsWithAllowPrereleaseTrueForPrereleasePackage ()
- {
- CreateUpdateAllPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ("MyProject");
- AddPackageToSolution ("Test1", "1.0.0-alpha");
- AddPackageToSolution ("Test2", "1.0");
- CallCreateActions ();
-
- Assert.AreEqual ("Test1", project.FirstFakeUpdatePackageActionCreated.PackageId);
- Assert.AreEqual (true, project.FirstFakeUpdatePackageActionCreated.AllowPrereleaseVersions);
- Assert.AreEqual ("Test2", project.FakeUpdatePackageActionsCreated [1].PackageId);
- Assert.AreEqual (false, project.FakeUpdatePackageActionsCreated[1].AllowPrereleaseVersions);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateNuGetPackageActionTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateNuGetPackageActionTests.cs new file mode 100644 index 0000000000..cd04f1dbc9 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdateNuGetPackageActionTests.cs @@ -0,0 +1,424 @@ +// +// UpdateNuGetPackageActionTests.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; +using MonoDevelop.PackageManagement.Tests.Helpers; +using MonoDevelop.Projects; +using NuGet.Configuration; +using NuGet.PackageManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Resolver; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + public class UpdateNuGetPackageActionTests + { + TestableUpdateNuGetPackageAction action; + FakeSolutionManager solutionManager; + FakeDotNetProject project; + FakeNuGetProject nugetProject; + List<SourceRepository> primaryRepositories; + FakeNuGetPackageManager packageManager; + FakePackageMetadataResource packageMetadataResource; + IPackageManagementEvents packageManagementEvents; + FakeFileRemover fileRemover; + + void CreateAction (string packageId = "Test") + { + project = new FakeDotNetProject (@"d:\projects\MyProject\MyProject.csproj"); + solutionManager = new FakeSolutionManager (); + nugetProject = new FakeNuGetProject (project); + solutionManager.NuGetProjects[project] = nugetProject; + + var metadataResourceProvider = new FakePackageMetadataResourceProvider (); + packageMetadataResource = metadataResourceProvider.PackageMetadataResource; + var source = new PackageSource ("http://test.com"); + var providers = new INuGetResourceProvider[] { + metadataResourceProvider + }; + var sourceRepository = new SourceRepository (source, providers); + primaryRepositories = new [] { + sourceRepository + }.ToList (); + solutionManager.SourceRepositoryProvider.Repositories.AddRange (primaryRepositories); + + action = new TestableUpdateNuGetPackageAction ( + solutionManager, + project); + + packageManager = action.PackageManager; + packageManagementEvents = action.PackageManagementEvents; + fileRemover = action.FileRemover; + + action.PackageId = packageId; + } + + void AddInstallPackageIntoProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Install); + packageManager.UpdateActions.Add (projectAction); + } + + void AddUninstallPackageFromProjectAction (string packageId, string version) + { + var projectAction = new FakeNuGetProjectAction (packageId, version, NuGetProjectActionType.Uninstall); + packageManager.UpdateActions.Add (projectAction); + } + + [Test] + public void Execute_PackageId_ActionsResolvedFromNuGetPackageManager () + { + CreateAction ("Test"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (primaryRepositories, packageManager.PreviewUpdatePrimarySources); + Assert.AreEqual (new SourceRepository[0], packageManager.PreviewUpdateSecondarySources); + Assert.AreEqual (nugetProject, packageManager.PreviewUpdateProject); + Assert.AreEqual ("Test", packageManager.PreviewUpdatePackageId); + Assert.IsFalse (packageManager.PreviewUpdateResolutionContext.IncludePrerelease); + Assert.AreEqual (VersionConstraints.None, packageManager.PreviewUpdateResolutionContext.VersionConstraints); + Assert.IsFalse (packageManager.PreviewUpdateResolutionContext.IncludeUnlisted); + Assert.AreEqual (DependencyBehavior.Lowest, packageManager.PreviewUpdateResolutionContext.DependencyBehavior); + } + + [Test] + public void Execute_PackageIdIsSet_ActionsAvailableForInstrumentation () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (action.GetNuGetProjectActions(), packageManager.UpdateActions); + } + + [Test] + public void Execute_PackageIdIsSet_UpdatesPackageUsingResolvedActions () + { + CreateAction ("Test"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + AddInstallPackageIntoProjectAction ("A", "2.1"); + + action.Execute (); + + Assert.AreEqual (packageManager.UpdateActions, packageManager.ExecutedActions); + Assert.AreEqual (nugetProject, packageManager.ExecutedNuGetProject); + Assert.AreEqual (action.ProjectContext, packageManager.ExecutedProjectContext); + } + + [Test] + public void IncludePrerelease_DefaultValue_ReturnsFalse () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + Assert.IsFalse (action.IncludePrerelease); + } + + [Test] + public void Execute_IncludePrereleaseIsTrue_PrereleaseVersionsAllowed () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + action.IncludePrerelease = true; + + action.Execute (); + + Assert.IsTrue (packageManager.PreviewUpdateResolutionContext.IncludePrerelease); + } + + [Test] + public void Execute_PackagesConfigFileDeletedDuringUpdate_FileServicePackagesConfigFileDeletionIsCancelled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName); + }; + action.Execute (); + + Assert.AreEqual (expectedFileName, fileRemover.FileRemoved); + Assert.IsFalse (fileRemovedResult.Value); + } + + [Test] + public void Execute_ScriptFileDeletedDuringUpdate_FileDeletionIsNotCancelled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName); + }; + action.Execute (); + + Assert.IsTrue (fileRemovedResult.Value); + Assert.IsNull (fileRemover.FileRemoved); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyTrue_ReferenceAddedHasLocalCopyTrue () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = true; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsTrue (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyTrueButCaseIsDifferent_ReferenceAddedHasLocalCopyTrue () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "nunit.framework"); + referenceBeingRemoved.LocalCopy = true; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsTrue (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyFalse_ReferenceAddedHasLocalCopyFalse () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + firstReferenceBeingAdded.LocalCopy = true; + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_ReferenceBeingUpdatedHasLocalCopyFalseButCaseIsDifferent_ReferenceAddedHasLocalCopyFalse () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly"); + firstReferenceBeingAdded.LocalCopy = true; + var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework"); + packageManager.BeforeExecuteAction = () => { + var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "nunit.framework"); + referenceBeingRemoved.LocalCopy = false; + packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved); + packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded); + packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded); + }; + + action.Execute (); + + Assert.IsTrue (firstReferenceBeingAdded.LocalCopy); + Assert.IsFalse (secondReferenceBeingAdded.LocalCopy); + } + + [Test] + public void Execute_PackagesConfigFileNamedAfterProjectDeletedDuringUpdate_FileServicePackagesConfigFileDeletionIsCancelled () + { + CreateAction (); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + string expectedFileName = @"d:\projects\MyProject\packages.MyProject.config".ToNativePath (); + bool? fileRemovedResult = null; + packageManager.BeforeExecuteAction = () => { + fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName); + }; + action.Execute (); + + Assert.AreEqual (expectedFileName, fileRemover.FileRemoved); + Assert.IsFalse (fileRemovedResult.Value); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_OnAfterExecuteActionsIsCalled () + { + CreateAction ("Test"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (packageManager.UpdateActions, nugetProject.ActionsPassedToOnAfterExecuteActions); + } + + [Test] + public void Execute_NuGetProjectIsBuildIntegratedProject_PostProcessingIsRun () + { + CreateAction ("Test"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual (action.ProjectContext, nugetProject.PostProcessProjectContext); + } + + [Test] + public void Execute_PackageHasALicenseToBeAcceptedWhichIsAccepted_UserPromptedToAcceptLicenses () + { + CreateAction ("Test"); + action.LicenseAcceptanceService.AcceptLicensesReturnValue = true; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + + action.Execute (); + + var license = action.LicenseAcceptanceService.PackageLicensesAccepted.Single (); + Assert.AreEqual ("Test", license.PackageId); + Assert.AreEqual (metadata.LicenseUrl, license.LicenseUrl); + Assert.AreEqual (metadata.Authors, license.PackageAuthor); + Assert.AreEqual (metadata.Title, license.PackageTitle); + Assert.AreEqual ("Test", license.PackageIdentity.Id); + Assert.AreEqual ("1.2", license.PackageIdentity.Version.ToString ()); + } + + [Test] + public void Execute_PackageHasALicenseToBeAcceptedWhichIsNotAccepted_ExceptionThrown () + { + CreateAction ("Test"); + action.LicenseAcceptanceService.AcceptLicensesReturnValue = false; + AddInstallPackageIntoProjectAction ("Test", "1.2"); + var metadata = packageMetadataResource.AddPackageMetadata ("Test", "1.2"); + metadata.RequireLicenseAcceptance = true; + metadata.LicenseUrl = new Uri ("http://test.com/license"); + + Exception ex = Assert.Throws (typeof(AggregateException), () => action.Execute ()); + + Assert.AreEqual ("Licenses not accepted.", ex.GetBaseException ().Message); + } + + [Test] + public void Execute_NoActions_NoUpdateFoundEventFires () + { + CreateAction ("Test"); + IDotNetProject noUpdateFoundForProject = null; + packageManagementEvents.NoUpdateFound += (sender, e) => { + noUpdateFoundForProject = e.Project; + }; + + action.Execute (); + + Assert.AreEqual (project, noUpdateFoundForProject); + } + + [Test] + public void Execute_OneAction_NoUpdateFoundEventDoesNotFire () + { + CreateAction ("Test"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + IDotNetProject noUpdateFoundForProject = null; + packageManagementEvents.NoUpdateFound += (sender, e) => { + noUpdateFoundForProject = e.Project; + }; + + action.Execute (); + + Assert.IsNull (noUpdateFoundForProject); + } + + [Test] + public void Execute_NoActions_NoActionsExecuted () + { + CreateAction ("Test"); + IDotNetProject noUpdateFoundForProject = null; + packageManagementEvents.NoUpdateFound += (sender, e) => { + noUpdateFoundForProject = e.Project; + }; + + action.Execute (); + + Assert.IsNull (packageManager.ExecutedActions); + Assert.AreEqual (project, noUpdateFoundForProject); + } + + /// <summary> + /// Must call NuGetPackageManager.SetDirectInstall to ensure that any + /// readme.txt is opened for a package when it is updated. + /// </summary> + [Test] + public void Execute_PackageIdIsSet_DirectInstallSetAndCleared () + { + CreateAction ("Test"); + AddUninstallPackageFromProjectAction ("Test", "1.0"); + AddInstallPackageIntoProjectAction ("Test", "1.2"); + + action.Execute (); + + Assert.AreEqual ("Test", packageManager.SetDirectInstallPackageIdentity.Id); + Assert.AreEqual ("1.2", packageManager.SetDirectInstallPackageIdentity.Version.ToString ()); + Assert.AreEqual (action.ProjectContext, packageManager.SetDirectInstallProjectContext); + Assert.AreSame (action.ProjectContext, packageManager.ClearDirectInstallProjectContext); + } + + [Test] + public void Execute_ProjectJsonDoesNotUpdatePackage_NullReferenceNotThrownWhenSettingDirectInstall () + { + CreateAction ("Test"); + AddUninstallPackageFromProjectAction ("Test", "1.0"); + + Assert.DoesNotThrow (() => action.Execute ()); + + Assert.IsNull (packageManager.SetDirectInstallPackageIdentity); + } + } +} + 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 deleted file mode 100644 index df84c7bd79..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatePackageActionTests.cs +++ /dev/null @@ -1,678 +0,0 @@ -//
-// UpdatePackageActionTests.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 System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UpdatePackageActionTests
- {
- TestableUpdatePackageAction action;
- PackageManagementEvents packageManagementEvents;
- FakePackageManagementProject fakeProject;
- UpdatePackageHelper updatePackageHelper;
- FakeFileRemover fileRemover;
- List<PackageOperationMessage> messagesLogged;
- FakeFileService fileService;
-
- void CreateSolution ()
- {
- packageManagementEvents = new PackageManagementEvents ();
- fakeProject = new FakePackageManagementProject ();
- fileRemover = new FakeFileRemover ();
- action = new TestableUpdatePackageAction (fakeProject, packageManagementEvents, fileRemover);
- updatePackageHelper = new UpdatePackageHelper (action);
- }
-
- void AddInstallOperationWithFile (string fileName)
- {
- var package = new FakePackage ();
- package.AddFile (fileName);
-
- var operation = new PackageOperation (package, PackageAction.Install);
- var operations = new List<PackageOperation> ();
- operations.Add (operation);
-
- action.Operations = operations;
- }
-
- void RecordMessagesLogged ()
- {
- messagesLogged = new List<PackageOperationMessage> ();
- packageManagementEvents.PackageOperationMessageLogged += (sender, e) => messagesLogged.Add (e.Message);
- }
-
- void AssertMessageIsLogged (string expectedMessage)
- {
- List<string> messages = messagesLogged.Select (m => m.ToString ()).ToList ();
-
- 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 ()
- {
- CreateSolution ();
- updatePackageHelper.UpdateTestPackage ();
-
- FakePackage expectedPackage = updatePackageHelper.TestPackage;
- IPackage actualPackage = fakeProject.PackagePassedToUpdatePackage;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void UpdateDependencies_DefaultValue_ReturnsTrue ()
- {
- CreateSolution ();
- Assert.IsTrue (action.UpdateDependencies);
- }
-
- [Test]
- public void AllowPrereleaseVersions_DefaultValue_ReturnsFalse ()
- {
- CreateSolution ();
- Assert.IsFalse (action.AllowPrereleaseVersions);
- }
-
- [Test]
- public void Execute_PackageAndRepositoryPassed_PackageOperationsUsedToUpdatePackage ()
- {
- CreateSolution ();
- updatePackageHelper.UpdateTestPackage ();
-
- IEnumerable<PackageOperation> expectedOperations = updatePackageHelper.PackageOperations;
- IEnumerable<PackageOperation> actualOperations = fakeProject.PackageOperationsPassedToUpdatePackage;
-
- Assert.AreEqual (expectedOperations, actualOperations);
- }
-
- [Test]
- public void Execute_PackageAndRepositoryPassed_DependenciesUpdated ()
- {
- CreateSolution ();
- updatePackageHelper.UpdateDependencies = true;
- updatePackageHelper.UpdateTestPackage ();
-
- bool result = fakeProject.UpdateDependenciesPassedToUpdatePackage;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Execute_PackageAndRepositoryPassed_PrereleaseVersionsNotAllowed ()
- {
- CreateSolution ();
- updatePackageHelper.AllowPrereleaseVersions = false;
- updatePackageHelper.UpdateTestPackage ();
-
- bool result = fakeProject.AllowPrereleaseVersionsPassedToUpdatePackage;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_PackageAndRepositoryPassedAndAllowPrereleaseVersions_PrereleaseVersionsAllowed ()
- {
- CreateSolution ();
- updatePackageHelper.AllowPrereleaseVersions = true;
- updatePackageHelper.UpdateTestPackage ();
-
- bool result = fakeProject.AllowPrereleaseVersionsPassedToUpdatePackage;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Execute_PackageAndRepositoryPassedAndUpdateDependenciesIsFalse_DependenciesNotUpdated ()
- {
- CreateSolution ();
- updatePackageHelper.UpdateDependencies = false;
- updatePackageHelper.UpdateTestPackage ();
-
- bool result = fakeProject.UpdateDependenciesPassedToUpdatePackage;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_PackageAndRepositoryPassed_PackageInstalledEventIsFired ()
- {
- CreateSolution ();
- IPackage actualPackage = null;
- packageManagementEvents.ParentPackageInstalled += (sender, e) => {
- actualPackage = e.Package;
- };
- updatePackageHelper.UpdateTestPackage ();
-
- FakePackage expectedPackage = updatePackageHelper.TestPackage;
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackagePassedButNoPackageOperations_PackageOperationsRetrievedFromProject ()
- {
- CreateSolution ();
- updatePackageHelper.PackageOperations = null;
- updatePackageHelper.UpdateTestPackage ();
-
- IEnumerable<PackageOperation> actualOperations = action.Operations;
- List<FakePackageOperation> expectedOperations = fakeProject.FakeInstallOperations;
-
- Assert.AreEqual (expectedOperations, actualOperations);
- }
-
- [Test]
- public void Execute_PackagePassedButNoPackageOperations_PackageOperationsCreatedForPackage ()
- {
- CreateSolution ();
- updatePackageHelper.PackageOperations = null;
- updatePackageHelper.UpdateTestPackage ();
-
- var expectedPackage = updatePackageHelper.TestPackage;
- var actualPackage = fakeProject.PackagePassedToGetInstallPackageOperations;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackageIdAndSourceAndProjectPassedAndUpdateDependenciesIsTrue_DependenciesUpdatedWhenUpdatingPackage ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- updatePackageHelper.UpdateDependencies = true;
- updatePackageHelper.UpdatePackageById ("PackageId");
-
- bool result = fakeProject.UpdateDependenciesPassedToUpdatePackage;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Execute_PackageIdAndSourceAndProjectPassedAndUpdateDependenciesIsFalse_DependenciesNotUpdatedWhenGettingPackageOperations ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- updatePackageHelper.UpdateDependencies = false;
- updatePackageHelper.UpdatePackageById ("PackageId");
-
- bool result = fakeProject.UpdateDependenciesPassedToUpdatePackage;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_UpdatedDepdenciesIsFalseAndNoPackageOperations_DependenciesIgnoredWhenGettingPackageOperations ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- updatePackageHelper.UpdateDependencies = false;
- updatePackageHelper.UpdatePackageById ("PackageId");
-
- bool result = fakeProject.IgnoreDependenciesPassedToGetInstallPackageOperations;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Execute_UpdateDependenciesIsTrueAndNoPackageOperations_DependenciesNotIgnoredWhenGettingPackageOperations ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- updatePackageHelper.UpdateDependencies = true;
- updatePackageHelper.UpdatePackageById ("PackageId");
-
- bool result = fakeProject.IgnoreDependenciesPassedToGetInstallPackageOperations;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_AllowPrereleaseVersionsIsFalseAndNoPackageOperations_PrereleaseVersionsNotAllowedWhenGettingPackageOperations ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- updatePackageHelper.AllowPrereleaseVersions = false;
- updatePackageHelper.UpdatePackageById ("PackageId");
-
- bool result = fakeProject.AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- Assert.IsFalse (result);
- }
-
- [Test]
- public void Execute_AllowPrereleaseVersionsIsTrueAndNoPackageOperations_PrereleaseVersionsAllowedWhenGettingPackageOperations ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("PackageId");
- updatePackageHelper.AllowPrereleaseVersions = true;
- updatePackageHelper.UpdatePackageById ("PackageId");
-
- bool result = fakeProject.AllowPrereleaseVersionsPassedToGetInstallPackageOperations;
-
- Assert.IsTrue (result);
- }
-
- [Test]
- public void Execute_PackageAndPackageOperationsSet_OperationsNotRetrievedFromPackageManager ()
- {
- CreateSolution ();
- updatePackageHelper.UpdateTestPackage ();
-
- IPackage actualPackage = fakeProject.PackagePassedToGetInstallPackageOperations;
-
- Assert.IsNull (actualPackage);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasInitPowerShellScript_ReturnsTrue ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- AddInstallOperationWithFile (@"tools\init.ps1");
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsTrue (hasPackageScripts);
- }
-
- [Test]
- public void HasPackageScriptsToRun_OnePackageInOperationsHasNoFiles_ReturnsFalse ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("Test");
- action.PackageId = "Test";
- action.Operations = new List<PackageOperation> ();
-
- bool hasPackageScripts = action.HasPackageScriptsToRun ();
-
- Assert.IsFalse (hasPackageScripts);
- }
-
- [Test]
- public void UpdateIfPackageDoesNotExistInProject_NewUpdateActionInstanceCreate_ReturnsTrue ()
- {
- CreateSolution ();
- bool update = action.UpdateIfPackageDoesNotExistInProject;
-
- Assert.IsTrue (update);
- }
-
- [Test]
- public void Execute_UpdateIfPackageDoesNotExistInProjectSetToFalseAndPackageDoesNotExistInProject_PackageIsNotUpdated ()
- {
- CreateSolution ();
- action.Package = new FakePackage ("Test");
- action.UpdateIfPackageDoesNotExistInProject = false;
- action.Execute ();
-
- bool updated = fakeProject.IsUpdatePackageCalled;
-
- Assert.IsFalse (updated);
- }
-
- [Test]
- public void Execute_UpdateIfPackageDoesNotExistInProjectSetToFalseAndPackageDoesNotExistInProject_PackageInstalledEventIsNotFired ()
- {
- CreateSolution ();
- bool updated = false;
- packageManagementEvents.ParentPackageInstalled += (sender, e) => updated = true;
- action.UpdateIfPackageDoesNotExistInProject = false;
-
- updatePackageHelper.UpdateTestPackage ();
-
- Assert.IsFalse (updated);
- }
-
- [Test]
- public void Execute_UpdateIfPackageDoesNotExistInProjectSetToFalseAndPackageExistsInProject_PackageIsUpdated ()
- {
- CreateSolution ();
- action.UpdateIfPackageDoesNotExistInProject = false;
- action.PackageId = "Test";
- FakePackage expectedPackage = fakeProject.FakeSourceRepository.AddFakePackageWithVersion ("Test", "1.1");
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Execute ();
-
- IPackage actualPackage = fakeProject.PackagePassedToUpdatePackage;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackagePassedAndUpdateIfPackageDoesNotExistInProjectSetToFalseAndPackageExistsInProject_PackageIsUpdated ()
- {
- CreateSolution ();
- action.UpdateIfPackageDoesNotExistInProject = false;
- var expectedPackage = new FakePackage ("Test", "1.1");
- action.Package = expectedPackage;
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Execute ();
-
- IPackage actualPackage = fakeProject.PackagePassedToUpdatePackage;
-
- Assert.AreEqual (expectedPackage, actualPackage);
- }
-
- [Test]
- public void Execute_PackagesConfigFileDeletedDuringUpdate_FileServicePackagesConfigFileDeletionIsCancelled ()
- {
- CreateSolution ();
- action.Package = new FakePackage ("Test");
- string expectedFileName = @"d:\projects\MyProject\packages.config".ToNativePath ();
- bool? fileRemovedResult = null;
- fakeProject.UpdatePackageAction = (p, a) => {
- fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName);
- };
- action.Execute ();
-
- Assert.AreEqual (expectedFileName, fileRemover.FileRemoved);
- Assert.IsFalse (fileRemovedResult.Value);
- }
-
- [Test]
- public void Execute_ScriptFileDeletedDuringUpdate_FileDeletionIsNotCancelled ()
- {
- CreateSolution ();
- action.Package = new FakePackage ("Test");
- string fileName = @"d:\projects\MyProject\scripts\myscript.js".ToNativePath ();
- bool? fileRemovedResult = null;
- fakeProject.UpdatePackageAction = (p, a) => {
- fileRemovedResult = packageManagementEvents.OnFileRemoving (fileName);
- };
- action.Execute ();
-
- Assert.IsTrue (fileRemovedResult.Value);
- Assert.IsNull (fileRemover.FileRemoved);
- }
-
- [Test]
- public void Execute_PackageHasConstraint_LatestPackageIsNotUpdatedButPackageWithHighestVersionThatMatchesConstraint ()
- {
- CreateSolution ();
- var constraintProvider = new DefaultConstraintProvider ();
- var versionSpec = new VersionSpec ();
- versionSpec.MinVersion = new SemanticVersion ("1.0");
- versionSpec.IsMinInclusive = true;
- versionSpec.IsMaxInclusive = true;
- versionSpec.MaxVersion = new SemanticVersion ("2.0");
- constraintProvider.AddConstraint ("MyPackage", versionSpec);
- fakeProject.ConstraintProvider = constraintProvider;
- fakeProject.AddFakePackageToSourceRepository ("MyPackage", "1.0");
- FakePackage packageVersion2 = fakeProject.AddFakePackageToSourceRepository ("MyPackage", "2.0");
- fakeProject.AddFakePackageToSourceRepository ("MyPackage", "3.0");
- fakeProject.FakePackages.Add (new FakePackage ("MyPackage", "1.0"));
- action.PackageId = "MyPackage";
-
- action.Execute ();
-
- Assert.AreEqual (packageVersion2, fakeProject.PackagePassedToUpdatePackage);
- }
-
- [Test]
- public void Execute_NewerPrereleaseInstalledAndTryToUpdateToOlderStableRelease_UpdateIsNotInstalled ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("MyPackage", "1.2");
- fakeProject.FakePackages.Add (new FakePackage ("MyPackage", "1.3.0.6275-pre1"));
- action.PackageId = "MyPackage";
- fakeProject.Name = "MyProject";
- action.UpdateIfPackageDoesNotExistInProject = false;
- RecordMessagesLogged ();
-
- action.Execute ();
-
- Assert.IsNull (fakeProject.PackagePassedToUpdatePackage);
- Assert.IsFalse (fakeProject.IsUpdatePackageCalled);
- AssertMessageIsLogged ("No updates available for 'MyPackage' in project 'MyProject'.");
- }
-
- [Test]
- public void Execute_NewerPrereleaseInstalledAndTryToUpdateToOlderStableReleaseAndUpdateIfPackageDoesNotExistInProject_UpdateIsNotInstalled ()
- {
- CreateSolution ();
- fakeProject.AddFakePackageToSourceRepository ("MyPackage", "1.2");
- fakeProject.FakePackages.Add (new FakePackage ("MyPackage", "1.3.0.6275-pre1"));
- action.PackageId = "MyPackage";
- fakeProject.Name = "MyProject";
- action.UpdateIfPackageDoesNotExistInProject = true;
- RecordMessagesLogged ();
-
- action.Execute ();
-
- Assert.IsNull (fakeProject.PackagePassedToUpdatePackage);
- Assert.IsFalse (fakeProject.IsUpdatePackageCalled);
- AssertMessageIsLogged ("No updates available for 'MyPackage' in project 'MyProject'.");
- }
-
- [Test]
- public void Execute_ReferenceBeingUpdatedHasLocalCopyTrue_ReferenceAddedHasLocalCopyTrue ()
- {
- CreateSolution ();
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Package = new FakePackage ("Test", "1.1");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- fakeProject.UpdatePackageAction = (p, a) => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- referenceBeingRemoved.LocalCopy = true;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsTrue (secondReferenceBeingAdded.LocalCopy);
- }
-
- [Test]
- public void Execute_ReferenceBeingUpdatedHasLocalCopyTrueButCaseIsDifferent_ReferenceAddedHasLocalCopyTrue ()
- {
- CreateSolution ();
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Package = new FakePackage ("Test", "1.1");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- fakeProject.UpdatePackageAction = (p, a) => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "nunit.framework");
- referenceBeingRemoved.LocalCopy = true;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsTrue (secondReferenceBeingAdded.LocalCopy);
- }
-
- [Test]
- public void Execute_ReferenceBeingUpdatedHasLocalCopyFalse_ReferenceAddedHasLocalCopyFalse ()
- {
- CreateSolution ();
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Package = new FakePackage ("Test", "1.1");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- firstReferenceBeingAdded.LocalCopy = true;
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- fakeProject.UpdatePackageAction = (p, a) => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- referenceBeingRemoved.LocalCopy = false;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsFalse (secondReferenceBeingAdded.LocalCopy);
- }
-
- [Test]
- public void Execute_ReferenceBeingUpdatedHasLocalCopyFalseButCaseIsDifferent_ReferenceAddedHasLocalCopyFalse ()
- {
- CreateSolution ();
- fakeProject.FakePackages.Add (new FakePackage ("Test", "1.0"));
- action.Package = new FakePackage ("Test", "1.1");
- var firstReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NewAssembly");
- firstReferenceBeingAdded.LocalCopy = true;
- var secondReferenceBeingAdded = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "NUnit.Framework");
- fakeProject.UpdatePackageAction = (p, a) => {
- var referenceBeingRemoved = ProjectReference.CreateCustomReference (ReferenceType.Assembly, "nunit.framework");
- referenceBeingRemoved.LocalCopy = false;
- packageManagementEvents.OnReferenceRemoving (referenceBeingRemoved);
- packageManagementEvents.OnReferenceAdding (firstReferenceBeingAdded);
- packageManagementEvents.OnReferenceAdding (secondReferenceBeingAdded);
- };
- action.Execute ();
-
- Assert.IsTrue (firstReferenceBeingAdded.LocalCopy);
- Assert.IsFalse (secondReferenceBeingAdded.LocalCopy);
- }
-
- [Test]
- public void Execute_PackageUpdatedSuccessfully_OpenPackageReadmeMonitorCreated ()
- {
- CreateSolution ();
- updatePackageHelper.TestPackage.Id = "Test";
- updatePackageHelper.UpdateTestPackage ();
-
- 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);
- }
-
- [Test]
- public void Execute_PackagesConfigFileNamedAfterProjectDeletedDuringUpdate_FileServicePackagesConfigFileDeletionIsCancelled ()
- {
- CreateSolution ();
- action.Package = new FakePackage ("Test");
- string expectedFileName = @"d:\projects\MyProject\packages.MyProject.config".ToNativePath ();
- bool? fileRemovedResult = null;
- fakeProject.UpdatePackageAction = (p, a) => {
- fileRemovedResult = packageManagementEvents.OnFileRemoving (expectedFileName);
- };
- action.Execute ();
-
- Assert.AreEqual (expectedFileName, fileRemover.FileRemoved);
- Assert.IsFalse (fileRemovedResult.Value);
- }
-
- [Test]
- public void NewInstance_LicensesMustBeAccepted_TrueByDefault ()
- {
- CreateSolution ();
-
- Assert.IsTrue (action.LicensesMustBeAccepted);
- }
-
- [Test]
- public void Execute_UpdateIfPackageDoesNotExistInProjectSetToFalseAndPackageDoesNotExistInProjectAndPackageRequiresLicenseAcceptance_PackageLicenseAcceptanceIsNotRequested ()
- {
- CreateSolution ();
- var package = new FakePackage ("Test") {
- RequireLicenseAcceptance = true
- };
- action.Package = package;
- var operation = new FakePackageOperation (package, PackageAction.Install);
- action.PackageId = package.Id;
- action.PackageVersion = package.Version;
- fakeProject.FakeInstallOperations.Add (operation);
- action.UpdateIfPackageDoesNotExistInProject = false;
- action.Execute ();
-
- bool updated = fakeProject.IsUpdatePackageCalled;
-
- Assert.IsFalse (updated);
- Assert.IsNull (action.LicenseAcceptanceService.PackagesAccepted);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedNuGetPackagesInWorkspaceTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedNuGetPackagesInWorkspaceTests.cs new file mode 100644 index 0000000000..0da7828430 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedNuGetPackagesInWorkspaceTests.cs @@ -0,0 +1,529 @@ +// +// UpdatedNuGetPackagesInWorkspace.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Linq; +using System.Threading.Tasks; +using MonoDevelop.PackageManagement.Tests.Helpers; +using NuGet.Configuration; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; +using NUnit.Framework; + +namespace MonoDevelop.PackageManagement.Tests +{ + [TestFixture] + public class UpdatedNuGetPackagesInWorkspaceTests + { + TestableUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace; + TestableCheckForNuGetPackageUpdatesTaskRunner taskRunner; + IPackageManagementEvents packageManagementEvents; + FakeSolution solution; + FakeDotNetProject dotNetProject; + FakePackageMetadataResource packageMetadataResource; + + void CreateUpdatedPackagesInWorkspace () + { + updatedPackagesInWorkspace = new TestableUpdatedNuGetPackagesInWorkspace (); + taskRunner = updatedPackagesInWorkspace.TaskRunner; + packageManagementEvents = updatedPackagesInWorkspace.PackageManagementEvents; + solution = new FakeSolution (); + + var metadataResourceProvider = new FakePackageMetadataResourceProvider (); + packageMetadataResource = metadataResourceProvider.PackageMetadataResource; + var source = new PackageSource ("http://test.com"); + var providers = new INuGetResourceProvider[] { + metadataResourceProvider + }; + var sourceRepository = new SourceRepository (source, providers); + taskRunner.SolutionManager.SourceRepositoryProvider.Repositories.Add (sourceRepository); + } + + SourceRepository CreateExceptionThrowingSourceRepository (Exception ex) + { + var metadataResourceProvider = new FakePackageMetadataResourceProvider (); + var metadataResource = new ExceptionThrowingPackageMetadataResource (ex); + metadataResourceProvider.PackageMetadataResource = metadataResource; + var source = new PackageSource ("http://test.com"); + var providers = new INuGetResourceProvider[] { + metadataResourceProvider + }; + return new SourceRepository (source, providers); + } + + FakeNuGetProject AddNuGetProjectToSolution () + { + dotNetProject = new FakeDotNetProject (); + solution.Projects.Add (dotNetProject); + return taskRunner.AddNuGetProject (dotNetProject); + } + + Task CheckForUpdates () + { + updatedPackagesInWorkspace.CheckForUpdates (solution); + return taskRunner.CheckForUpdatesTask; + } + + [Test] + public async Task CheckForUpdates_OnePackageUpdated_OneUpdatedPackageFoundForProject () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.2"); + var updatedPackage = packageMetadataResource.AddPackageMetadata ("MyPackage", "1.2").Identity; + var expectedPackages = new [] { + updatedPackage + }; + + await CheckForUpdates (); + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + Assert.AreEqual (project.Project, updatedPackages.Project); + Assert.IsNotNull (updatedPackages.Project); + CollectionAssert.AreEqual (expectedPackages, updatedPackages.GetPackages ()); + } + + [Test] + public async Task CheckForUpdates_NoPackagesUpdated_DoesNotReturnNullUpdatedPackagesForProject () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + + await CheckForUpdates (); + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + Assert.AreEqual (project.Project, updatedPackages.Project); + Assert.IsNotNull (updatedPackages.Project); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task Clear_OnePackageUpdatedButEverythingCleared_NoUpdatedPackagesFoundForProject () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + await CheckForUpdates (); + + updatedPackagesInWorkspace.Clear (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + Assert.AreEqual (project.Project, updatedPackages.Project); + Assert.IsNotNull (updatedPackages.Project); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task CheckForUpdates_OnePackageUpdated_UpdatedPackagesAvailableEventIsFired () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + bool updatesAvailableEventFired = false; + packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { + updatesAvailableEventFired = true; + }; + + await CheckForUpdates (); + + Assert.IsTrue (updatesAvailableEventFired); + } + + [Test] + public async Task CheckForUpdates_NoPackagesUpdated_UpdatedPackagesAvailableEventIsNotFired () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + bool fired = false; + packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { + fired = true; + }; + + await CheckForUpdates (); + + Assert.IsFalse (fired); + } + + [Test] + public async Task GetUpdatedPackages_OnePackageUpdatedSameUnderlyingDotNetProjectButDifferentProxy_OneUpdatedPackageFoundForProject () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + var updatedPackage = packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1").Identity; + var expectedPackages = new [] { updatedPackage }; + var newProject = new FakeDotNetProject (); + dotNetProject.EqualsAction = p => { + return p == newProject; + }; + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (newProject); + + Assert.IsNotNull (updatedPackages.Project); + CollectionAssert.AreEqual (expectedPackages, updatedPackages.GetPackages ()); + Assert.AreNotEqual (newProject, updatedPackages.Project); + } + + [Test] + public async Task RemoveUpdatedPackages_OnePackageUpdatedAndPackageUpdateIsInstalled_NoUpdatesAvailable () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + await CheckForUpdates (); + project.InstalledPackages.Clear (); + project.AddPackageReference ("MyPackage", "1.1"); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + int updatedPackagesCountBeforeUpdating = updatedPackages.GetPackages ().Count (); + updatedPackages.RemoveUpdatedPackages (project.InstalledPackages); + + Assert.AreEqual (1, updatedPackagesCountBeforeUpdating); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task GetUpdatedPackages_OnePackageUpdatedAndPackageIsUninstalled_NoUpdatesAvailableForUninstalledPackage () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + await CheckForUpdates (); + project.InstalledPackages.Clear (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + int updatedPackagesCountBeforeUpdating = updatedPackages.GetPackages ().Count (); + updatedPackages.RemoveUpdatedPackages (project.InstalledPackages); + + Assert.AreEqual (1, updatedPackagesCountBeforeUpdating); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task GetUpdatedPackages_TwoPackagesInstalledOneUpdatedAndUpdatesAvailableForBoth_OneUpdateAvailable () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("One", "1.0"); + project.AddPackageReference ("Two", "1.0"); + packageMetadataResource.AddPackageMetadata ("One", "1.1"); + packageMetadataResource.AddPackageMetadata ("Two", "1.1"); + await CheckForUpdates (); + project.InstalledPackages.Clear (); + project.AddPackageReference ("One", "1.1"); + project.AddPackageReference ("Two", "1.0"); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + int updatedPackagesCountBeforeUpdating = updatedPackages.GetPackages ().Count (); + updatedPackages.RemoveUpdatedPackages (project.InstalledPackages); + + Assert.AreEqual (2, updatedPackagesCountBeforeUpdating); + Assert.AreEqual (1, updatedPackages.GetPackages ().Count ()); + Assert.AreEqual ("Two", updatedPackages.GetPackages ().FirstOrDefault ().Id); + } + + [Test] + public async Task GetUpdatedPackages_TwoPackagesInstalledOneUpdatedWhichUpdatesItsDependency_NoUpdatesAvailable () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("One", "1.0"); + project.AddPackageReference ("Two", "1.0"); + packageMetadataResource.AddPackageMetadata ("One", "1.1"); + packageMetadataResource.AddPackageMetadata ("Two", "1.1"); + await CheckForUpdates (); + project.InstalledPackages.Clear (); + project.AddPackageReference ("One", "1.1"); + project.AddPackageReference ("Two", "1.1"); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + int updatedPackagesCountBeforeUpdating = updatedPackages.GetPackages ().Count (); + updatedPackages.RemoveUpdatedPackages (project.InstalledPackages); + + Assert.AreEqual (2, updatedPackagesCountBeforeUpdating); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task CheckForUpdates_OnePackageUpdatedButSolutionClosedBeforeResultsReturned_UpdatedPackagesAvailableEventIsNotFiredAndNoPackageUpdatesAvailable () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + bool fired = false; + packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { + fired = true; + }; + taskRunner.AfterCheckForUpdatesAction = () => { + updatedPackagesInWorkspace.Clear (); + }; + await CheckForUpdates (); + + Assert.IsFalse (fired); + Assert.IsFalse (updatedPackagesInWorkspace.AnyUpdates ()); + } + + [Test] + public async Task CheckForUpdates_NoPackagesUpdated_NoUpdates () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + + await CheckForUpdates (); + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + Assert.IsFalse (updatedPackagesInWorkspace.AnyUpdates ()); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task CheckForUpdates_OnePackageUpdatedAndSolutionClosedBeforeResultsReturnedAndThenSolutionOpenedAgain_UpdatedPackagesAvailableEventIsFiredForSecondOpeningOfSolution () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + bool fired = false; + packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => { + fired = true; + }; + taskRunner.AfterCheckForUpdatesAction = () => { + updatedPackagesInWorkspace.Clear (); + }; + await CheckForUpdates (); + Assert.IsFalse (fired); + taskRunner.AfterCheckForUpdatesAction = () => { }; + await CheckForUpdates (); + + Assert.IsTrue (updatedPackagesInWorkspace.AnyUpdates ()); + Assert.IsTrue (fired); + } + + [Test] + public async Task GetUpdatedPackages_OnePackageHasUpdatesAndNewerVersionButNotLatestIsInstalled_UpdatesStillShowAsAvailable () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.9"); + await CheckForUpdates (); + project.InstalledPackages.Clear (); + project.AddPackageReference ("MyPackage", "1.1"); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + updatedPackages.RemoveUpdatedPackages (project.InstalledPackages); + + Assert.AreEqual (1, updatedPackages.GetPackages ().Count ()); + Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id); + Assert.AreEqual ("1.9", updatedPackages.GetPackages ().First ().Version.ToString ()); + } + + [Test] + public async Task CheckForUpdates_ProjectHasPreReleasePackageWhichHasUpdatedPrereleasePackage_OnePrereleaseUpdateFound () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0.1-alpha"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.0.1-beta"); + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + Assert.AreEqual (1, updatedPackages.GetPackages ().Count ()); + Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id); + Assert.AreEqual ("1.0.1-beta", updatedPackages.GetPackages ().First ().Version.ToString ()); + } + + [Test] + public async Task CheckForUpdates_ProjectHasPreReleasePackageWhichHasUpdatedStablePackage_OneStableUpdateFound () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0.1-alpha"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.0.1"); + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + Assert.AreEqual (1, updatedPackages.GetPackages ().Count ()); + Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id); + Assert.AreEqual ("1.0.1", updatedPackages.GetPackages ().First ().Version.ToString ()); + } + + [Test] + public async Task CheckForUpdates_ProjectHasStableAndPreReleasePackagesBothWithUpdatese_TwoUpdatesFound () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0.1-alpha"); + project.AddPackageReference ("AnotherPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.0.1-beta"); + packageMetadataResource.AddPackageMetadata ("AnotherPackage", "1.1"); + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + var anotherPackageUpdate = updatedPackages.GetPackages ().FirstOrDefault (p => p.Id == "AnotherPackage"); + var myPackageUpdate = updatedPackages.GetPackages ().FirstOrDefault (p => p.Id == "MyPackage"); + Assert.AreEqual (2, updatedPackages.GetPackages ().Count ()); + Assert.IsNotNull (anotherPackageUpdate); + Assert.AreEqual ("1.1", anotherPackageUpdate.Version.ToString ()); + Assert.IsNotNull (myPackageUpdate); + Assert.AreEqual ("1.0.1-beta", myPackageUpdate.Version.ToString ()); + } + + [Test] + public async Task CheckForUpdates_ProjectHasStablePackageWhichHasUpdatedPrereleasePackage_NoUpdatesFound () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0.1"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1.0-alpha"); + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (project.Project); + + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task GetUpdatedPackages_UpdatingThreeOldAndroidPackagesInstallsOneAndUpdatesOneAndRemovesOneWithOneInstall_NoUpdatesRemain () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("Xamarin.Android.Support.v13", "20.0.0.4"); + project.AddPackageReference ("Xamarin.Android.Support.v4", "20.0.0.4"); + project.AddPackageReference ("Xamarin.Android.Support.v7.AppCompat", "20.0.0.2"); + packageMetadataResource.AddPackageMetadata ("Xamarin.Android.Support.v13", "23.1.1.0"); + packageMetadataResource.AddPackageMetadata ("Xamarin.Android.Support.v4", "23.1.1.0"); + packageMetadataResource.AddPackageMetadata ("Xamarin.Android.Support.v7.AppCompat", "23.1.1.0"); + await CheckForUpdates (); + int originalUpdatesAvailable = updatedPackagesInWorkspace + .GetUpdatedPackages (project.Project) + .GetPackages () + .Count (); + project.InstalledPackages.Clear (); + project.AddPackageReference ("Xamarin.Android.Support.v4", "23.1.1.0"); + project.AddPackageReference ("Xamarin.Android.Support.v7.AppCompat", "23.1.1.0"); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (project.Project); + updatedPackages.RemoveUpdatedPackages (project.InstalledPackages); + + Assert.AreEqual (3, originalUpdatesAvailable); + Assert.AreEqual (0, updatedPackages.GetPackages ().Count ()); + } + + [Test] + public async Task GetUpdatedPackages_SecondSolutionOpenedWhilstCheckingForUpdatesForFirstSolution_UpdatesFoundForProjectsInBothSolutions () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + packageMetadataResource.AddPackageMetadata ("AnotherPackage", "1.2"); + var firstDotNetProject = dotNetProject; + FakeDotNetProject secondDotNetProject = null; + taskRunner.AfterCheckForUpdatesAction = () => { + if (secondDotNetProject == null) { + solution = new FakeSolution (); + FakeNuGetProject anotherProject = AddNuGetProjectToSolution (); + anotherProject.AddPackageReference ("AnotherPackage", "0.1"); + secondDotNetProject = dotNetProject; + updatedPackagesInWorkspace.CheckForUpdates (solution); + } + }; + await CheckForUpdates (); + // Wait for second solution checks. + await taskRunner.CheckForUpdatesTask; + + var updatedPackagesForProjectInFirstSolution = updatedPackagesInWorkspace.GetUpdatedPackages (firstDotNetProject); + var updatedPackagesForProjectInSecondSolution = updatedPackagesInWorkspace.GetUpdatedPackages (secondDotNetProject); + + Assert.AreEqual (1, updatedPackagesForProjectInFirstSolution.GetPackages ().Count ()); + Assert.AreEqual ("MyPackage", updatedPackagesForProjectInFirstSolution.GetPackages ().First ().Id); + Assert.AreEqual ("1.1", updatedPackagesForProjectInFirstSolution.GetPackages ().First ().Version.ToString ()); + Assert.AreEqual (1, updatedPackagesForProjectInSecondSolution.GetPackages ().Count ()); + Assert.AreEqual ("AnotherPackage", updatedPackagesForProjectInSecondSolution.GetPackages ().First ().Id); + Assert.AreEqual ("1.2", updatedPackagesForProjectInSecondSolution.GetPackages ().First ().Version.ToString ()); + } + + [Test] + public async Task GetUpdatedPackages_OnePackageReferencedWithConstraintAndUpdatesAvailable_LatestVersionReturnedBasedOnConstraint () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + var versionRange = new VersionRange ( + minVersion: new NuGetVersion ("1.0"), + includeMinVersion: true, + maxVersion: new NuGetVersion ("2.0"), + includeMaxVersion: true); + project.AddPackageReference ("Test", "1.0", versionRange); + var package = packageMetadataResource.AddPackageMetadata ("Test", "2.0").Identity; + packageMetadataResource.AddPackageMetadata ("Test", "3.0"); + var expectedPackages = new [] { + package + }; + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + CollectionAssert.AreEqual (expectedPackages, updatedPackages.GetPackages ()); + } + + [Test] + public async Task CheckForUpdates_TwoSourceRepositoriesAndFirstOneThrowsException_UpdatedPackageFoundFromNonFailingSourceRepository () + { + CreateUpdatedPackagesInWorkspace (); + FakeNuGetProject project = AddNuGetProjectToSolution (); + project.AddPackageReference ("MyPackage", "1.0"); + packageMetadataResource.AddPackageMetadata ("MyPackage", "1.1"); + var ex = new ApplicationException ("Error"); + var sourceRepository = CreateExceptionThrowingSourceRepository (ex); + taskRunner.SolutionManager.SourceRepositoryProvider.Repositories.Insert (0, sourceRepository); + + await CheckForUpdates (); + + var updatedPackages = updatedPackagesInWorkspace.GetUpdatedPackages (dotNetProject); + + var package = updatedPackages.GetPackages ().Single (); + Assert.AreEqual ("MyPackage", package.Id); + Assert.AreEqual ("1.1", package.Version.ToString ()); + } + } +} + 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 deleted file mode 100644 index 0a0a83eed6..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesInSolutionTests.cs +++ /dev/null @@ -1,690 +0,0 @@ -//
-// UpdatedPackagesInSolutionTests.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UpdatedPackagesInSolutionTests
- {
- TestableUpdatedPackagesInSolution updatedPackagesInSolution;
- FakePackageManagementSolution solution;
- FakeRegisteredPackageRepositories registeredPackageRepositories;
- PackageManagementEvents packageManagementEvents;
- FakeTaskFactory taskFactory;
- FakeProgressMonitorFactory progressMonitorFactory;
- TestableCheckForUpdatesTaskRunner checkForUpdatesTaskRunner;
- List<string> messagesLogged;
-
- void CreateUpdatedPackagesInSolution ()
- {
- solution = new FakePackageManagementSolution ();
- registeredPackageRepositories = new FakeRegisteredPackageRepositories ();
- packageManagementEvents = new PackageManagementEvents ();
- taskFactory = new FakeTaskFactory ();
- taskFactory.RunTasksSynchronously = true;
- progressMonitorFactory = new FakeProgressMonitorFactory ();
- checkForUpdatesTaskRunner = new TestableCheckForUpdatesTaskRunner (taskFactory);
- updatedPackagesInSolution = new TestableUpdatedPackagesInSolution (
- solution,
- registeredPackageRepositories,
- packageManagementEvents,
- checkForUpdatesTaskRunner);
- }
-
- FakePackageManagementProject AddProjectToSolution ()
- {
- var project = new FakePackageManagementProject ();
- project.FakeSourceRepository = registeredPackageRepositories.FakeAggregateRepository;
- solution.FakeProjects.Add (project);
- return project;
- }
-
- FakePackage AddUpdatedPackageToAggregateSourceRepository (string id, string version)
- {
- return registeredPackageRepositories.FakeAggregateRepository.AddFakePackageWithVersion (id, version);
- }
-
- void CaptureMessagesLogged ()
- {
- messagesLogged = new List<string> ();
- packageManagementEvents.PackageOperationMessageLogged += (sender, e) => {
- messagesLogged.Add (e.Message.ToString ());
- };
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdated_OneUpdatedPackageFoundForProject ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- var expectedPackages = new FakePackage [] { updatedPackage };
-
- updatedPackagesInSolution.CheckForUpdates ();
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (project.Project, updatedPackages.Project);
- Assert.IsNotNull (updatedPackages.Project);
- CollectionAssert.AreEqual (expectedPackages, updatedPackages.GetPackages ());
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdated_AggregateRepositoryUsedWhenCheckingForUpdates ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
-
- updatedPackagesInSolution.CheckForUpdates ();
- updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (registeredPackageRepositories.FakeAggregateRepository, solution.SourceRepositoryPassedToGetProjects);
- }
-
- [Test]
- public void CheckForUpdates_NoPackagesUpdated_DoesNotReturnNullUpdatedPackagesForProject ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
-
- updatedPackagesInSolution.CheckForUpdates ();
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (project.Project, updatedPackages.Project);
- Assert.IsNotNull (updatedPackages.Project);
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void Clear_OnePackageUpdatedButEverythingCleared_NoUpdatedPackagesFoundForProject ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
-
- updatedPackagesInSolution.Clear ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (project.Project, updatedPackages.Project);
- Assert.IsNotNull (updatedPackages.Project);
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdated_UpdatedPackagesAvailableEventIsFired ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- bool fired = false;
- packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => {
- fired = true;
- };
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void CheckForUpdates_NoPackagesUpdated_UpdatedPackagesAvailableEventIsNotFired ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- updatedPackagesInSolution.CheckForUpdates ();
- bool fired = false;
- packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => {
- fired = true;
- };
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.IsFalse (fired);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageUpdatedSameUnderlyingDotNetProjectButDifferentProxy_OneUpdatedPackageFoundForProject ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- var expectedPackages = new FakePackage [] { updatedPackage };
- var newProject = new FakeDotNetProject ();
- project.FakeDotNetProject.EqualsAction = p => {
- return p == newProject;
- };
- updatedPackagesInSolution.CheckForUpdates ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (newProject);
-
- Assert.IsNotNull (updatedPackages.Project);
- CollectionAssert.AreEqual (expectedPackages, updatedPackages.GetPackages ());
- Assert.AreNotEqual (newProject, updatedPackages.Project);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageUpdatedAndPackageUpdateIsInstalled_NoUpdatesAvailable ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("MyPackage", "1.1");
- packageManagementEvents.OnParentPackageInstalled (updatedPackage, project);
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void CheckForUpdates_TwoProjectsAndNoPackagesUpdated_CheckingProjectMessageIsLogged ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project1 = AddProjectToSolution ();
- project1.Name = "MyProject1";
- project1.AddFakePackage ("MyPackage", "1.0");
- FakePackageManagementProject project2 = AddProjectToSolution ();
- project2.Name = "MyProject2";
- updatedPackagesInSolution.CheckForUpdates ();
- CaptureMessagesLogged ();
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.That (messagesLogged, Contains.Item ("Checking MyProject1 for updates..."));
- Assert.That (messagesLogged, Contains.Item ("Checking MyProject2 for updates..."));
- Assert.That (messagesLogged, Contains.Item ("0 updates found."));
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdated_OneFoundMessageLogged ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- CaptureMessagesLogged ();
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.That (messagesLogged, Contains.Item ("1 update found."));
- }
-
- [Test]
- public void CheckForUpdates_TwoPackagesUpdated_TwoUpdatesFoundMessageLogged ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("One", "1.0");
- project.AddPackageReference ("Two", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("One", "1.1");
- AddUpdatedPackageToAggregateSourceRepository ("Two", "1.4");
- CaptureMessagesLogged ();
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.That (messagesLogged, Contains.Item ("2 updates found."));
- }
-
- [Test]
- public void CheckForUpdates_ProjectHasNoPackagesConfigFile_NoProjectsCheckedForUpdates ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- string expectedPackagesConfigFileName = @"d:\projects\MyProject\packages.config".ToNativePath ();
- string fileChecked = null;
- updatedPackagesInSolution.FileExistsAction = path => {
- fileChecked = path;
- return false;
- };
- project.FakeDotNetProject.BaseDirectory = @"d:\projects\MyProject".ToNativePath ();
- CaptureMessagesLogged ();
-
- updatedPackagesInSolution.CheckForUpdates ();
-
- Assert.AreEqual (0, messagesLogged.Count);
- Assert.AreEqual (expectedPackagesConfigFileName, fileChecked);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageUpdatedAndPackageIsUninstalled_NoUpdatesAvailableForUninstalledPackage ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- var package = FakePackage.CreatePackageWithVersion ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- project.PackageReferences.Clear ();
- packageManagementEvents.OnParentPackageUninstalled (package, project);
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void CheckForUpdates_NoPackagesUpdated_LoggerConfiguredForProject ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
-
- updatedPackagesInSolution.CheckForUpdates ();
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.IsInstanceOf<PackageManagementLogger> (project.Logger);
- }
-
- [Test]
- public void GetUpdatedPackages_TwoPackagesInstalledOneUpdatedAndUpdatesAvailableForBoth_OneUpdateAvailable ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("One", "1.0");
- project.AddPackageReference ("Two", "1.0");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("One", "1.1");
- AddUpdatedPackageToAggregateSourceRepository ("Two", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("One", "1.1");
- project.AddPackageReference ("Two", "1.0");
- packageManagementEvents.OnParentPackageInstalled (updatedPackage, project);
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (1, updatedPackages.GetPackages ().Count ());
- Assert.AreEqual ("Two", updatedPackages.GetPackages ().FirstOrDefault ().Id);
- }
-
- [Test]
- public void GetUpdatedPackages_TwoPackagesInstalledOneUpdatedWhichUpdatesItsDependency_NoUpdatesAvailable ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("One", "1.0");
- project.AddPackageReference ("Two", "1.0");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("One", "1.1");
- AddUpdatedPackageToAggregateSourceRepository ("Two", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("One", "1.1");
- project.AddPackageReference ("Two", "1.1");
- packageManagementEvents.OnParentPackageInstalled (updatedPackage, project);
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdatedButSolutionClosedBeforeResultsReturned_UpdatedPackagesAvailableEventIsNotFiredAndNoPackageUpdatesAvailable ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- bool fired = false;
- packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => {
- fired = true;
- };
- updatedPackagesInSolution.CheckForUpdates ();
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.ExecuteTaskButNotContinueWith ();
- updatedPackagesInSolution.Clear ();
-
- task.ExecuteContinueWith ();
-
- Assert.IsFalse (fired);
- Assert.IsFalse (updatedPackagesInSolution.AnyUpdates ());
- }
-
- [Test]
- public void CheckForUpdates_NoPackagesUpdated_NoUpdates ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
-
- updatedPackagesInSolution.CheckForUpdates ();
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.IsFalse (updatedPackagesInSolution.AnyUpdates ());
- }
-
- [Test]
- public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdates_ExceptionLogged ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- updatedPackagesInSolution.CheckForUpdates ();
-
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.IsFaulted = true;
- var innerException = new ApplicationException ("Inner exception error message");
- task.Exception = new AggregateException ("Aggregate error message", innerException);
- task.ExecuteTaskButNotContinueWith ();
- task.Result = null;
- task.ExecuteContinueWith ();
-
- Assert.AreEqual ("Current check for updates task error.", checkForUpdatesTaskRunner.LoggedErrorMessages[0]);
- Assert.AreEqual (task.Exception, checkForUpdatesTaskRunner.LoggedExceptions[0]);
- }
-
- [Test]
- public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdatesButSolutionClosedBeforeCheckForUpdatesReturns_ErrorIsLogged ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- updatedPackagesInSolution.CheckForUpdates ();
-
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.IsFaulted = true;
- task.Exception = new AggregateException ("Error message");
- task.ExecuteTaskButNotContinueWith ();
- updatedPackagesInSolution.Clear ();
- task.Result = null;
- task.ExecuteContinueWith ();
-
- Assert.AreEqual ("Check for updates task error.", checkForUpdatesTaskRunner.LoggedErrorMessages[0]);
- Assert.AreEqual (task.Exception, checkForUpdatesTaskRunner.LoggedExceptions[0]);
- }
-
- [Test]
- public void CheckForUpdates_ExceptionThrownWhilstCheckingForUpdatesButSolutionClosedBeforeCheckForUpdatesReturnsAndSecondCheckForUpdatesIsStarted_ErrorIsLogged ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- updatedPackagesInSolution.CheckForUpdates ();
-
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.IsFaulted = true;
- task.Exception = new AggregateException ("Error message");
- task.ExecuteTaskButNotContinueWith ();
- updatedPackagesInSolution.CheckForUpdates ();
- task.Result = null;
- task.ExecuteContinueWith ();
-
- Assert.AreEqual ("Check for updates task error.", checkForUpdatesTaskRunner.LoggedErrorMessages[0]);
- Assert.AreEqual (task.Exception, checkForUpdatesTaskRunner.LoggedExceptions[0]);
- }
-
- [Test]
- public void CheckForUpdates_OnePackageUpdatedAndSolutionClosedBeforeResultsReturnedAndThenSolutionOpenedAgain_UpdatedPackagesAvailableEventIsFiredForSecondOpeningOfSolution ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- bool fired = false;
- packageManagementEvents.UpdatedPackagesAvailable += (sender, e) => {
- fired = true;
- };
- updatedPackagesInSolution.CheckForUpdates ();
- var firstTask = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- firstTask.ExecuteTaskButNotContinueWith ();
- updatedPackagesInSolution.CheckForUpdates ();
- firstTask.ExecuteContinueWith ();
- var secondTask = taskFactory.FakeTasksCreated [1] as FakeTask<CheckForUpdatesTask>;
- secondTask.ExecuteTaskButNotContinueWith ();
- secondTask.ExecuteContinueWith ();
-
- Assert.IsTrue (updatedPackagesInSolution.AnyUpdates ());
- Assert.IsTrue (fired);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageUpdatedAndPackageIsUninstalledWhilstCheckingForUpdates_NoUpdatesAvailableForUninstalledPackage ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- var package = FakePackage.CreatePackageWithVersion ("MyPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.ExecuteTaskButNotContinueWith ();
- project.PackageReferences.Clear ();
- packageManagementEvents.OnParentPackageUninstalled (package, project);
- task.ExecuteContinueWith ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void CheckForUpdates_TaskCancelled_TaskResultIsNotReferenced ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- updatedPackagesInSolution.CheckForUpdates ();
-
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.IsCancelled = true;
- task.ExecuteTaskButNotContinueWith ();
- task.Result = null;
-
- Assert.DoesNotThrow (() => {
- task.ExecuteContinueWith ();
- });
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageHasUpdatesAndNewerVersionButNotLatestIsInstalled_UpdatesStillShowAsAvailable ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- var newerPackage = new FakePackage ("MyPackage", "1.1");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.9");
- updatedPackagesInSolution.CheckForUpdates ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("MyPackage", "1.1");
- packageManagementEvents.OnParentPackageInstalled (newerPackage, project);
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (1, updatedPackages.GetPackages ().Count ());
- Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id);
- Assert.AreEqual ("1.9", updatedPackages.GetPackages ().First ().Version.ToString ());
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageUpdatedAndPackageUpdatedWhilstCheckingForUpdates_UpdateIsNotAvailableForPackage ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- FakePackage updatedPackage = AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.ExecuteTaskButNotContinueWith ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("MyPackage", "1.1");
- packageManagementEvents.OnParentPackageInstalled (updatedPackage, project);
- task.ExecuteContinueWith ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageUpdatedAndNewerButNotLatestPackageIsInstalledWhilstCheckingForUpdates_UpdateIsAvailableForPackage ()
- {
- CreateUpdatedPackagesInSolution ();
- taskFactory.RunTasksSynchronously = false;
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0");
- var installedPackage = FakePackage.CreatePackageWithVersion ("MyPackage", "1.2");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.8");
- updatedPackagesInSolution.CheckForUpdates ();
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.ExecuteTaskButNotContinueWith ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("MyPackage", "1.2");
- packageManagementEvents.OnParentPackageInstalled (installedPackage, project);
- task.ExecuteContinueWith ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (1, updatedPackages.GetPackages ().Count ());
- Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id);
- Assert.AreEqual ("1.8", updatedPackages.GetPackages ().First ().Version.ToString ());
- }
-
- [Test]
- public void CheckForUpdates_ProjectHasPreReleasePackageWhichHasUpdatedPrereleasePackage_OnePrereleaseUpdateFound ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0.1-alpha");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.0.1-beta");
- updatedPackagesInSolution.CheckForUpdates ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (1, updatedPackages.GetPackages ().Count ());
- Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id);
- Assert.AreEqual ("1.0.1-beta", updatedPackages.GetPackages ().First ().Version.ToString ());
- }
-
- [Test]
- public void CheckForUpdates_ProjectHasPreReleasePackageWhichHasUpdatedStablePackage_OneStableUpdateFound ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0.1-alpha");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.0.1");
- updatedPackagesInSolution.CheckForUpdates ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (1, updatedPackages.GetPackages ().Count ());
- Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().First ().Id);
- Assert.AreEqual ("1.0.1", updatedPackages.GetPackages ().First ().Version.ToString ());
- }
-
- [Test]
- public void CheckForUpdates_ProjectHasStableAndPreReleasePackagesBothWithUpdatese_TwoUpdatesFound ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0.1-alpha");
- project.AddPackageReference ("AnotherPackage", "1.0");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.0.1-beta");
- AddUpdatedPackageToAggregateSourceRepository ("AnotherPackage", "1.1");
- updatedPackagesInSolution.CheckForUpdates ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (2, updatedPackages.GetPackages ().Count ());
- Assert.AreEqual ("AnotherPackage", updatedPackages.GetPackages ().First ().Id);
- Assert.AreEqual ("1.1", updatedPackages.GetPackages ().First ().Version.ToString ());
- Assert.AreEqual ("MyPackage", updatedPackages.GetPackages ().Last ().Id);
- Assert.AreEqual ("1.0.1-beta", updatedPackages.GetPackages ().Last ().Version.ToString ());
- }
-
- [Test]
- public void CheckForUpdates_ProjectHasStablePackageWhichHasUpdatedPrereleasePackage_NoUpdatesFound ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("MyPackage", "1.0.1");
- AddUpdatedPackageToAggregateSourceRepository ("MyPackage", "1.1.0-alpha");
- updatedPackagesInSolution.CheckForUpdates ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
-
- [Test]
- public void GetUpdatedPackages_UpdatingThreeOldAndroidPackagesInstallsOneAndUpdatesOneAndRemovesOneWithOneInstall_NoUpdatesRemain ()
- {
- CreateUpdatedPackagesInSolution ();
- FakePackageManagementProject project = AddProjectToSolution ();
- project.AddPackageReference ("Xamarin.Android.Support.v13", "20.0.0.4");
- project.AddPackageReference ("Xamarin.Android.Support.v4", "20.0.0.4");
- project.AddPackageReference ("Xamarin.Android.Support.v7.AppCompat", "20.0.0.2");
- AddUpdatedPackageToAggregateSourceRepository ("Xamarin.Android.Support.v13", "23.1.1.0");
- AddUpdatedPackageToAggregateSourceRepository ("Xamarin.Android.Support.v4", "23.1.1.0");
- AddUpdatedPackageToAggregateSourceRepository ("Xamarin.Android.Support.v7.AppCompat", "23.1.1.0");
- updatedPackagesInSolution.CheckForUpdates ();
- int originalUpdatesAvailable = updatedPackagesInSolution
- .GetUpdatedPackages (project.Project)
- .GetPackages ()
- .Count ();
- var task = taskFactory.FakeTasksCreated [0] as FakeTask<CheckForUpdatesTask>;
- task.ExecuteTaskButNotContinueWith ();
- project.PackageReferences.Clear ();
- project.AddPackageReference ("Xamarin.Android.Support.v4", "23.1.1.0");
- project.AddPackageReference ("Xamarin.Android.Support.v7.AppCompat", "23.1.1.0");
- var installedPackage = FakePackage.CreatePackageWithVersion ("Xamarin.Android.Support.v4", "23.1.1.0");
- packageManagementEvents.OnParentPackageInstalled (installedPackage, project);
- task.ExecuteContinueWith ();
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.GetUpdatedPackages (project.Project);
-
- Assert.AreEqual (3, originalUpdatesAvailable);
- Assert.AreEqual (0, updatedPackages.GetPackages ().Count ());
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesTests.cs deleted file mode 100644 index 9b4c2316c9..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UpdatedPackagesTests.cs +++ /dev/null @@ -1,200 +0,0 @@ -//
-// UpdatedPackagesTests.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 System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using NUnit.Framework;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UpdatedPackagesTests
- {
- UpdatedPackages updatedPackages;
- FakeServiceBasedRepository sourceRepository;
- List<FakePackage> sourceRepositoryPackages;
- List<IPackageName> packageNamesUsedWhenCheckingForUpdates;
- bool includePreleaseUsedWhenCheckingForUpdates;
- FakePackageManagementProject project;
-
- [SetUp]
- public void Init ()
- {
- sourceRepository = new FakeServiceBasedRepository ();
- sourceRepositoryPackages = new List<FakePackage> ();
- packageNamesUsedWhenCheckingForUpdates = new List<IPackageName> ();
- project = new FakePackageManagementProject ();
- }
-
- void CreateUpdatedPackages ()
- {
- sourceRepository.GetUpdatesAction = (packagesNames, includePrerelease, includeAllVersions, targetFrameworks, versionConstraints) => {
- includePreleaseUsedWhenCheckingForUpdates = includePrerelease;
- packageNamesUsedWhenCheckingForUpdates.AddRange (packagesNames.Select (p => (IPackageName)p));
- return sourceRepositoryPackages.AsQueryable ();
- };
- CreateUpdatedPackages (sourceRepository);
- }
-
- void CreateUpdatedPackages (IPackageRepository repository)
- {
- updatedPackages = new UpdatedPackages (project, repository);
- }
-
- FakePackage AddPackageToSourceRepository (string id, string version)
- {
- FakePackage package = CreatePackage (id, version);
- sourceRepositoryPackages.Add (package);
- return package;
- }
-
- FakePackage CreatePackage (string id, string version)
- {
- var helper = new TestPackageHelper (id, version);
- helper.IsLatestVersion ();
- helper.Listed ();
- return helper.Package;
- }
-
- PackageReference AddPackageReference (string packageId, string packageVersion)
- {
- return project.AddPackageReference (packageId, packageVersion);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageReferenceAndUpdateAvailable_UpdatedPackageReturned ()
- {
- AddPackageReference ("Test", "1.0");
- IPackage expectedPackage = AddPackageToSourceRepository ("Test", "1.1");
- var expectedPackages = new IPackage[] { expectedPackage };
- CreateUpdatedPackages ();
-
- IEnumerable<IPackage> packages = updatedPackages.GetUpdatedPackages ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageReferencedAndUpdateAvailable_InstalledPackageNameUsedToCheckIfSourceRepositoryHasAnyUpdates ()
- {
- AddPackageReference ("Test", "1.0");
- AddPackageToSourceRepository ("Test", "1.1");
- CreateUpdatedPackages ();
-
- updatedPackages.GetUpdatedPackages ();
-
- IPackageName packageChecked = packageNamesUsedWhenCheckingForUpdates.FirstOrDefault ();
- Assert.AreSame ("Test", packageChecked.Id);
- Assert.AreSame ("1.0", packageChecked.Version.ToString ());
- Assert.AreEqual (1, packageNamesUsedWhenCheckingForUpdates.Count);
- }
-
- [Test]
- public void GetUpdatedPackages_JQueryPackageInstalledTwiceWithDifferentVersions_OnlyOlderJQueryPackageUsedToDetermineUpdatedPackages ()
- {
- AddPackageReference ("jquery", "1.6");
- AddPackageReference ("jquery", "1.7");
- AddPackageToSourceRepository ("jquery", "2.1");
- CreateUpdatedPackages ();
-
- updatedPackages.GetUpdatedPackages ();
-
- IPackageName packageChecked = packageNamesUsedWhenCheckingForUpdates.FirstOrDefault ();
- Assert.AreSame ("jquery", packageChecked.Id);
- Assert.AreSame ("1.6", packageChecked.Version.ToString ());
- Assert.AreEqual (1, packageNamesUsedWhenCheckingForUpdates.Count);
- }
-
- [Test]
- public void GetUpdatedPackages_JQueryPackageInstalledTwiceWithDifferentVersionsAndNewerVersionsFirst_OnlyOlderJQueryPackageUsedToDetermineUpdatedPackages ()
- {
- AddPackageReference ("jquery", "1.7");
- AddPackageReference ("jquery", "1.6");
- AddPackageToSourceRepository ("jquery", "2.1");
- CreateUpdatedPackages ();
-
- updatedPackages.GetUpdatedPackages ();
-
- IPackageName packageChecked = packageNamesUsedWhenCheckingForUpdates.FirstOrDefault ();
- Assert.AreSame ("jquery", packageChecked.Id);
- Assert.AreSame ("1.6", packageChecked.Version.ToString ());
- Assert.AreEqual (1, packageNamesUsedWhenCheckingForUpdates.Count);
- }
-
- [Test]
- public void GetUpdatedPackages_AllowPrereleaseIsTrue_PrereleasePackagesAllowedForUpdates ()
- {
- AddPackageReference ("Test", "1.0");
- CreateUpdatedPackages ();
-
- updatedPackages.GetUpdatedPackages (includePrerelease: true);
-
- Assert.IsTrue (includePreleaseUsedWhenCheckingForUpdates);
- }
-
- [Test]
- public void GetUpdatedPackages_AllowPrereleaseIsFalse_PrereleasePackagesNotAllowedForUpdates ()
- {
- AddPackageReference ("Test", "1.0");
- CreateUpdatedPackages ();
-
- updatedPackages.GetUpdatedPackages (includePrerelease: false);
-
- Assert.IsFalse (includePreleaseUsedWhenCheckingForUpdates);
- }
-
- [Test]
- public void GetUpdatedPackages_OnePackageReferencedWithConstraintAndUpdatesAvailable_LatestVersionReturnedBasedOnConstraint ()
- {
- AddPackageReference ("Test", "1.0");
- FakePackage package = AddPackageToSourceRepository ("Test", "2.0");
- FakePackage [] expectedPackages = new [] {
- package
- };
- AddPackageToSourceRepository ("Test", "3.0");
- var versionSpec = new VersionSpec ();
- versionSpec.MinVersion = new SemanticVersion ("1.0");
- versionSpec.IsMinInclusive = true;
- versionSpec.MaxVersion = new SemanticVersion ("2.0");
- versionSpec.IsMaxInclusive = true;
- var constraintProvider = new DefaultConstraintProvider ();
- constraintProvider.AddConstraint ("Test", versionSpec);
- project.ConstraintProvider = constraintProvider;
- var repository = new FakePackageRepository ();
- repository.FakePackages = sourceRepositoryPackages;
- CreateUpdatedPackages (repository);
-
- IEnumerable<IPackage> packages = updatedPackages.GetUpdatedPackages ();
-
- PackageCollectionAssert.AreEqual (expectedPackages, packages);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UserAgentGeneratorForRepositoryRequestsTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UserAgentGeneratorForRepositoryRequestsTests.cs deleted file mode 100644 index 74da61618b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/UserAgentGeneratorForRepositoryRequestsTests.cs +++ /dev/null @@ -1,106 +0,0 @@ -//
-// UserAgentGeneratorForRepositoryRequestsTests.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 System.Net;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement.Tests.Helpers;
-using NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class UserAgentGeneratorForRepositoryRequestsTests
- {
- UserAgentGeneratorForRepositoryRequests generator;
-
- FakePackageRepositoryFactoryEvents repositoryFactoryEvents;
-
- void CreateGenerator ()
- {
- repositoryFactoryEvents = new FakePackageRepositoryFactoryEvents ();
- generator = new UserAgentGeneratorForRepositoryRequests ();
- generator.Register (repositoryFactoryEvents);
- }
-
- IPackageRepository CreatePackageRepository ()
- {
- return new FakePackageRepository ();
- }
-
- FakePackageRepositoryWithHttpClientEvents CreatePackageRepositoryThatImplementsIHttpClientEvents ()
- {
- return new FakePackageRepositoryWithHttpClientEvents ();
- }
-
- void FireRepositoryCreatedEvent (FakePackageRepositoryWithHttpClientEvents clientEvents)
- {
- FireRepositoryCreatedEvent (clientEvents as IPackageRepository);
- }
-
- void FireRepositoryCreatedEvent (IPackageRepository repository)
- {
- var eventArgs = new PackageRepositoryFactoryEventArgs (repository);
- repositoryFactoryEvents.RaiseRepositoryCreatedEvent (eventArgs);
- }
-
- WebRequest FireSendingRequestEvent (FakePackageRepositoryWithHttpClientEvents clientEvents)
- {
- var request = new FakeWebRequest ();
- request.Headers = new WebHeaderCollection ();
-
- var eventArgs = new WebRequestEventArgs (request);
- clientEvents.RaiseSendingRequestEvent (eventArgs);
-
- return request;
- }
-
- [Test]
- public void SendingRequest_UserAgentGeneration_UserAgentSetOnRequest ()
- {
- CreateGenerator ();
- var clientEvents = CreatePackageRepositoryThatImplementsIHttpClientEvents ();
- FireRepositoryCreatedEvent (clientEvents);
-
- WebRequest request = FireSendingRequestEvent (clientEvents);
-
- string userAgent = request.Headers [HttpRequestHeader.UserAgent];
- Assert.IsTrue (userAgent.StartsWith (BrandingService.ApplicationName), userAgent);
- }
-
- [Test]
- public void RepositoryCreated_RepositoryDoesNotImplementIHttpClientEvents_NullReferenceExceptionNotThrown ()
- {
- CreateGenerator ();
- IPackageRepository repository = CreatePackageRepository ();
-
- FireRepositoryCreatedEvent (repository);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/WildcardVersionSpecTests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/WildcardVersionSpecTests.cs deleted file mode 100644 index d57e6fb1e5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests/WildcardVersionSpecTests.cs +++ /dev/null @@ -1,79 +0,0 @@ -//
-// WildCardVersionSpecTests.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 NuGet;
-using NUnit.Framework;
-
-namespace MonoDevelop.PackageManagement.Tests
-{
- [TestFixture]
- public class WildcardVersionSpecTests
- {
- WildcardVersionSpec versionSpec;
-
- void CreateWildcardVersionSpec (string version)
- {
- versionSpec = new WildcardVersionSpec (version);
- }
-
- [TestCase ("1.0", "1.0", true)]
- [TestCase ("1.0", "1.1", false)]
- [TestCase ("1", "1.0", true)]
- [TestCase ("1*", "1.1", true)]
- [TestCase ("1", "1.9.1", true)]
- [TestCase ("1", "1.10.1", true)]
- [TestCase ("1", "1.10.1-alpha", true)]
- [TestCase ("1", "2.0", false)]
- [TestCase ("*", "1.10.1", true)]
- [TestCase ("1.1", "1.9.1", false)]
- [TestCase ("1.1", "1.1.1", true)]
- [TestCase ("1.1", "1.1.0", true)]
- [TestCase ("1.1", "1.0.0", false)]
- [TestCase ("1.1", "2.0.0", false)]
- [TestCase ("1.1.1", "1.9.1", false)]
- [TestCase ("1.1.1", "1.1.1", true)]
- [TestCase ("1.1.1", "1.1.1.1", true)]
- [TestCase ("1.1.1", "1.1.1.0", true)]
- [TestCase ("1.1.1", "1.1.1.0-alpha1", true)]
- [TestCase ("1.1.1", "1.0.0", false)]
- [TestCase ("1.1.1", "1.1.2.0", false)]
- [TestCase ("1.1.1.1", "1.1.1.1", true)]
- [TestCase ("1.1.1.1", "1.1.1.2", false)]
- [TestCase ("1.1.0", "1.1.1", false)]
- [TestCase ("1.1.1.0-alpha1", "1.1.1.0-alpha1", true)]
- [TestCase ("1.1.1.0-alpha1", "1.1.1.0-alpha2", false)]
- public void VersionSatisfiesWildcardVersionSpec (string wildcard, string versionToMatch, bool expectedResult)
- {
- CreateWildcardVersionSpec (wildcard);
-
- bool result = versionSpec.Satisfies (new SemanticVersion (versionToMatch));
-
- Assert.AreEqual (expectedResult, result);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config new file mode 100644 index 0000000000..747efc53e4 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" /> +</packages>
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.addin.xml b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.addin.xml index caa93c4622..ffcd1b72f8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.addin.xml +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.addin.xml @@ -9,58 +9,62 @@ <Extension path = "/MonoDevelop/Ide/Commands">
<Category _name = "NuGet" id = "NuGet">
<Command
- id = "MonoDevelop.PackageManagement.Commands.AddNuGetPackages"
+ id = "MonoDevelop.PackageManagement.Commands.AddPackages"
_description = "Add NuGet packages to the project"
_label = "Add NuGet _Packages..."
defaultHandler = "MonoDevelop.PackageManagement.Commands.AddPackagesHandler" />
<Command
- id = "MonoDevelop.PackageManagement.Commands.AddPackages"
- _description = "Add packages to the project"
- _label = "Add _Packages..."
- defaultHandler = "MonoDevelop.PackageManagement.Commands.AddPackagesHandler" />
- <Command
id = "MonoDevelop.PackageManagement.Commands.RestorePackages"
- _description = "Restore missing NuGet packages"
+ _description = "Restore all missing packages in the solution"
_label = "_Restore NuGet Packages"
+ _displayName = "Restore Packages (Solution)"
defaultHandler = "MonoDevelop.PackageManagement.Commands.RestorePackagesHandler" />
<Command
id="MonoDevelop.PackageManagement.Commands.Restore"
_description="Restore missing packages"
_label="_Restore"
+ _displayName = "Restore Packages"
defaultHandler="MonoDevelop.PackageManagement.Commands.RestorePackagesInProjectHandler" />
<Command
- id="MonoDevelop.PackageManagement.Commands.PackageReferenceNodeCommands.ShowPackageVersion"
- _description="Current package version"
- _label="Version" />
- <Command
id="MonoDevelop.PackageManagement.Commands.PackageReferenceNodeCommands.ReinstallPackage"
- _description="Retarget package"
- _label="Re_target" />
+ _description="Retarget selected package"
+ _label="Re_target"
+ _displayName="Retarget Package" />
<Command
id="MonoDevelop.PackageManagement.Commands.PackageReferenceNodeCommands.UpdatePackage"
- _description="Update package"
- _label="_Update" />
+ _description="Update selected package"
+ _label="_Update"
+ _displayName="Update Package" />
<Command
id="MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInProject"
_description="Update all packages"
_label="_Update"
+ _displayName="Update All Packages"
defaultHandler="MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInProjectHandler" />
<Command
id="MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInSolution"
- _description="Update all NuGet packages in the solution"
+ _description="Update all packages in the solution"
_label="_Update NuGet Packages"
+ _displayName="Update All Packages (Solution)"
defaultHandler="MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInSolutionHandler" />
<Command
- id="MonoDevelop.PackageManagement.Commands.ReinstallAllPackagesInProject"
+ id="MonoDevelop.PackageManagement.Commands.PackagesFolderNodeCommands.ReinstallAllPackagesInProject"
_description="Retargets all packages"
_label="Re_target"
+ _displayName="Retarget All Packages"
defaultHandler="MonoDevelop.PackageManagement.Commands.ReinstallAllPackagesInProjectHandler" />
</Category>
+ <Category id="Hidden" _name="Hidden">
+ <Command
+ id="MonoDevelop.PackageManagement.Commands.PackageReferenceNodeCommands.ShowPackageVersion"
+ _description="Current package version"
+ _label="Version" />
+ </Category>
</Extension>
<Extension path="/MonoDevelop/Ide/MainMenu/Project">
<SeparatorItem insertafter="MonoDevelop.Ide.Commands.ProjectCommands.AddReference" />
- <CommandItem id="MonoDevelop.PackageManagement.Commands.AddNuGetPackages" />
+ <CommandItem id="MonoDevelop.PackageManagement.Commands.AddPackages" />
<CommandItem id="MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInSolution" />
<CommandItem id="MonoDevelop.PackageManagement.Commands.RestorePackages" />
<SeparatorItem />
@@ -79,9 +83,9 @@ </Condition>
<Condition id="ItemType" value="MonoDevelop.PackageManagement.NodeBuilders.ProjectPackagesFolderNode">
<CommandItem
- id="MonoDevelop.PackageManagement.Commands.AddPackages" />
+ id="MonoDevelop.PackageManagement.Commands.AddPackages" _label = "Add _Packages..." />
<CommandItem
- id="MonoDevelop.PackageManagement.Commands.ReinstallAllPackagesInProject" />
+ id="MonoDevelop.PackageManagement.Commands.PackagesFolderNodeCommands.ReinstallAllPackagesInProject" />
<CommandItem
id="MonoDevelop.PackageManagement.Commands.UpdateAllPackagesInProject" />
<CommandItem
@@ -92,7 +96,7 @@ <Extension path="/MonoDevelop/Ide/ContextMenu/ProjectPad/Add">
<Condition id="ItemType" value="Project">
<CommandItem
- id="MonoDevelop.PackageManagement.Commands.AddNuGetPackages"
+ id="MonoDevelop.PackageManagement.Commands.AddPackages"
insertafter="MonoDevelop.Ide.Commands.ProjectCommands.AddFiles"
insertbefore="MonoDevelop.WebReferences.WebReferenceCommands.Add" />
</Condition>
@@ -155,4 +159,8 @@ <Extension path="/MonoDevelop/Refactoring/CodeDiagnosticProvider">
<Class class="MonoDevelop.PackageManagement.Refactoring.PackageCodeDiagnosticProvider" />
</Extension>-->
+
+ <Extension path="/MonoDevelop/Core/SystemInformation">
+ <Class class="MonoDevelop.PackageManagement.NuGetSystemInformation" />
+ </Extension>
</ExtensionModel>
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index ffb8d42e5f..9812f841cb 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -58,188 +58,173 @@ <Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <Reference Include="Mono.Posix" /> + <Reference Include="Mono.Cairo" /> + <Reference Include="System.Security" /> + <Reference Include="Microsoft.Web.XmlTransform"> + <HintPath>..\..\..\external\nuget-binary\Microsoft.Web.XmlTransform.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json"> + <HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath> + <Private>False</Private> + </Reference> + <Reference Include="NuGet.Versioning"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Versioning.dll</HintPath> + </Reference> + <Reference Include="mscorlib" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="NuGet.LibraryModel"> + <HintPath>..\..\..\external\nuget-binary\NuGet.LibraryModel.dll</HintPath> + </Reference> + <Reference Include="NuGet.Frameworks"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Frameworks.dll</HintPath> + </Reference> + <Reference Include="NuGet.Logging"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Logging.dll</HintPath> + </Reference> + <Reference Include="NuGet.Packaging.Core.Types"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Packaging.Core.Types.dll</HintPath> + </Reference> + <Reference Include="NuGet.Packaging.Core"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Packaging.Core.dll</HintPath> + </Reference> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.IO.Compression" /> + <Reference Include="NuGet.Packaging"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Packaging.dll</HintPath> + </Reference> + <Reference Include="NuGet.Configuration"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Configuration.dll</HintPath> + </Reference> + <Reference Include="System.Globalization" /> + <Reference Include="NuGet.Protocol.Core.Types"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Protocol.Core.Types.dll</HintPath> + </Reference> + <Reference Include="System.Net.Http" /> + <Reference Include="NuGet.Protocol.Core.v3"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Protocol.Core.v3.dll</HintPath> + </Reference> + <Reference Include="System.Collections.Concurrent" /> + <Reference Include="System.IdentityModel" /> + <Reference Include="System.Net.Http.WebRequest" /> + <Reference Include="System.ServiceModel" /> + <Reference Include="NuGet.Repositories"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Repositories.dll</HintPath> + </Reference> + <Reference Include="NuGet.RuntimeModel"> + <HintPath>..\..\..\external\nuget-binary\NuGet.RuntimeModel.dll</HintPath> + </Reference> + <Reference Include="System.Collections" /> + <Reference Include="NuGet.DependencyResolver.Core"> + <HintPath>..\..\..\external\nuget-binary\NuGet.DependencyResolver.Core.dll</HintPath> + </Reference> + <Reference Include="NuGet.ProjectModel"> + <HintPath>..\..\..\external\nuget-binary\NuGet.ProjectModel.dll</HintPath> + </Reference> + <Reference Include="NuGet.ProjectManagement"> + <HintPath>..\..\..\external\nuget-binary\NuGet.ProjectManagement.dll</HintPath> + </Reference> + <Reference Include="System.ComponentModel.Composition" /> + <Reference Include="NuGet.ContentModel"> + <HintPath>..\..\..\external\nuget-binary\NuGet.ContentModel.dll</HintPath> + </Reference> + <Reference Include="NuGet.Client"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Client.dll</HintPath> + </Reference> + <Reference Include="NuGet.DependencyResolver"> + <HintPath>..\..\..\external\nuget-binary\NuGet.DependencyResolver.dll</HintPath> + </Reference> + <Reference Include="NuGet.Commands"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Commands.dll</HintPath> + </Reference> <Reference Include="NuGet.Core"> <HintPath>..\..\..\external\nuget-binary\NuGet.Core.dll</HintPath> </Reference> - <Reference Include="Mono.Cairo" /> - <Reference Include="System.Security" /> + <Reference Include="NuGet.Protocol.Core.v2"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Protocol.Core.v2.dll</HintPath> + </Reference> + <Reference Include="System.Runtime.Serialization" /> + <Reference Include="WindowsBase" /> + <Reference Include="NuGet.Resolver"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Resolver.dll</HintPath> + </Reference> + <Reference Include="NuGet.PackageManagement"> + <HintPath>..\..\..\external\nuget-binary\NuGet.PackageManagement.dll</HintPath> + </Reference> + <Reference Include="NuGet.Common"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Common.dll</HintPath> + </Reference> + <Reference Include="NuGet.Protocol.VisualStudio"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Protocol.VisualStudio.dll</HintPath> + </Reference> + <Reference Include="NuGet.Indexing"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Indexing.dll</HintPath> + </Reference> + <Reference Include="NuGet.Credentials"> + <HintPath>..\..\..\external\nuget-binary\NuGet.Credentials.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <Compile Include="AssemblyInfo.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Commands\ManagePackagesHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\PackagesCommandHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\RestorePackagesHandler.cs" /> - <Compile Include="MonoDevelop.PackageManagement\AcceptLicensesEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\AggregateExceptionErrorMessage.cs" /> - <Compile Include="MonoDevelop.PackageManagement\AvailablePackagesViewModel.cs" /> <Compile Include="MonoDevelop.PackageManagement\ConfigSettingsFileSystem.cs" /> - <Compile Include="MonoDevelop.PackageManagement\DefaultProjectTemplatePackageSource.cs" /> <Compile Include="MonoDevelop.PackageManagement\DelegateCommand.cs" /> <Compile Include="MonoDevelop.PackageManagement\DotNetProjectExtensions.cs" /> <Compile Include="MonoDevelop.PackageManagement\FileConflictResolver.cs" /> <Compile Include="MonoDevelop.PackageManagement\FolderBrowser.cs" /> <Compile Include="MonoDevelop.PackageManagement\ICommand.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ICompilerMessageView.cs" /> <Compile Include="MonoDevelop.PackageManagement\IFolderBrowser.cs" /> <Compile Include="MonoDevelop.PackageManagement\ILicenseAcceptanceService.cs" /> <Compile Include="MonoDevelop.PackageManagement\IMachinePackageCache.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IMessageViewCategory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\InstalledPackagesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\InstalledPackageViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\InstalledPackageViewModelFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\InstallPackageAction.cs" /> <Compile Include="MonoDevelop.PackageManagement\IPackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageActionRunner.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageExtensions.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageFromRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageFromRepositoryExtensions.cs" /> <Compile Include="MonoDevelop.PackageManagement\IPackageManagementEvents.cs" /> <Compile Include="MonoDevelop.PackageManagement\IPackageManagementFileService.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageManagementOutputMessagesView.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageManagementProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageManagementProjectFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\IPackageManagementProjectService.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageManagementSelectedProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageManagementSolution.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageManagerFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageOperationResolverFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageRepositoryCache.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageRepositoryExtensions.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageRepositoryFactoryEvents.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageViewModelFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IPackageViewModelParent.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IProcess.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IProjectBrowserUpdater.cs" /> <Compile Include="MonoDevelop.PackageManagement\IPropertyService.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IRecentPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IRegisteredPackageRepositories.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ISelectProjectsService.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ISettingsFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\ISolutionPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ISolutionPackageRepositoryFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\ITask.cs" /> <Compile Include="MonoDevelop.PackageManagement\ITaskFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IThreadSafePackageManagementEvents.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IUpdatePackageActions.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IUpdatePackagesAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IUpdatePackageSettings.cs" /> <Compile Include="MonoDevelop.PackageManagement\LicenseAcceptanceService.cs" /> <Compile Include="MonoDevelop.PackageManagement\LicenseAcceptanceViewModel.cs" /> <Compile Include="MonoDevelop.PackageManagement\MachinePackageCache.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ManagePackagesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ManagePackagesViewTitle.cs" /> <Compile Include="MonoDevelop.PackageManagement\MonoDevelopCredentialProvider.cs" /> <Compile Include="MonoDevelop.PackageManagement\MSBuildProjectExtensions.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageActionRunner.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageFromRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageLicenseViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementEnumerableExtensions.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementOptionsViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementSelectedProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementSelectedProjects.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementTask.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementTaskFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementViewModels.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageRepositoryFactoryEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackagesForSelectedPageResult.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageSourceViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackagesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackagesViewModels.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageViewModelFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageViewModelOperationLogger.cs" /> - <Compile Include="MonoDevelop.PackageManagement\Page.cs" /> - <Compile Include="MonoDevelop.PackageManagement\Pages.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ParentPackagesOperationEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\Process.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RecentPackagesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ReducedPackageOperations.cs" /> <Compile Include="MonoDevelop.PackageManagement\RegisteredPackageSourcesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageReferenceMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\ResolveFileConflictEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SelectedProjectsForInstalledPackages.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SelectedProjectsForUpdatedPackages.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SelectProjectsEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SelectProjectsService.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SelectProjectsViewModel.cs" /> <Compile Include="MonoDevelop.PackageManagement\MarkupString.cs" /> - <Compile Include="MonoDevelop.PackageManagement\OpenDotNetProjects.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageFiles.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageFilesForOperations.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementCompilerMessageView.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementEvents.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementFileService.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementLogger.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementMessageViewCategory.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementOptions.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementOutputMessagesView.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementProjectFactory.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageManagementInstrumentationService.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementProjectService.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementPropertyService.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementServices.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementSolution.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageOperationExceptionEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageOperationMessage.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageOperationMessageLoggedEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageOperationsResolverFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageRepositoryCache.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageSourceConverter.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageSourceExtensions.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ParentPackageOperationEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ProcessPackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ProcessPackageOperationsAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ProjectBrowserUpdater.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectTargetFramework.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ProjectTemplatePackageRepositoryCache.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ProjectTemplatePackageSettingsFileName.cs" /> <Compile Include="MonoDevelop.PackageManagement\RecentPackageInfo.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RecentPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RegisteredPackageRepositories.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RegisteredPackageSource.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RegisteredPackageSources.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RegisteredPackageSourceSettings.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RegisteredProjectTemplatePackageSources.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SettingsFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\MonoDevelopHttpUserAgent.cs" /> <Compile Include="MonoDevelop.PackageManagement\SolutionExtensions.cs" /> <Compile Include="MonoDevelop.PackageManagement\SolutionPackageRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement\SolutionPackageRepositoryFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\SolutionPackageRepositoryPath.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ThreadSafePackageManagementEvents.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ThreadSafeProjectBrowserUpdater.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UninstallPackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatedPackages.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatedPackagesViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatedPackageViewModel.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatedPackageViewModelFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatePackageAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatePackagesAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatePackagesActionFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdateSolutionPackagesAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UserAgentGeneratorForRepositoryRequests.cs" /> <Compile Include="MonoDevelop.PackageManagement\ViewModelBase.cs" /> <Compile Include="gtk-gui\generated.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Gui\ManagePackagesDialog.cs" /> - <Compile Include="gtk-gui\MonoDevelop.PackageManagement.ManagePackagesDialog.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Gui\PackagesWidget.cs" /> - <Compile Include="gtk-gui\MonoDevelop.PackageManagement.PackagesWidget.cs" /> - <Compile Include="gtk-gui\MonoDevelop.PackageManagement.HyperlinkWidget.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Gui\HyperlinkWidget.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\LicenseAcceptanceDialog.cs" /> <Compile Include="gtk-gui\MonoDevelop.PackageManagement.LicenseAcceptanceDialog.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Gui\PackageLicenseWidget.cs" /> - <Compile Include="gtk-gui\MonoDevelop.PackageManagement.PackageLicenseWidget.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Gui\SelectProjectsDialog.cs" /> - <Compile Include="gtk-gui\MonoDevelop.PackageManagement.SelectProjectsDialog.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageSourcesOptionsPanel.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageSourcesWidget.cs" /> <Compile Include="gtk-gui\MonoDevelop.PackageManagement.PackageSourcesWidget.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageManagementOptionsPanel.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageManagementOptionsWidget.cs" /> <Compile Include="gtk-gui\MonoDevelop.PackageManagement.PackageManagementOptionsWidget.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Gui\PagedResultsWidget.cs" /> - <Compile Include="gtk-gui\MonoDevelop.PackageManagement.PagedResultsWidget.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\AddPackagesHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\AddPackagesDialog.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\AddPackagesDialog.UI.cs"> @@ -259,19 +244,13 @@ <Compile Include="MonoDevelop.PackageManagement.Commands\PackageReferenceNodeCommandHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\PackageReferenceNodeCommands.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\UpdateAllPackagesInProjectHandler.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdateAllPackagesInProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatePackageActions.cs" /> <Compile Include="MonoDevelop.PackageManagement.NodeBuilders\PackageReferenceNodePropertyProvider.cs" /> <Compile Include="MonoDevelop.PackageManagement.NodeBuilders\PackageReferenceNodeDescriptor.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdateAllPackagesInSolution.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\UpdateAllPackagesInSolutionHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement\IBackgroundPackageActionRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProgressMonitorStatusMessageFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProgressMonitorStatusMessage.cs" /> <Compile Include="AddinInfo.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageRestorer.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ProjectPackageReferenceFile.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageRestoreRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageCellView.cs" /> <Compile Include="MonoDevelop.PackageManagement\SearchPackagesSearchCategory.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\AddPackagesDialogRunner.cs" /> @@ -296,12 +275,9 @@ <Compile Include="MonoDevelop.PackageManagement\PackageSourceViewModelChangedEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageSourceCellRenderer.cs" /> <Compile Include="MonoDevelop.PackageManagement\ImageCache.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackagesRequiringLicenseAcceptance.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProgressMonitorExtensions.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageListViewTextFormatter.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\PackageCellViewCheckBox.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackagesForSelectedPageQuery.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementProgressProvider.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementProgressMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\ISolution.cs" /> <Compile Include="MonoDevelop.PackageManagement\IProject.cs" /> @@ -311,8 +287,6 @@ <Compile Include="MonoDevelop.PackageManagement\DotNetProjectProxy.cs" /> <Compile Include="MonoDevelop.PackageManagement\ISettingsProvider.cs" /> <Compile Include="MonoDevelop.PackageManagement\SettingsProvider.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageSearchCriteria.cs" /> - <Compile Include="MonoDevelop.PackageManagement\WildcardVersionSpec.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectTargetFrameworkMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectTargetFrameworkChangedEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectModifiedEventArgs.cs" /> @@ -320,26 +294,14 @@ <Compile Include="MonoDevelop.PackageManagement\PackageCompatibilityHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageCompatibilityRunner.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageCompatibilityChecker.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ReinstallPackageAction.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageReinstaller.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ReinstallProjectPackagesAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\ReinstallPackageOperations.cs" /> - <Compile Include="MonoDevelop.PackageManagement.Commands\ReinstallAllPackagesInProjectHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageCompatibility.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectPackagesCompatibilityReport.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatedPackagesInSolution.cs" /> - <Compile Include="MonoDevelop.PackageManagement\UpdatedPackagesInProject.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IUpdatedPackagesInSolution.cs" /> - <Compile Include="MonoDevelop.PackageManagement\FallbackRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\PackageManagementStartupHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement\UpdatedPackagesMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\UpdatePackagesProgressMonitorStatusMessage.cs" /> <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatedPackagesAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RestoreBeforeUpdateAction.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MonoDevelopAggregateRepository.cs" /> - <Compile Include="MonoDevelop.PackageManagement\RestorePackagesAction.cs" /> <Compile Include="MonoDevelop.PackageManagement.Commands\RestorePackagesInProjectHandler.cs" /> - <Compile Include="MonoDevelop.PackageManagement\FailingPackageRepository.cs" /> <Compile Include="MonoDevelop.PackageManagement\FileRemovingEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\PreventPackagesConfigFileBeingRemovedOnUpdateMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\FilePathExtensions.cs" /> @@ -350,35 +312,102 @@ <Compile Include="MonoDevelop.PackageManagement\PackageManagementProjectOperations.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementPackageReferenceEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageRestoredEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MSBuildTargetsRestoredMonitor.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementMSBuildExtension.cs" /> <Compile Include="MonoDevelop.PackageManagement\EnsureNuGetPackageBuildImportsTargetUpdater.cs" /> - <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesTaskRunner.cs" /> - <Compile Include="MonoDevelop.PackageManagement\CheckForUpdatesTask.cs" /> <Compile Include="MonoDevelop.PackageManagement.Refactoring\PackageCodeDiagnosticProvider.cs" /> <Compile Include="MonoDevelop.PackageManagement\ProjectReloadedEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\OpenPackageReadmeMonitor.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IOpenPackageReadMeMonitor.cs" /> - <Compile Include="MonoDevelop.PackageManagement\NullOpenPackageReadMeMonitor.cs" /> - <Compile Include="MonoDevelop.PackageManagement\PackageManagementSolutionExtensions.cs" /> <Compile Include="MonoDevelop.PackageManagement\DotNetProjectReferenceEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\LocalCopyReferenceMaintainer.cs" /> <Compile Include="MonoDevelop.PackageManagement\DotNetSolutionEventArgs.cs" /> <Compile Include="MonoDevelop.PackageManagement\DotNetProjectImportEventArgs.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IMonoDevelopProjectManager.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IMonoDevelopPackageManager.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MonoDevelopPackageManagerFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\IMonoDevelopPackageRepositoryFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\IMonoDevelopProjectSystemFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\MonoDevelopPackageRepositoryFactory.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MonoDevelopPackageManager.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MonoDevelopProjectManager.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MonoDevelopProjectSystem.cs" /> - <Compile Include="MonoDevelop.PackageManagement\MonoDevelopProjectSystemFactory.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementBackgroundDispatcher.cs" /> <Compile Include="MonoDevelop.PackageManagement\PackageManagementSolutionProjectService.cs" /> <Compile Include="MonoDevelop.PackageManagement\NuGetPackageNewImportsHandler.cs" /> <Compile Include="MonoDevelop.PackageManagement\INuGetPackageNewImportsHandler.cs" /> + <Compile Include="MonoDevelop.PackageManagement\AllPackagesViewModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement\SourceRepositoryProvider.cs" /> + <Compile Include="NuGet.PackageManagement.UI\SearchResult.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageItemListViewModel.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageStatus.cs" /> + <Compile Include="NuGet.PackageManagement.UI\DisplayVersion.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageSearchResultViewModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement\SourceRepositoryViewModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement\InstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopSolutionManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement\DeleteOnRestartManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetProjectContext.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopCommonOperations.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopNuGetProjectFactory.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopMSBuildNuGetProjectSystem.cs" /> + <Compile Include="MonoDevelop.PackageManagement\BuildIntegrationProjectSystem.cs" /> + <Compile Include="MonoDevelop.PackageManagement\INuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UninstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UpdateNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UpdateAllNuGetPackagesInProjectAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UpdateAllNuGetPackagesInSolution.cs" /> + <Compile Include="MonoDevelop.PackageManagement\RestoreNuGetPackagesAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\RestoreNuGetPackagesInProjectAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\RestoreAndCheckForUpdatesAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\IInstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UpdatedNuGetPackagesProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UpdatedNuGetPackagesInProject.cs" /> + <Compile Include="MonoDevelop.PackageManagement\UpdatedNuGetPackagesInWorkspace.cs" /> + <Compile Include="MonoDevelop.PackageManagement\CheckForNuGetPackageUpdatesTaskRunner.cs" /> + <Compile Include="MonoDevelop.PackageManagement\IUpdatedNuGetPackagesInWorkspace.cs" /> + <Compile Include="MonoDevelop.PackageManagement\RestoreNuGetPackagesInNuGetIntegratedProject.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopBuildIntegratedRestorer.cs" /> + <Compile Include="MonoDevelop.PackageManagement\ProjectTemplateSourceRepositoryProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement\ReinstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Commands\PackagesFolderNodeCommands.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetSystemInformation.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetPackageLicenseAuditor.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetPackageLicense.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageManagementWorkspace.cs" /> + <Compile Include="MonoDevelop.PackageManagement\IMonoDevelopSolutionManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetProjectExtensions.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageRestoreMonitor.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageManagementPackageReferenceExtensions.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetPackageEventsMonitor.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageManagementEventArgs.cs" /> + <Compile Include="MonoDevelop.PackageManagement\AnalyzerPackageMonitor.cs" /> + <Compile Include="MonoDevelop.PackageManagement\INuGetProjectActionsProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement\IFileConflictResolver.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NullDisposable.cs" /> + <Compile Include="MonoDevelop.PackageManagement\RestoreAndUninstallNuGetPackageAction.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetPackageUninstaller.cs" /> + <Compile Include="MonoDevelop.PackageManagement\NuGetPackageForcedImportsRemover.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageItemLoader.cs" /> + <Compile Include="NuGet.PackageManagement.UI\IItemLoader.cs" /> + <Compile Include="NuGet.PackageManagement.UI\LoadingStatus.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageLoadContext.cs" /> + <Compile Include="NuGet.PackageManagement.UI\IPackageFeed.cs" /> + <Compile Include="NuGet.PackageManagement.UI\MultiSourcePackageFeed.cs" /> + <Compile Include="NuGet.PackageManagement.UI\TaskCombinators.cs" /> + <Compile Include="NuGet.PackageManagement.UI\SourceRepositoryExtensions.cs" /> + <Compile Include="NuGet.PackageManagement.UI\FeedSearchContinuationToken.cs" /> + <Compile Include="NuGet.PackageManagement.UI\INuGetUILogger.cs" /> + <Compile Include="MonoDevelop.PackageManagement\AggregateSourceRepositoryViewModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageManagementCredentialService.cs" /> + <Compile Include="MonoDevelop.PackageManagement\HttpHandlerResourceV3Extensions.cs" /> + <Compile Include="MonoDevelop.PackageManagement\AggregatePackageSourceErrorMessage.cs" /> + <Compile Include="NuGet.PackageManagement.UI\DetailedPackageMetadata.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageDependentSetMetadata.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageDependencyMetadata.cs" /> + <Compile Include="NuGet.PackageManagement.UI\MultiSourcePackageMetadataProvider.cs" /> + <Compile Include="NuGet.PackageManagement.UI\IPackageMetadataProvider.cs" /> + <Compile Include="NuGet.PackageManagement.UI\DetailControlModel.cs" /> + <Compile Include="NuGet.PackageManagement.UI\PackageDetailControlModel.cs" /> + <Compile Include="MonoDevelop.PackageManagement\RecentNuGetPackagesRepository.cs" /> + <Compile Include="MonoDevelop.PackageManagement\PackageSearchResultViewModelComparer.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopPackageSourceProvider.cs" /> + <Compile Include="MonoDevelop.PackageManagement\SettingsLoader.cs" /> + <Compile Include="MonoDevelop.PackageManagement\INuGetPackageManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopNuGetPackageManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement\IBuildIntegratedNuGetProject.cs" /> + <Compile Include="MonoDevelop.PackageManagement\MonoDevelopPackageRestoreManager.cs" /> + <Compile Include="MonoDevelop.PackageManagement\BackgroundDispatcher.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.PackageManagement.addin.xml" /> @@ -524,11 +553,13 @@ </ItemGroup> <ItemGroup> <Folder Include="MonoDevelop.PackageManagement.NodeBuilders\" /> + <Folder Include="NuGet.PackageManagement.UI\" /> </ItemGroup> <ItemGroup> <None Include="..\..\..\external\nuget-binary\NuGet-LICENSE.txt"> <Link>NuGet-LICENSE.txt</Link> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> + <None Include="packages.config" /> </ItemGroup> </Project> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AcceptLicensesEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AcceptLicensesEventArgs.cs deleted file mode 100644 index 1ba27e9429..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AcceptLicensesEventArgs.cs +++ /dev/null @@ -1,45 +0,0 @@ -//
-// AcceptLicensesEventArgs.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class AcceptLicensesEventArgs : EventArgs
- {
- public AcceptLicensesEventArgs(IEnumerable<IPackage> packages)
- {
- this.Packages = packages;
- }
-
- public IEnumerable<IPackage> Packages { get; private set; }
- public bool IsAccepted { get; set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AggregatePackageSourceErrorMessage.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AggregatePackageSourceErrorMessage.cs new file mode 100644 index 0000000000..155cf6a6c8 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AggregatePackageSourceErrorMessage.cs @@ -0,0 +1,96 @@ +// +// AggregatePackageSourceErrorMessage.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Text; +using MonoDevelop.Core; + +namespace MonoDevelop.PackageManagement +{ + class AggregatePackageSourceErrorMessage + { + int totalPackageSources; + int failedPackageSourcesCount; + StringBuilder errorBuilder = new StringBuilder (); + + public AggregatePackageSourceErrorMessage (int totalPackageSources) + { + this.totalPackageSources = totalPackageSources; + ErrorMessage = String.Empty; + } + + public string ErrorMessage { get; private set; } + + public void AddError (string message) + { + failedPackageSourcesCount++; + + AppendErrorMessage (message); + + if (!MultiplePackageSources) { + ErrorMessage = errorBuilder.ToString (); + } else if (AllFailed) { + ErrorMessage = GetAllPackageSourcesCouldNotBeReachedErrorMessage (); + } else { + ErrorMessage = GetSomePackageSourcesCouldNotBeReachedErrorMessage (); + } + } + + bool MultiplePackageSources { + get { return totalPackageSources > 1; } + } + + bool AllFailed { + get { return failedPackageSourcesCount >= totalPackageSources; } + } + + void AppendErrorMessage (string message) + { + if (errorBuilder.Length == 0) { + errorBuilder.Append (message); + } else { + errorBuilder.AppendLine (); + errorBuilder.AppendLine (); + errorBuilder.Append (message); + } + } + + string GetAllPackageSourcesCouldNotBeReachedErrorMessage () + { + return GettextCatalog.GetString ("All package sources could not be reached.") + + Environment.NewLine + + errorBuilder.ToString (); + } + + string GetSomePackageSourcesCouldNotBeReachedErrorMessage () + { + return GettextCatalog.GetString ("Some package sources could not be reached.") + + Environment.NewLine + + errorBuilder.ToString (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AggregateSourceRepositoryViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AggregateSourceRepositoryViewModel.cs new file mode 100644 index 0000000000..4f7987e9e3 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AggregateSourceRepositoryViewModel.cs @@ -0,0 +1,44 @@ +// +// AggregateSourceRepositoryViewModel.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using NuGet.Configuration; +using NuGet.Protocol.Core.Types; + +namespace MonoDevelop.PackageManagement +{ + internal class AggregateSourceRepositoryViewModel : SourceRepositoryViewModel + { + public static readonly PackageSource AggregatePackageSource = + new PackageSource ("(Aggregate source)", "All"); + + public AggregateSourceRepositoryViewModel (IEnumerable<SourceRepository> repositories) + : base (repositories, AggregatePackageSource) + { + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AllPackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AllPackagesViewModel.cs new file mode 100644 index 0000000000..091e479a65 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AllPackagesViewModel.cs @@ -0,0 +1,594 @@ +//
+// AllPackagesViewModel.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Projects;
+using NuGet.Configuration;
+using NuGet.PackageManagement;
+using NuGet.PackageManagement.UI;
+using NuGet.Packaging;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+using NuGet.Versioning;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class AllPackagesViewModel : ViewModelBase<AllPackagesViewModel>, INuGetUILogger
+ {
+ SourceRepositoryViewModel selectedPackageSource;
+ IPackageSourceProvider packageSourceProvider;
+ PackageItemLoader currentLoader;
+ CancellationTokenSource cancellationTokenSource;
+ List<SourceRepositoryViewModel> packageSources;
+ bool includePrerelease;
+ bool ignorePackageCheckedChanged;
+ IMonoDevelopSolutionManager solutionManager;
+ NuGetProject nugetProject;
+ IDotNetProject dotNetProject;
+ INuGetProjectContext projectContext;
+ List<PackageReference> packageReferences = new List<PackageReference> ();
+ AggregatePackageSourceErrorMessage aggregateErrorMessage;
+ NuGetPackageManager packageManager;
+ RecentNuGetPackagesRepository recentPackagesRepository;
+
+ public static AllPackagesViewModel Create (RecentNuGetPackagesRepository recentPackagesRepository)
+ {
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (IdeApp.ProjectOperations.CurrentSelectedSolution);
+ var dotNetProject = new DotNetProjectProxy ((DotNetProject)IdeApp.ProjectOperations.CurrentSelectedProject);
+ return new AllPackagesViewModel (solutionManager, dotNetProject, recentPackagesRepository);
+ }
+
+ public AllPackagesViewModel (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ RecentNuGetPackagesRepository recentPackagesRepository)
+ : this (
+ solutionManager,
+ dotNetProject,
+ new NuGetProjectContext (),
+ recentPackagesRepository)
+ {
+ }
+
+ public AllPackagesViewModel (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext,
+ RecentNuGetPackagesRepository recentPackagesRepository)
+ {
+ this.solutionManager = solutionManager;
+ this.dotNetProject = dotNetProject;
+ this.projectContext = projectContext;
+ this.recentPackagesRepository = recentPackagesRepository;
+ PackageViewModels = new ObservableCollection<PackageSearchResultViewModel> ();
+ CheckedPackageViewModels = new ObservableCollection<PackageSearchResultViewModel> ();
+ ErrorMessage = String.Empty;
+
+ packageManager = new NuGetPackageManager (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solutionManager,
+ new DeleteOnRestartManager ()
+ );
+
+ nugetProject = solutionManager.GetNuGetProject (dotNetProject);
+ GetPackagesInstalledInProject ();
+ }
+
+ public NuGetProject NuGetProject {
+ get { return nugetProject; }
+ }
+
+ public IDotNetProject Project {
+ get { return dotNetProject; }
+ }
+ + public string SearchTerms { get; set; }
+
+ public IEnumerable<SourceRepositoryViewModel> PackageSources {
+ get {
+ if (packageSources == null) {
+ packageSources = GetPackageSources ().ToList ();
+ }
+ return packageSources;
+ }
+ }
+
+ IEnumerable<SourceRepositoryViewModel> GetPackageSources ()
+ {
+ ISourceRepositoryProvider provider = solutionManager.CreateSourceRepositoryProvider ();
+ packageSourceProvider = provider.PackageSourceProvider;
+ var repositories = provider.GetRepositories ().ToList ();
+
+ if (repositories.Count > 1) {
+ yield return new AggregateSourceRepositoryViewModel (repositories);
+ }
+
+ foreach (SourceRepository repository in repositories) {
+ yield return new SourceRepositoryViewModel (repository);
+ }
+ }
+
+ public SourceRepositoryViewModel SelectedPackageSource {
+ get {
+ if (selectedPackageSource == null) {
+ selectedPackageSource = GetActivePackageSource ();
+ }
+ return selectedPackageSource;
+ }
+ set {
+ if (selectedPackageSource != value) {
+ selectedPackageSource = value;
+ SaveActivePackageSource ();
+ ReadPackages ();
+ OnPropertyChanged (null);
+ }
+ }
+ }
+ + SourceRepositoryViewModel GetActivePackageSource ()
+ {
+ if (packageSources == null)
+ return null;
+
+ if (!String.IsNullOrEmpty (packageSourceProvider.ActivePackageSourceName)) {
+ SourceRepositoryViewModel packageSource = packageSources
+ .FirstOrDefault (viewModel => String.Equals (viewModel.PackageSource.Name, packageSourceProvider.ActivePackageSourceName, StringComparison.CurrentCultureIgnoreCase));
+ if (packageSource != null) {
+ return packageSource;
+ }
+ }
+
+ return packageSources.FirstOrDefault (packageSource => !packageSource.IsAggregate);
+ }
+
+ void SaveActivePackageSource ()
+ {
+ if (selectedPackageSource == null || packageSourceProvider == null)
+ return;
+
+ packageSourceProvider.SaveActivePackageSource (selectedPackageSource.PackageSource);
+ }
+ + public ObservableCollection<PackageSearchResultViewModel> PackageViewModels { get; private set; }
+ public ObservableCollection<PackageSearchResultViewModel> CheckedPackageViewModels { get; private set; }
+
+ public bool HasError { get; private set; }
+ public string ErrorMessage { get; private set; }
+
+ public bool IsLoadingNextPage { get; private set; }
+ public bool IsReadingPackages { get; private set; }
+ public bool HasNextPage { get; private set; }
+
+ public bool IncludePrerelease {
+ get { return includePrerelease; }
+ set {
+ if (includePrerelease != value) {
+ includePrerelease = value;
+ ReadPackages ();
+ OnPropertyChanged (null);
+ }
+ }
+ }
+
+ public void Dispose()
+ {
+ OnDispose ();
+ CancelReadPackagesTask ();
+ IsDisposed = true;
+ }
+ + protected virtual void OnDispose()
+ {
+ }
+
+ public bool IsDisposed { get; private set; }
+
+ public void Search ()
+ {
+ ReadPackages ();
+ OnPropertyChanged (null);
+ }
+
+ public void ReadPackages ()
+ {
+ if (SelectedPackageSource == null) {
+ return;
+ }
+
+ HasNextPage = false;
+ IsLoadingNextPage = false;
+ currentLoader = null;
+ StartReadPackagesTask ();
+ }
+
+ void StartReadPackagesTask (bool clearPackages = true)
+ {
+ IsReadingPackages = true;
+ ClearError ();
+ if (clearPackages) {
+ CancelReadPackagesTask ();
+ ClearPackages ();
+ }
+ CreateReadPackagesTask ();
+ }
+
+ void CancelReadPackagesTask()
+ {
+ if (cancellationTokenSource != null) {
+ // Cancel on another thread since CancellationTokenSource.Cancel can sometimes
+ // take up to a second on Mono and we do not want to block the UI thread.
+ var tokenSource = cancellationTokenSource;
+ Task.Run (() => {
+ try {
+ tokenSource.Cancel ();
+ tokenSource.Dispose ();
+ } catch (Exception ex) {
+ LoggingService.LogError ("Unable to cancel task.", ex);
+ }
+ });
+ cancellationTokenSource = null;
+ }
+ }
+
+ protected virtual Task CreateReadPackagesTask()
+ {
+ var loader = currentLoader ?? CreatePackageLoader ();
+ cancellationTokenSource = cancellationTokenSource ?? new CancellationTokenSource ();
+ return LoadPackagesAsync (loader, cancellationTokenSource.Token)
+ .ContinueWith (t => OnPackagesRead (t, loader), TaskScheduler.FromCurrentSynchronizationContext ());
+ }
+
+ PackageItemLoader CreatePackageLoader ()
+ {
+ var context = new PackageLoadContext (
+ selectedPackageSource.GetSourceRepositories (),
+ false,
+ nugetProject);
+
+ var loader = new PackageItemLoader (
+ context,
+ CreatePackageFeed (context.SourceRepositories),
+ SearchTerms,
+ IncludePrerelease
+ );
+
+ currentLoader = loader;
+
+ return loader;
+ }
+
+ protected virtual IPackageFeed CreatePackageFeed (IEnumerable<SourceRepository> sourceRepositories)
+ {
+ return new MultiSourcePackageFeed (sourceRepositories, this);
+ }
+
+ protected virtual Task LoadPackagesAsync (PackageItemLoader loader, CancellationToken token)
+ {
+ return Task.Run (async () => {
+ await loader.LoadNextAsync (null, token);
+
+ while (loader.State.LoadingStatus == LoadingStatus.Loading) {
+ token.ThrowIfCancellationRequested ();
+ await loader.UpdateStateAsync (null, token);
+ }
+ });
+ }
+
+ void ClearError ()
+ {
+ HasError = false;
+ ErrorMessage = String.Empty;
+ aggregateErrorMessage = new AggregatePackageSourceErrorMessage (GetTotalPackageSources ());
+ }
+
+ int GetTotalPackageSources ()
+ {
+ if (selectedPackageSource != null) {
+ return selectedPackageSource.GetSourceRepositories ().Count ();
+ }
+ return 0;
+ }
+
+ public void ShowNextPage ()
+ {
+ IsLoadingNextPage = true;
+ StartReadPackagesTask (false);
+ base.OnPropertyChanged (null);
+ }
+
+ void OnPackagesRead (Task task, PackageItemLoader loader)
+ {
+ IsReadingPackages = false;
+ IsLoadingNextPage = false;
+ if (task.IsFaulted) {
+ SaveError (task.Exception);
+ } else if (task.IsCanceled || !IsCurrentQuery (loader)) {
+ // Ignore.
+ return;
+ } else {
+ SaveAnyWarnings ();
+ UpdatePackagesForSelectedPage (loader);
+ }
+ base.OnPropertyChanged (null);
+ }
+
+ bool IsCurrentQuery (PackageItemLoader loader)
+ {
+ return currentLoader == loader;
+ }
+
+ void SaveError (AggregateException ex)
+ {
+ HasError = true;
+ ErrorMessage = GetErrorMessage (ex);
+ LoggingService.LogInfo ("PackagesViewModel error", ex);
+ }
+
+ string GetErrorMessage (AggregateException ex)
+ {
+ var errorMessage = new AggregateExceptionErrorMessage (ex);
+ return errorMessage.ToString ();
+ }
+
+ void SaveAnyWarnings ()
+ {
+ string warning = GetWarningMessage ();
+ if (!String.IsNullOrEmpty (warning)) {
+ HasError = true;
+ ErrorMessage = warning;
+ }
+ }
+
+ protected virtual string GetWarningMessage ()
+ {
+ return String.Empty;
+ }
+
+ void UpdatePackagesForSelectedPage (PackageItemLoader loader)
+ {
+ HasNextPage = loader.State.LoadingStatus == LoadingStatus.Ready;
+
+ UpdatePackageViewModels (loader.GetCurrent ());
+ }
+
+ void UpdatePackageViewModels (IEnumerable<PackageItemListViewModel> newPackageViewModels)
+ {
+ var packages = ConvertToPackageViewModels (newPackageViewModels).ToList ();
+ packages = PrioritizePackages (packages).ToList ();
+ + foreach (PackageSearchResultViewModel packageViewModel in packages) {
+ PackageViewModels.Add (packageViewModel);
+ }
+ }
+
+ public IEnumerable<PackageSearchResultViewModel> ConvertToPackageViewModels (IEnumerable<PackageItemListViewModel> itemViewModels)
+ {
+ foreach (PackageItemListViewModel itemViewModel in itemViewModels) {
+ PackageSearchResultViewModel packageViewModel = CreatePackageViewModel (itemViewModel);
+ UpdatePackageViewModelIfPreviouslyChecked (packageViewModel);
+ yield return packageViewModel;
+ }
+ }
+
+ PackageSearchResultViewModel CreatePackageViewModel (PackageItemListViewModel viewModel)
+ {
+ return new PackageSearchResultViewModel (this, viewModel);
+ }
+
+ void ClearPackages ()
+ {
+ PackageViewModels.Clear();
+ }
+
+ public void OnPackageCheckedChanged (PackageSearchResultViewModel packageViewModel)
+ {
+ if (ignorePackageCheckedChanged)
+ return;
+
+ if (packageViewModel.IsChecked) {
+ UncheckExistingCheckedPackageWithDifferentVersion (packageViewModel);
+ CheckedPackageViewModels.Add (packageViewModel);
+ } else {
+ CheckedPackageViewModels.Remove (packageViewModel);
+ }
+ }
+
+ void UpdatePackageViewModelIfPreviouslyChecked (PackageSearchResultViewModel packageViewModel)
+ {
+ ignorePackageCheckedChanged = true;
+ try {
+ PackageSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel (packageViewModel.Id);
+ if (existingPackageViewModel != null) {
+ packageViewModel.UpdateFromPreviouslyCheckedViewModel (existingPackageViewModel);
+ CheckedPackageViewModels.Remove (existingPackageViewModel);
+ CheckedPackageViewModels.Add (packageViewModel);
+ }
+ } finally {
+ ignorePackageCheckedChanged = false;
+ }
+ }
+
+ void UncheckExistingCheckedPackageWithDifferentVersion (PackageSearchResultViewModel packageViewModel)
+ {
+ PackageSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel (packageViewModel.Id);
+
+ if (existingPackageViewModel != null) {
+ CheckedPackageViewModels.Remove (existingPackageViewModel);
+ existingPackageViewModel.IsChecked = false;
+ }
+ }
+
+ PackageSearchResultViewModel GetExistingCheckedPackageViewModel (string packageId)
+ {
+ return CheckedPackageViewModels
+ .FirstOrDefault (item => item.Id == packageId);
+ }
+
+ public IPackageAction CreateInstallPackageAction (PackageSearchResultViewModel packageViewModel)
+ {
+ return new InstallNuGetPackageAction (
+ SelectedPackageSource.GetSourceRepositories (),
+ solutionManager,
+ dotNetProject,
+ projectContext
+ ) {
+ IncludePrerelease = IncludePrerelease,
+ PackageId = packageViewModel.Id,
+ Version = packageViewModel.SelectedVersion
+ };
+ }
+
+ public PackageSearchResultViewModel SelectedPackage { get; set; }
+
+ public bool IsOlderPackageInstalled (string id, NuGetVersion version)
+ {
+ return packageReferences.Any (packageReference => IsOlderPackageInstalled (packageReference, id, version));
+ }
+
+ bool IsOlderPackageInstalled (PackageReference packageReference, string id, NuGetVersion version)
+ {
+ return packageReference.PackageIdentity.Id == id &&
+ packageReference.PackageIdentity.Version < version;
+ }
+ + protected virtual Task GetPackagesInstalledInProject ()
+ {
+ return nugetProject
+ .GetInstalledPackagesAsync (CancellationToken.None)
+ .ContinueWith (task => OnReadInstalledPackages (task), TaskScheduler.FromCurrentSynchronizationContext ());
+ }
+
+ void OnReadInstalledPackages (Task<IEnumerable<PackageReference>> task)
+ {
+ try {
+ if (task.IsFaulted) {
+ LoggingService.LogError ("Unable to read installed packages.", task.Exception);
+ } else {
+ packageReferences = task.Result.ToList ();
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("OnReadInstalledPackages", ex);
+ }
+ }
+
+ void INuGetUILogger.Log (MessageLevel level, string message, params object [] args)
+ {
+ if (level == MessageLevel.Error) {
+ string fullErrorMessage = String.Format (message, args);
+ AppendErrorMessage (fullErrorMessage);
+ }
+ }
+
+ void AppendErrorMessage (string message)
+ {
+ aggregateErrorMessage.AddError (message);
+ ErrorMessage = aggregateErrorMessage.ErrorMessage;
+ HasError = true;
+ OnPropertyChanged (null);
+ }
+
+ public void LoadPackageMetadata (PackageSearchResultViewModel packageViewModel) + {
+ var provider = new MultiSourcePackageMetadataProvider (
+ selectedPackageSource.GetSourceRepositories (),
+ packageManager.PackagesFolderSourceRepository,
+ packageManager.GlobalPackagesFolderSourceRepository,
+ new NuGet.Logging.NullLogger ());
+ + packageViewModel.LoadPackageMetadata (provider, cancellationTokenSource.Token); + } + + public void OnInstallingSelectedPackages () + { + try {
+ UpdateRecentPackages ();
+ } catch (Exception ex) {
+ LoggingService.LogError ("Unable to update recent packages", ex);
+ } + }
+
+ void UpdateRecentPackages ()
+ {
+ if (SelectedPackageSource == null)
+ return;
+
+ if (CheckedPackageViewModels.Any ()) {
+ foreach (PackageSearchResultViewModel packageViewModel in CheckedPackageViewModels) {
+ recentPackagesRepository.AddPackage (packageViewModel, SelectedPackageSource.Name);
+ }
+ } else {
+ recentPackagesRepository.AddPackage (SelectedPackage, SelectedPackageSource.Name);
+ }
+ }
+
+ IEnumerable<PackageSearchResultViewModel> PrioritizePackages (IEnumerable<PackageSearchResultViewModel> packages)
+ {
+ var recentPackages = GetRecentPackages ().ToList ();
+
+ foreach (PackageSearchResultViewModel package in recentPackages) {
+ package.Parent = this;
+ package.ResetForRedisplay (IncludePrerelease);
+ yield return package;
+ }
+
+ foreach (PackageSearchResultViewModel package in packages) {
+ if (!recentPackages.Contains (package, PackageSearchResultViewModelComparer.Instance)) {
+ yield return package;
+ }
+ }
+ }
+
+ IEnumerable<PackageSearchResultViewModel> GetRecentPackages ()
+ {
+ if (PackageViewModels.Count == 0 &&
+ String.IsNullOrEmpty (SearchTerms) &&
+ selectedPackageSource != null) {
+ return recentPackagesRepository.GetPackages (SelectedPackageSource.Name)
+ .Where (recentPackage => SelectedVersionMatchesIncludePreleaseFilter (recentPackage));
+ }
+
+ return Enumerable.Empty<PackageSearchResultViewModel> ();
+ }
+
+ bool SelectedVersionMatchesIncludePreleaseFilter (PackageSearchResultViewModel package)
+ {
+ if (package.SelectedVersion.IsPrerelease) {
+ return IncludePrerelease;
+ }
+
+ return true;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AnalyzerPackageMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AnalyzerPackageMonitor.cs new file mode 100644 index 0000000000..56aeead2a9 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AnalyzerPackageMonitor.cs @@ -0,0 +1,111 @@ +//
+// AnalyzerPackageMonitor.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using MonoDevelop.Core;
+using MonoDevelop.Refactoring;
+using NuGet.Packaging;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class AnalyzerPackageMonitor
+ {
+ IPackageManagementEvents packageManagementEvents;
+ List<string> uninstalledFiles = new List<string> ();
+
+ public AnalyzerPackageMonitor ()
+ {
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+ packageManagementEvents.PackageInstalled += PackageInstalled;
+ packageManagementEvents.PackageUninstalling += PackageUninstalling;
+ packageManagementEvents.PackageUninstalled += PackageUninstalled;
+ packageManagementEvents.PackageOperationError += PackageOperationError;
+ }
+
+ void PackageInstalled (object sender, PackageManagementEventArgs e)
+ {
+ try {
+ //var files = GetFiles (e);
+ //Runtime.RunInMainThread (() => {
+ // AnalyzerPackageService.AddPackageFiles (e.Project.DotNetProject, files);
+ //});
+ } catch (Exception ex) {
+ LoggingService.LogError ("AnalyzerPackageMonitor error.", ex);
+ }
+ }
+
+ /// <summary>
+ /// TODO: Need to handle when an uninstall fails.
+ /// </summary>
+ void PackageUninstalling (object sender, PackageManagementEventArgs e)
+ {
+ try {
+ uninstalledFiles = GetFiles (e).ToList ();
+ } catch (Exception ex) {
+ LoggingService.LogError ("AnalyzerPackageMonitor error.", ex);
+ }
+ }
+
+ void PackageUninstalled (object sender, PackageManagementEventArgs e)
+ {
+ try {
+ //Runtime.RunInMainThread (() => {
+ // AnalyzerPackageService.RemovePackageFiles (e.Project.DotNetProject, uninstalledFiles);
+ //}).Wait ();
+ uninstalledFiles = new List<string> ();
+ } catch (Exception ex) {
+ LoggingService.LogError ("AnalyzerPackageMonitor error.", ex);
+ }
+ }
+
+ void PackageOperationError (object sender, EventArgs e)
+ {
+ uninstalledFiles = new List<string> ();
+ }
+
+ IEnumerable<string> GetFiles (PackageManagementEventArgs e)
+ {
+ if (String.IsNullOrEmpty (e.PackageFilePath))
+ return new string[0];
+
+ using (var packageStream = File.OpenRead (e.PackageFilePath)) {
+ var zipArchive = new ZipArchive (packageStream);
+
+ using (var packageReader = new PackageArchiveReader (zipArchive)) {
+ return packageReader
+ .GetFiles ()
+ .Select (file => Path.GetFullPath (Path.Combine (e.InstallPath, file)))
+ .ToList ();
+ }
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs deleted file mode 100644 index 9e3a3b2a80..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/AvailablePackagesViewModel.cs +++ /dev/null @@ -1,222 +0,0 @@ -//
-// AvailablePackagesViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-
-using MonoDevelop.PackageManagement;
-using NuGet;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class AvailablePackagesViewModel : PackagesViewModel
- {
- ISolutionPackageRepository solutionPackageRepository;
- IPackageRepository repository;
- string errorMessage;
- IRecentPackageRepository recentPackageRepository;
-
- public AvailablePackagesViewModel (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
- IRecentPackageRepository recentPackageRepository,
- IPackageViewModelFactory packageViewModelFactory,
- ITaskFactory taskFactory)
- : base(registeredPackageRepositories, packageViewModelFactory, taskFactory)
- {
- this.solutionPackageRepository = solution.GetRepository ();
- this.recentPackageRepository = recentPackageRepository;
-
- IsSearchable = true;
- ShowPackageSources = true;
- ShowPrerelease = true;
- }
-
- protected override void UpdateRepositoryBeforeReadPackagesTaskStarts()
- {
- try {
- repository = RegisteredPackageRepositories.ActiveRepository;
- } catch (Exception ex) {
- repository = null;
- errorMessage = ex.Message;
- }
- }
-
- protected override IQueryable<IPackage> GetPackages (PackageSearchCriteria search)
- {
- if (repository == null) {
- throw new ApplicationException (errorMessage);
- }
-
- if (search.IsPackageVersionSearch) {
- return repository
- .FindPackagesById (search.PackageId)
- .Where (package => IncludePrerelease || package.IsReleaseVersion ())
- .AsQueryable ();
- }
-
- if (IncludePrerelease) {
- return repository
- .Search (search.SearchText, new string[0], IncludePrerelease)
- .Where (package => package.IsAbsoluteLatestVersion);
- }
- return repository
- .Search (search.SearchText, new string[0], IncludePrerelease)
- .Where (package => package.IsLatestVersion);
- }
-
- /// <summary>
- /// Order packages by most downloaded first.
- /// </summary>
- protected override IQueryable<IPackage> OrderPackages (IQueryable<IPackage> packages, PackageSearchCriteria search)
- {
- if (search.IsPackageVersionSearch) {
- return packages.OrderByDescending (package => package.Version);
- }
-
- if (search.SearchText != null) {
- // Order by relevance for searches.
- return packages;
- }
- return packages.OrderByDescending(package => package.DownloadCount);
- }
-
- protected override IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults (IQueryable<IPackage> allPackages, PackageSearchCriteria search)
- {
- if (search.IsPackageVersionSearch) {
- return base.GetFilteredPackagesBeforePagingResults (allPackages, search)
- .Where (package => search.IsVersionMatch (package.Version));
- }
-
- if (IncludePrerelease) {
- return base.GetFilteredPackagesBeforePagingResults(allPackages, search)
- .DistinctLast<IPackage>(PackageEqualityComparer.Id);
- }
- return base.GetFilteredPackagesBeforePagingResults(allPackages, search)
- .Where(package => package.IsReleaseVersion())
- .DistinctLast<IPackage>(PackageEqualityComparer.Id);
- }
-
- /// <summary>
- /// Package prioritization:
- ///
- /// Recent packages first.
- /// Packages in solution.
- /// Packages from active package source.
- /// </summary>
- protected override IEnumerable<IPackage> PrioritizePackages (IEnumerable<IPackage> packages, PackageSearchCriteria search)
- {
- List<IPackage> prioritizedPackages = GetPrioritizedPackages (search).ToList ();
-
- foreach (IPackage package in prioritizedPackages) {
- yield return package;
- }
-
- foreach (IPackage package in packages) {
- if (!prioritizedPackages.Contains (package, PackageEqualityComparer.IdAndVersion)) {
- yield return package;
- }
- }
- }
-
- IEnumerable<IPackage> GetPrioritizedPackages (PackageSearchCriteria search)
- {
- if (search.IsPackageVersionSearch) {
- yield break;
- }
-
- List<IPackage> prioritizedPackages = GetRecentPackages (search).ToList ();
-
- if (PackageViewModels.Count == 0) {
- foreach (IPackage package in prioritizedPackages) {
- yield return package;
- }
-
- foreach (IPackage package in GetSolutionPackages (search)) {
- if (!prioritizedPackages.Contains (package, PackageEqualityComparer.IdAndVersion)) {
- prioritizedPackages.Add (package);
- yield return package;
- }
- }
- }
- }
-
- IEnumerable<IPackage> GetRecentPackages (PackageSearchCriteria search)
- {
- return recentPackageRepository.Search (search.SearchText, IncludePrerelease);
- }
-
- IEnumerable<IPackage> GetSolutionPackages (PackageSearchCriteria search)
- {
- try {
- return solutionPackageRepository
- .GetPackages ()
- .Find (search.SearchText)
- .FilterByPrerelease (IncludePrerelease)
- .ToList ();
- } catch (Exception ex) {
- LoggingService.LogError ("Unable to get solution packages so these will not be shown.", ex);
- return Enumerable.Empty<IPackage> ();
- }
- }
-
- protected override PackageViewModel CreatePackageViewModel (IPackage package, PackageSearchCriteria search)
- {
- PackageViewModel viewModel = base.CreatePackageViewModel (package, search);
- viewModel.ShowVersionInsteadOfDownloadCount = search.IsPackageVersionSearch;
- return viewModel;
- }
-
- protected override string GetWarningMessage ()
- {
- var aggregateRepository = repository as MonoDevelopAggregateRepository;
- if (aggregateRepository != null) {
- if (aggregateRepository.AllFailed ()) {
- return GetAllPackageSourcesCouldNotBeReachedErrorMessage (aggregateRepository);
- } else if (aggregateRepository.AnyFailures ()) {
- return GetSomePackageSourcesCouldNotBeReachedErrorMessage (aggregateRepository);
- }
- }
- return String.Empty;
- }
-
- string GetAllPackageSourcesCouldNotBeReachedErrorMessage (MonoDevelopAggregateRepository repository)
- {
- string message = GettextCatalog.GetString ("All package sources could not be reached.");
- return new AggregateExceptionErrorMessage (message, repository.GetAggregateException ()).ToString ();
- }
-
- string GetSomePackageSourcesCouldNotBeReachedErrorMessage (MonoDevelopAggregateRepository repository)
- {
- string message = GettextCatalog.GetString ("Some package sources could not be reached.");
- return new AggregateExceptionErrorMessage (message, repository.GetAggregateException ()).ToString ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundDispatcher.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundDispatcher.cs new file mode 100644 index 0000000000..7077231486 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundDispatcher.cs @@ -0,0 +1,100 @@ +// +// BackgroundDispatcher.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading; +using MonoDevelop.Core; + +namespace MonoDevelop.PackageManagement +{ + class BackgroundDispatcher + { + Queue<Action> backgroundQueue = new Queue<Action> (); + ManualResetEvent backgroundThreadWait = new ManualResetEvent (false); + Thread backgroundThread; + bool stopped; + + public void Start (string name) + { + backgroundThread = new Thread (new ThreadStart (RunDispatcher)) { + Name = name, + IsBackground = true, + Priority = ThreadPriority.Lowest, + }; + backgroundThread.Start (); + } + + void RunDispatcher () + { + while (!stopped) { + Action action = null; + bool wait = false; + lock (backgroundQueue) { + if (backgroundQueue.Count == 0) { + backgroundThreadWait.Reset (); + wait = true; + } else + action = backgroundQueue.Dequeue (); + } + + if (wait) { + backgroundThreadWait.WaitOne (); + continue; + } + + if (action != null) { + try { + action (); + } catch (Exception ex) { + LoggingService.LogError ("BackgroundDispatcher error.", ex); + } + } + } + } + + public void Dispatch (Action action) + { + QueueBackground (action); + } + + void QueueBackground (Action action) + { + lock (backgroundQueue) { + backgroundQueue.Enqueue (action); + if (backgroundQueue.Count == 1) + backgroundThreadWait.Set (); + } + } + + public void Stop () + { + stopped = true; + backgroundThreadWait.Set (); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs index 49c4b94f00..491bb1c5a4 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BackgroundPackageActionRunner.cs @@ -27,9 +27,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using MonoDevelop.PackageManagement;
+using System.Threading.Tasks;
using MonoDevelop.Core;
-using MonoDevelop.Ide;
using MonoDevelop.Projects;
using NuGet;
@@ -37,36 +36,43 @@ namespace MonoDevelop.PackageManagement {
internal class BackgroundPackageActionRunner : IBackgroundPackageActionRunner
{
- static MonoDevelop.Core.Instrumentation.Counter InstallPackageCounter = MonoDevelop.Core.Instrumentation.InstrumentationService.CreateCounter ("Package Installed", "Package Management", id:"PackageManagement.Package.Installed");
- static MonoDevelop.Core.Instrumentation.Counter UninstallPackageCounter = MonoDevelop.Core.Instrumentation.InstrumentationService.CreateCounter ("Package Uninstalled", "Package Management", id:"PackageManagement.Package.Uninstalled");
-
IPackageManagementProgressMonitorFactory progressMonitorFactory;
IPackageManagementEvents packageManagementEvents;
- IProgressProvider progressProvider;
- List<InstallPackageAction> pendingInstallActions = new List<InstallPackageAction> ();
+ PackageManagementInstrumentationService instrumentationService;
+ List<IInstallNuGetPackageAction> pendingInstallActions = new List<IInstallNuGetPackageAction> ();
int runCount;
public BackgroundPackageActionRunner (
IPackageManagementProgressMonitorFactory progressMonitorFactory,
+ IPackageManagementEvents packageManagementEvents)
+ : this (
+ progressMonitorFactory,
+ packageManagementEvents,
+ new PackageManagementInstrumentationService ())
+ {
+ }
+
+ public BackgroundPackageActionRunner (
+ IPackageManagementProgressMonitorFactory progressMonitorFactory,
IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ PackageManagementInstrumentationService instrumentationService)
{
this.progressMonitorFactory = progressMonitorFactory;
this.packageManagementEvents = packageManagementEvents;
- this.progressProvider = progressProvider;
+ this.instrumentationService = instrumentationService;
}
public bool IsRunning {
get { return runCount > 0; }
}
- public IEnumerable<InstallPackageAction> PendingInstallActions {
+ public IEnumerable<IInstallNuGetPackageAction> PendingInstallActions {
get { return pendingInstallActions; }
}
- public IEnumerable<InstallPackageAction> PendingInstallActionsForProject (DotNetProject project)
+ public IEnumerable<IInstallNuGetPackageAction> PendingInstallActionsForProject (DotNetProject project)
{
- return pendingInstallActions.Where (action => action.Project.DotNetProject == project);
+ return pendingInstallActions.Where (action => action.IsForProject (project));
}
public void Run (ProgressMonitorStatusMessage progressMessage, IPackageAction action)
@@ -76,29 +82,47 @@ namespace MonoDevelop.PackageManagement public void Run (ProgressMonitorStatusMessage progressMessage, IEnumerable<IPackageAction> actions)
{
+ Run (progressMessage, actions, null);
+ }
+
+ void Run (
+ ProgressMonitorStatusMessage progressMessage,
+ IEnumerable<IPackageAction> actions,
+ TaskCompletionSource<bool> taskCompletionSource)
+ {
AddInstallActionsToPendingQueue (actions);
packageManagementEvents.OnPackageOperationsStarting ();
runCount++;
List<IPackageAction> actionsList = actions.ToList ();
BackgroundDispatch (() => {
- TryRunActionsWithProgressMonitor (progressMessage, actionsList);
+ TryRunActionsWithProgressMonitor (progressMessage, actionsList, taskCompletionSource);
actionsList = null;
progressMessage = null;
});
}
+ public Task RunAsync (ProgressMonitorStatusMessage progressMessage, IEnumerable<IPackageAction> actions)
+ {
+ var taskCompletionSource = new TaskCompletionSource<bool> ();
+ Run (progressMessage, actions, taskCompletionSource);
+ return taskCompletionSource.Task;
+ }
+
void AddInstallActionsToPendingQueue (IEnumerable<IPackageAction> actions)
{
- foreach (InstallPackageAction action in actions.OfType<InstallPackageAction> ()) {
+ foreach (IInstallNuGetPackageAction action in actions.OfType<IInstallNuGetPackageAction> ()) {
pendingInstallActions.Add (action);
}
}
- void TryRunActionsWithProgressMonitor (ProgressMonitorStatusMessage progressMessage, IList<IPackageAction> actions)
+ void TryRunActionsWithProgressMonitor (
+ ProgressMonitorStatusMessage progressMessage,
+ IList<IPackageAction> actions,
+ TaskCompletionSource<bool> taskCompletionSource)
{
try {
- RunActionsWithProgressMonitor (progressMessage, actions);
+ RunActionsWithProgressMonitor (progressMessage, actions, taskCompletionSource);
} catch (Exception ex) {
LoggingService.LogInternalError (ex);
} finally {
@@ -106,10 +130,13 @@ namespace MonoDevelop.PackageManagement }
}
- void RunActionsWithProgressMonitor (ProgressMonitorStatusMessage progressMessage, IList<IPackageAction> installPackageActions)
+ void RunActionsWithProgressMonitor (
+ ProgressMonitorStatusMessage progressMessage,
+ IList<IPackageAction> installPackageActions,
+ TaskCompletionSource<bool> taskCompletionSource)
{
using (ProgressMonitor monitor = progressMonitorFactory.CreateProgressMonitor (progressMessage.Status)) {
- using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor (monitor)) {
+ using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor (monitor, taskCompletionSource)) {
try {
monitor.BeginTask (null, installPackageActions.Count);
RunActionsWithProgressMonitor (monitor, installPackageActions);
@@ -128,80 +155,31 @@ namespace MonoDevelop.PackageManagement }
}
- PackageManagementEventsMonitor CreateEventMonitor (ProgressMonitor monitor)
+ PackageManagementEventsMonitor CreateEventMonitor (ProgressMonitor monitor, TaskCompletionSource<bool> taskCompletionSource)
{
- return CreateEventMonitor (monitor, packageManagementEvents, progressProvider);
+ return CreateEventMonitor (monitor, packageManagementEvents, taskCompletionSource);
}
protected virtual PackageManagementEventsMonitor CreateEventMonitor (
ProgressMonitor monitor,
IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ TaskCompletionSource<bool> taskCompletionSource)
{
- return new PackageManagementEventsMonitor (monitor, packageManagementEvents, progressProvider);
+ return new PackageManagementEventsMonitor (monitor, packageManagementEvents, taskCompletionSource);
}
void RunActionsWithProgressMonitor (ProgressMonitor monitor, IList<IPackageAction> packageActions)
{
foreach (IPackageAction action in packageActions) {
- action.Execute ();
- InstrumentPackageAction (action);
+ action.Execute (monitor.CancellationToken);
+ instrumentationService.InstrumentPackageAction (action);
monitor.Step (1);
}
}
- protected virtual void InstrumentPackageAction (IPackageAction action)
- {
- try {
- var addAction = action as InstallPackageAction;
- if (addAction != null) {
- InstrumentPackageOperations (addAction.Operations);
- return;
- }
-
- var updateAction = action as UpdatePackageAction;
- if (updateAction != null) {
- InstrumentPackageOperations (updateAction.Operations);
- return;
- }
-
- var removeAction = action as UninstallPackageAction;
- if (removeAction != null) {
- var metadata = new Dictionary<string, string> ();
-
- metadata ["PackageId"] = removeAction.GetPackageId ();
- var version = removeAction.GetPackageVersion ();
- if (version != null)
- metadata ["PackageVersion"] = version.ToString ();
-
- UninstallPackageCounter.Inc (1, null, metadata);
- }
- } catch (Exception ex) {
- LoggingService.LogError ("Instrumentation Failure in PackageManagement", ex);
- }
- }
-
- static void InstrumentPackageOperations (IEnumerable<PackageOperation> operations)
- {
- foreach (var op in operations) {
- var metadata = new Dictionary<string, string> ();
- metadata ["PackageId"] = op.Package.Id;
- metadata ["Package"] = op.Package.Id + " v" + op.Package.Version.ToString ();
-
- switch (op.Action) {
- case PackageAction.Install:
- InstallPackageCounter.Inc (1, null, metadata);
- break;
- case PackageAction.Uninstall:
- UninstallPackageCounter.Inc (1, null, metadata);
- break;
- }
- }
- }
-
void RemoveInstallActions (IList<IPackageAction> installPackageActions)
{
- foreach (InstallPackageAction action in installPackageActions.OfType <InstallPackageAction> ()) {
+ foreach (IInstallNuGetPackageAction action in installPackageActions.OfType<IInstallNuGetPackageAction> ()) {
pendingInstallActions.Remove (action);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BuildIntegrationProjectSystem.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BuildIntegrationProjectSystem.cs new file mode 100644 index 0000000000..0cc5e18611 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/BuildIntegrationProjectSystem.cs @@ -0,0 +1,409 @@ +//
+// BuildIntegratedProjectSystem.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// based on NuGet.Clients
+// src/NuGet.Clients/PackageManagement.VisualStudio/ProjectSystems/BuildIntegratedProjectSystem.cs
+//
+// Copyright (c) 2016 Xamarin Inc.
+// Copyright (c) .NET Foundation. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.Common;
+using NuGet.Configuration;
+using NuGet.PackageManagement;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+using NuGet.ProjectManagement.Projects;
+using NuGet.ProjectModel;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class BuildIntegratedProjectSystem : BuildIntegratedNuGetProject, IBuildIntegratedNuGetProject
+ {
+ IDotNetProject dotNetProject;
+ PackageManagementEvents packageManagementEvents;
+ VersionFolderPathResolver packagePathResolver;
+
+ public BuildIntegratedProjectSystem (
+ string jsonConfigPath,
+ string msbuildProjectFilePath,
+ DotNetProject dotNetProject,
+ IMSBuildNuGetProjectSystem msbuildProjectSystem,
+ string uniqueName,
+ ISettings settings)
+ : base (jsonConfigPath, msbuildProjectFilePath, msbuildProjectSystem)
+ {
+ this.dotNetProject = new DotNetProjectProxy (dotNetProject);
+ packageManagementEvents = (PackageManagementEvents)PackageManagementServices.PackageManagementEvents;
+
+ string path = SettingsUtility.GetGlobalPackagesFolder (settings);
+ packagePathResolver = new VersionFolderPathResolver (path, normalizePackageId: false);
+ }
+
+ public override Task<bool> ExecuteInitScriptAsync (PackageIdentity identity, string packageInstallPath, INuGetProjectContext projectContext, bool throwOnFailure)
+ {
+ // Not supported. This gets called for every NuGet package
+ // even if they do not have an init.ps1 so do not report this.
+ return Task.FromResult (false);
+ }
+
+ public override Task PostProcessAsync (INuGetProjectContext nuGetProjectContext, System.Threading.CancellationToken token)
+ {
+ packageManagementEvents.OnFileChanged (JsonConfigPath);
+
+ return base.PostProcessAsync (nuGetProjectContext, token);
+ }
+
+ public void OnAfterExecuteActions (IEnumerable<NuGetProjectAction> actions)
+ {
+ ProcessActions (actions, OnPackageInstalled, OnPackageUninstalled);
+ }
+
+ public void OnBeforeUninstall (IEnumerable<NuGetProjectAction> actions)
+ {
+ ProcessActions (actions, identity => {}, OnPackageUninstalling);
+ } +
+ void ProcessActions (
+ IEnumerable<NuGetProjectAction> actions,
+ Action<PackageIdentity> installAction,
+ Action<PackageIdentity> uninstallAction) + { + foreach (var action in actions) {
+ if (action.NuGetProjectActionType == NuGetProjectActionType.Install) {
+ installAction (action.PackageIdentity);
+ } else if (action.NuGetProjectActionType == NuGetProjectActionType.Uninstall) {
+ uninstallAction (action.PackageIdentity);
+ }
+ } + }
+
+ void OnPackageInstalled (PackageIdentity identity)
+ {
+ var eventArgs = CreatePackageEventArgs (identity);
+ packageManagementEvents.OnPackageInstalled (dotNetProject, eventArgs);
+ }
+
+ PackageEventArgs CreatePackageEventArgs (PackageIdentity identity)
+ {
+ string installPath = packagePathResolver.GetInstallPath (identity.Id, identity.Version);
+ return new PackageEventArgs (this, identity, installPath);
+ }
+
+ void OnPackageUninstalling (PackageIdentity identity)
+ {
+ var eventArgs = CreatePackageEventArgs (identity);
+ packageManagementEvents.OnPackageUninstalling (dotNetProject, eventArgs);
+ }
+
+ void OnPackageUninstalled (PackageIdentity identity)
+ {
+ var eventArgs = CreatePackageEventArgs (identity);
+ packageManagementEvents.OnPackageUninstalled (dotNetProject, eventArgs);
+ }
+
+ public override Task<IReadOnlyList<ExternalProjectReference>> GetProjectReferenceClosureAsync (ExternalProjectReferenceContext context)
+ {
+ return Runtime.RunInMainThread (() => {
+ return GetExternalProjectReferenceClosureAsync (context);
+ });
+ }
+
+ /// <summary>
+ /// Returns the closure of all project to project references below this project.
+ /// The code is a port of src/NuGet.Clients/PackageManagement.VisualStudio/ProjectSystems/BuildIntegratedProjectSystem.cs
+ /// </summary>
+ Task<IReadOnlyList<ExternalProjectReference>> GetExternalProjectReferenceClosureAsync (ExternalProjectReferenceContext context)
+ {
+ var logger = context.Logger;
+ var cache = context.Cache;
+
+ var results = new HashSet<ExternalProjectReference> ();
+
+ // projects to walk - DFS
+ var toProcess = new Stack<DotNetProjectReference> ();
+
+ // keep track of found projects to avoid duplicates
+ string rootProjectPath = dotNetProject.FileName;
+
+ // start with the current project
+ toProcess.Push (new DotNetProjectReference (dotNetProject.DotNetProject, rootProjectPath));
+
+ var uniqueNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
+
+ // continue walking all project references until we run out
+ while (toProcess.Count > 0) {
+ var reference = toProcess.Pop ();
+
+ // Find the path of the current project
+ string projectFileFullPath = reference.Path;
+ var project = reference.Project;
+
+ if (string.IsNullOrEmpty(projectFileFullPath) || !uniqueNames.Add (projectFileFullPath)) {
+ // This has already been processed or does not exist
+ continue;
+ }
+
+ IReadOnlyList<ExternalProjectReference> cacheReferences;
+ if (cache.TryGetValue (projectFileFullPath, out cacheReferences)) {
+ // The cached value contains the entire closure, add it to the results and skip
+ // all child references.
+ results.UnionWith (cacheReferences);
+ } else {
+ // Get direct references
+ var projectResult = GetDirectProjectReferences (
+ reference.Project,
+ projectFileFullPath,
+ context,
+ rootProjectPath);
+
+ // Add results to the closure
+ results.UnionWith (projectResult.Processed);
+
+ // Continue processing
+ foreach (var item in projectResult.ToProcess) {
+ toProcess.Push (item);
+ }
+ }
+ }
+
+ // Cache the results for this project and every child project which has not been cached
+ foreach (var project in results) {
+ if (!context.Cache.ContainsKey (project.UniqueName)) {
+ var closure = BuildIntegratedRestoreUtility.GetExternalClosure (project.UniqueName, results);
+
+ context.Cache.Add(project.UniqueName, closure.ToList ());
+ }
+ }
+
+ var result = cache[rootProjectPath];
+ return Task.FromResult (result);
+ }
+
+ /// <summary>
+ /// Get only the direct dependencies from a project
+ /// </summary>
+ private DirectReferences GetDirectProjectReferences(
+ DotNetProject project,
+ string projectFileFullPath,
+ ExternalProjectReferenceContext context,
+ string rootProjectPath)
+ {
+ var logger = context.Logger;
+ var cache = context.Cache;
+
+ var result = new DirectReferences ();
+
+ // Find a project.json in the project
+ // This checks for files on disk to match how BuildIntegratedProjectSystem checks at creation time.
+ // NuGet.exe also uses disk paths and not the project file.
+ var projectName = Path.GetFileNameWithoutExtension (projectFileFullPath);
+
+ var projectDirectory = Path.GetDirectoryName (projectFileFullPath);
+
+ // Check for projectName.project.json and project.json
+ string jsonConfigItem =
+ ProjectJsonPathUtilities.GetProjectConfigPath (
+ directoryPath: projectDirectory,
+ projectName: projectName);
+
+ var hasProjectJson = true;
+
+ // Verify the file exists, otherwise clear it
+ if (!File.Exists(jsonConfigItem)) {
+ jsonConfigItem = null;
+ hasProjectJson = false;
+ }
+
+ // Verify ReferenceOutputAssembly
+ var excludedProjects = GetExcludedReferences (project);
+
+ var childReferences = new HashSet<string> (StringComparer.Ordinal);
+ var hasMissingReferences = false;
+
+ // find all references in the project
+ foreach (var childReference in project.References) {
+ try {
+ if (!childReference.IsValid) {
+ // Skip missing references and show a warning
+ hasMissingReferences = true;
+ continue;
+ }
+
+ // Skip missing references
+ DotNetProject sourceProject = null;
+ if (childReference.ReferenceType == ReferenceType.Project) {
+ sourceProject = childReference.ResolveProject (project.ParentSolution) as DotNetProject;
+ }
+
+ if (sourceProject != null) {
+
+ string childName = sourceProject.FileName;
+
+ // Skip projects which have ReferenceOutputAssembly=false
+ if (!string.IsNullOrEmpty (childName)
+ && !excludedProjects.Contains (childName, StringComparer.OrdinalIgnoreCase)) {
+ childReferences.Add (childName);
+
+ result.ToProcess.Add (new DotNetProjectReference (sourceProject, childName));
+ }
+ } else if (hasProjectJson) {
+ // SDK references do not have a SourceProject or child references,
+ // but they can contain project.json files, and should be part of the closure
+ // SDKs are not projects, only the project.json name is checked here
+ //var possibleSdkPath = childReference.Path;
+
+ //if (!string.IsNullOrEmpty (possibleSdkPath)
+ // && !possibleSdkPath.EndsWith (".dll", StringComparison.OrdinalIgnoreCase)
+ // && Directory.Exists(possibleSdkPath)) {
+ // var possibleProjectJson = Path.Combine (
+ // possibleSdkPath,
+ // ProjectJsonPathUtilities.ProjectConfigFileName);
+
+ // if (File.Exists (possibleProjectJson)) {
+ // childReferences.Add (possibleProjectJson);
+
+ // // add the sdk to the results here
+ // result.Processed.Add (new ExternalProjectReference (
+ // possibleProjectJson,
+ // childReference.Name,
+ // possibleProjectJson,
+ // msbuildProjectPath: null,
+ // projectReferences: Enumerable.Empty<string> ()));
+ // }
+ //}
+ }
+ } catch (Exception ex) {
+ // Exceptions are expected in some scenarios for native projects,
+ // ignore them and show a warning
+ hasMissingReferences = true;
+
+ logger.LogDebug (ex.Message);
+
+ LoggingService.LogError ("Unable to find project closure.", ex);
+ }
+ }
+
+ if (hasMissingReferences) {
+ // Log a warning message once per project
+ // This warning contains only the names of the root project and the project with the
+ // broken reference. Attempting to display more details on the actual reference
+ // that has the problem may lead to another exception being thrown.
+ var warning = GettextCatalog.GetString ("Failed to resolve all project references for '{0}'. The package restore result for '{1}' may be incomplete.",
+ projectName,
+ rootProjectPath);
+
+ logger.LogWarning (warning);
+ }
+
+ // Only set a package spec project name if a package spec exists
+ var packageSpecProjectName = jsonConfigItem == null ? null : projectName;
+
+ // Add the parent project to the results
+ result.Processed.Add (new ExternalProjectReference (
+ projectFileFullPath,
+ packageSpecProjectName,
+ jsonConfigItem,
+ projectFileFullPath,
+ childReferences));
+
+ return result;
+ }
+
+ /// <summary>
+ /// Get the unique names of all references which have ReferenceOutputAssembly set to false.
+ /// </summary>
+ static List<string> GetExcludedReferences (DotNetProject project)
+ {
+ var excludedReferences = new List<string> ();
+
+ foreach (var reference in project.References) {
+ // 1. Verify that this is a project reference
+ // 2. Check that it is valid and resolved
+ // 3. Follow the reference to the DotNetProject and get the unique name
+ if (!reference.ReferenceOutputAssembly &&
+ reference.IsValid &&
+ reference.ReferenceType == ReferenceType.Project) {
+
+ var sourceProject = reference.ResolveProject (project.ParentSolution);
+ if (sourceProject != null) {
+ string childPath = sourceProject.FileName;
+ excludedReferences.Add (childPath);
+ }
+ }
+ }
+
+ return excludedReferences;
+ }
+
+
+ /// <summary>
+ /// Top level references
+ /// </summary>
+ class DirectReferences
+ {
+ public HashSet<DotNetProjectReference> ToProcess { get; } = new HashSet<DotNetProjectReference> ();
+
+ public HashSet<ExternalProjectReference> Processed { get; } = new HashSet<ExternalProjectReference> ();
+ }
+
+ /// <summary>
+ /// Holds the full path to a project and the project.
+ /// </summary>
+ private class DotNetProjectReference : IEquatable<DotNetProjectReference>, IComparable<DotNetProjectReference>
+ {
+ public DotNetProjectReference (DotNetProject project, string path)
+ {
+ Project = project;
+ Path = path;
+ }
+
+ public DotNetProject Project { get; }
+
+ public string Path { get; }
+
+ public bool Equals (DotNetProjectReference other)
+ {
+ return StringComparer.Ordinal.Equals (Path, other.Path);
+ }
+
+ public int CompareTo (DotNetProjectReference other)
+ {
+ return StringComparer.Ordinal.Compare (Path, other.Path);
+ }
+
+ public override int GetHashCode ()
+ {
+ return StringComparer.Ordinal.GetHashCode (Path);
+ }
+
+ public override bool Equals (object obj)
+ {
+ return Equals (obj as DotNetProjectReference);
+ }
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForNuGetPackageUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForNuGetPackageUpdatesTaskRunner.cs new file mode 100644 index 0000000000..3d6f214459 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForNuGetPackageUpdatesTaskRunner.cs @@ -0,0 +1,170 @@ +// +// CheckForNuGetPackageUpdatesTaskRunner.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core; +using NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement
+{
+ internal class CheckForNuGetPackageUpdatesTaskRunner
+ {
+ UpdatedNuGetPackagesInWorkspace updatedNuGetPackagesInWorkspace;
+ List<UpdatedNuGetPackagesProvider> currentProviders;
+ CancellationTokenSource cancellationTokenSource;
+
+ public CheckForNuGetPackageUpdatesTaskRunner (UpdatedNuGetPackagesInWorkspace updatedNuGetPackagesInWorkspace)
+ {
+ this.updatedNuGetPackagesInWorkspace = updatedNuGetPackagesInWorkspace;
+ }
+
+ public bool IsRunning {
+ get { return cancellationTokenSource != null; }
+ }
+
+ public void Start (IEnumerable<IDotNetProject> projects)
+ {
+ Stop ();
+ CheckForUpdates (projects);
+ }
+
+ protected virtual Task CheckForUpdates (IEnumerable<IDotNetProject> projects)
+ {
+ cancellationTokenSource = new CancellationTokenSource ();
+
+ var providers = projects.Select (project => CreateProvider (project)).ToList ();
+ currentProviders = providers;
+
+ return Task.Run (
+ () => CheckForUpdates (currentProviders, cancellationTokenSource.Token),
+ cancellationTokenSource.Token
+ ).ContinueWith (
+ task => OnCheckForUpdatesCompleted (task, providers),
+ TaskScheduler.FromCurrentSynchronizationContext ());
+ }
+
+ UpdatedNuGetPackagesProvider CreateProvider (IDotNetProject project)
+ {
+ var solutionManager = GetSolutionManager (project.ParentSolution); + var nugetProject = CreateNuGetProject (solutionManager, project);
+ return new UpdatedNuGetPackagesProvider (
+ project,
+ solutionManager, + nugetProject,
+ cancellationTokenSource.Token);
+ }
+
+ protected virtual IMonoDevelopSolutionManager GetSolutionManager (ISolution solution)
+ {
+ return PackageManagementServices.Workspace.GetSolutionManager (solution);
+ }
+
+ protected virtual NuGetProject CreateNuGetProject ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject project) + { + return new MonoDevelopNuGetProjectFactory (solutionManager.Settings) + .CreateNuGetProject (project); + }
+ + List<UpdatedNuGetPackagesInProject> CheckForUpdates (List<UpdatedNuGetPackagesProvider> providers, CancellationToken cancellationToken)
+ {
+ var updatedPackages = new List<UpdatedNuGetPackagesInProject> ();
+ foreach (UpdatedNuGetPackagesProvider provider in providers) {
+ if (cancellationToken.IsCancellationRequested) {
+ break;
+ }
+
+ provider.FindUpdatedPackages ().Wait ();
+
+ if (provider.UpdatedPackagesInProject.AnyPackages ()) {
+ updatedPackages.Add (provider.UpdatedPackagesInProject);
+ }
+ }
+
+ return updatedPackages;
+ }
+ + public void Dispose ()
+ {
+ Stop ();
+ }
+
+ public void Stop ()
+ {
+ if (cancellationTokenSource != null) {
+ cancellationTokenSource.Cancel ();
+ cancellationTokenSource.Dispose ();
+ cancellationTokenSource = null;
+ }
+
+ currentProviders = null;
+ }
+
+ void OnCheckForUpdatesCompleted (Task<List<UpdatedNuGetPackagesInProject>> task, List<UpdatedNuGetPackagesProvider> providers)
+ {
+ if (task.IsFaulted) {
+ if (IsCurrentTask (providers)) {
+ LogError ("Current check for updates task error.", task.Exception);
+ } else {
+ LogError ("Check for updates task error.", task.Exception);
+ }
+ } else if (task.IsCanceled) {
+ // Ignore.
+ return;
+ } else if (!IsCurrentTask (providers)) {
+ return;
+ } else {
+ currentProviders = null;
+ if (cancellationTokenSource != null) {
+ cancellationTokenSource.Dispose ();
+ cancellationTokenSource = null;
+ }
+ updatedNuGetPackagesInWorkspace.CheckForUpdatesCompleted (task.Result);
+ }
+ }
+
+ bool IsCurrentTask (List<UpdatedNuGetPackagesProvider> providers)
+ {
+ return currentProviders == providers;
+ }
+
+ protected virtual void LogError (string message, Exception ex)
+ {
+ LoggingService.LogError (message, ex);
+ }
+
+ protected virtual void GuiBackgroundDispatch (Action action)
+ {
+ PackageManagementBackgroundDispatcher.Dispatch (action);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatedPackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatedPackagesAction.cs index bdc748dc10..17a672ea88 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatedPackagesAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatedPackagesAction.cs @@ -24,25 +24,29 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
+using System.Threading;
+using MonoDevelop.Projects;
namespace MonoDevelop.PackageManagement
{
internal class CheckForUpdatedPackagesAction : IPackageAction
{
- IUpdatedPackagesInSolution updatedPackagesInSolution;
+ IUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace;
+ ISolution solution;
- public CheckForUpdatedPackagesAction ()
- : this (PackageManagementServices.UpdatedPackagesInSolution)
+ public CheckForUpdatedPackagesAction (Solution solution)
+ : this (
+ new SolutionProxy (solution),
+ PackageManagementServices.UpdatedPackagesInWorkspace)
{
}
public CheckForUpdatedPackagesAction (
- IUpdatedPackagesInSolution updatedPackagesInSolution)
+ ISolution solution,
+ IUpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace)
{
- this.updatedPackagesInSolution = updatedPackagesInSolution;
+ this.solution = solution;
+ this.updatedPackagesInWorkspace = updatedPackagesInWorkspace;
}
public bool HasPackageScriptsToRun ()
@@ -52,10 +56,15 @@ namespace MonoDevelop.PackageManagement public void Execute ()
{
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
// Queue the check for updates with the background dispatcher so
// the NuGet addin does not create another separate Package Console.
PackageManagementBackgroundDispatcher.Dispatch (() => {
- updatedPackagesInSolution.CheckForUpdates ();
+ updatedPackagesInWorkspace.CheckForUpdates (solution);
});
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs deleted file mode 100644 index 45b7375059..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTask.cs +++ /dev/null @@ -1,86 +0,0 @@ -//
-// CheckForUpdatesTaskResult.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;
-using System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class CheckForUpdatesTask : IDisposable
- {
- UpdatedPackagesInSolution updatedPackagesInSolution;
- List<IPackageManagementProject> projects;
- List<UpdatedPackagesInProject> projectsWithUpdatedPackages = new List<UpdatedPackagesInProject> ();
- bool disposed;
-
- public CheckForUpdatesTask (
- UpdatedPackagesInSolution updatedPackagesInSolution,
- IEnumerable<IPackageManagementProject> projects)
- {
- this.updatedPackagesInSolution = updatedPackagesInSolution;
- this.projects = projects.ToList ();
- }
-
- public void CheckForUpdates ()
- {
- foreach (IPackageManagementProject project in projects) {
-
- UpdatedPackagesInProject updatedPackages = updatedPackagesInSolution.CheckForUpdates (project);
-
- if (disposed) {
- break;
- }
-
- if (updatedPackages.AnyPackages ()) {
- projectsWithUpdatedPackages.Add (updatedPackages);
- }
- }
-
- projects.Clear ();
-
- if (disposed) {
- projectsWithUpdatedPackages.Clear ();
- }
- }
-
- public void CheckForUpdatesCompleted ()
- {
- updatedPackagesInSolution.CheckForUpdatesCompleted (projectsWithUpdatedPackages);
- projectsWithUpdatedPackages.Clear ();
- }
-
- public void Dispose ()
- {
- if (!disposed) {
- disposed = true;
- }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs deleted file mode 100644 index c2149758ef..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/CheckForUpdatesTaskRunner.cs +++ /dev/null @@ -1,141 +0,0 @@ -//
-// CheckForUpdatesTaskRunner.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;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class CheckForUpdatesTaskRunner : IDisposable
- {
- ITaskFactory taskFactory;
- CheckForUpdatesTask currentCheckForUpdatesTask;
- ITask<CheckForUpdatesTask> task;
-
- public CheckForUpdatesTaskRunner (ITaskFactory taskFactory)
- {
- this.taskFactory = taskFactory;
- }
-
- public CheckForUpdatesTaskRunner ()
- : this (new PackageManagementTaskFactory ())
- {
- }
-
- public bool IsRunning {
- get { return currentCheckForUpdatesTask != null; }
- }
-
- public void Start (CheckForUpdatesTask checkForUpdatesTask)
- {
- Stop ();
-
- CreateCheckForUpdatesTask (checkForUpdatesTask);
-
- task.Start ();
- }
-
- void CreateCheckForUpdatesTask (CheckForUpdatesTask checkForUpdatesTask)
- {
- currentCheckForUpdatesTask = checkForUpdatesTask;
-
- task = taskFactory.CreateTask (
- () => CheckForUpdates (checkForUpdatesTask),
- OnCheckForUpdatesCompleted);
- }
-
- public void Dispose ()
- {
- Stop ();
- }
-
- public void Stop ()
- {
- if (task != null) {
- task.Cancel ();
- task = null;
- }
- if (currentCheckForUpdatesTask != null) {
- currentCheckForUpdatesTask.Dispose ();
- currentCheckForUpdatesTask = null;
- }
- }
-
- CheckForUpdatesTask CheckForUpdates (CheckForUpdatesTask currentTask)
- {
- currentTask.CheckForUpdates ();
- return currentTask;
- }
-
- void OnCheckForUpdatesCompleted (ITask<CheckForUpdatesTask> task)
- {
- if (task.IsFaulted) {
- if (IsCurrentTask (task)) {
- LogError ("Current check for updates task error.", task.Exception);
- } else {
- LogError ("Check for updates task error.", task.Exception);
- }
- } else if (task.IsCancelled) {
- // Ignore.
- return;
- } else if (!IsCurrentTask (task.Result)) {
- task.Result.Dispose ();
- return;
- } else {
- task.Result.CheckForUpdatesCompleted ();
- GuiBackgroundDispatch (() => {
- task.Result.Dispose ();
- });
- }
-
- currentCheckForUpdatesTask = null;
- this.task = null;
- }
-
- bool IsCurrentTask (CheckForUpdatesTask task)
- {
- return currentCheckForUpdatesTask == task;
- }
-
- protected virtual void LogError (string message, Exception ex)
- {
- LoggingService.LogError (message, ex);
- }
-
- bool IsCurrentTask (ITask<CheckForUpdatesTask> taskToCompare)
- {
- return taskToCompare == task;
- }
-
- protected virtual void GuiBackgroundDispatch (Action action)
- {
- PackageManagementBackgroundDispatcher.Dispatch (action);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DefaultProjectTemplatePackageSource.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DefaultProjectTemplatePackageSource.cs deleted file mode 100644 index 8bb65f4ad9..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DefaultProjectTemplatePackageSource.cs +++ /dev/null @@ -1,58 +0,0 @@ -//
-// DefaultProjectTemplatePackageSource.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.IO;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class DefaultProjectTemplatePackageSource
- {
- PackageSource packageSource;
-
- public DefaultProjectTemplatePackageSource()
- : this(new PackageManagementPropertyService())
- {
- }
-
- public DefaultProjectTemplatePackageSource(IPropertyService propertyService)
- {
- CreatePackageSource(propertyService.DataDirectory);
- }
-
- void CreatePackageSource(string dataDirectory)
- {
- string packageDirectory = Path.Combine(dataDirectory, @"templates\packages");
- packageSource = new PackageSource(packageDirectory, "Default");
- }
-
- public PackageSource PackageSource {
- get { return packageSource; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DeleteOnRestartManager.cs index 78c70d29dd..03aa727c3e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageOperations.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DeleteOnRestartManager.cs @@ -1,10 +1,10 @@ //
-// ReinstallPackageOperations.cs
+// DeleteOnRestartManager.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -26,30 +26,31 @@ using System;
using System.Collections.Generic;
-using System.Linq;
-using NuGet;
+using NuGet.PackageManagement;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
- internal class ReinstallPackageOperations
+ internal class DeleteOnRestartManager : IDeleteOnRestartManager
{
- List<PackageOperation> operations;
- List<IPackage> packagesInDependencyOrder;
+ public event EventHandler<PackagesMarkedForDeletionEventArgs> PackagesMarkedForDeletionFound;
- public ReinstallPackageOperations (
- IEnumerable<PackageOperation> operations,
- IEnumerable<IPackage> packagesInDependencyOrder)
+ public void CheckAndRaisePackageDirectoriesMarkedForDeletion ()
{
- this.operations = operations.ToList ();
- this.packagesInDependencyOrder = packagesInDependencyOrder.ToList ();
}
- public IEnumerable<PackageOperation> Operations {
- get { return operations; }
+ public void DeleteMarkedPackageDirectories (INuGetProjectContext projectContext)
+ {
}
- public IEnumerable<IPackage> PackagesInDependencyOrder {
- get { return packagesInDependencyOrder; }
+ public IReadOnlyList<string> GetPackageDirectoriesMarkedForDeletion ()
+ {
+ return new List<string> ();
+ }
+
+ public void MarkPackageDirectoryForDeletion (PackageIdentity package, string packageDirectory, INuGetProjectContext projectContext)
+ {
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectExtensions.cs index 38ba1cae5f..558440fe3a 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectExtensions.cs @@ -30,9 +30,12 @@ using System; using System.Collections.Generic;
using System.Linq;
using System.IO;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Projects;
using NuGet;
+using NuGet.Common;
+using MonoDevelop.Core;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -50,7 +53,7 @@ namespace MonoDevelop.PackageManagement public static bool HasProjectType(this IDotNetProject project, Guid projectTypeGuid)
{
- foreach (string guid in project.GetProjectTypeGuids()) {
+ foreach (string guid in project.FlavorGuids) {
if (IsMatch(projectTypeGuid, guid)) {
return true;
}
@@ -58,12 +61,6 @@ namespace MonoDevelop.PackageManagement return false;
}
- public static string[] GetProjectTypeGuids(this IDotNetProject project)
- {
- string projectTypeGuids = project.GetProjectTypeGuidPropertyValue();
- return projectTypeGuids.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
- }
-
static bool IsMatch(Guid guid, string guidStringToMatch)
{
Guid result;
@@ -73,15 +70,6 @@ namespace MonoDevelop.PackageManagement return false;
}
- public static string GetProjectTypeGuidPropertyValue (this IDotNetProject project)
- {
- string propertyValue = null;
- if (project.ExtendedProperties.Contains("ProjectTypeGuids")) {
- propertyValue = project.ExtendedProperties["ProjectTypeGuids"] as String;
- }
- return propertyValue ?? String.Empty;
- }
-
public static bool HasPackages (this DotNetProject project)
{
return HasPackages (project.BaseDirectory, project.Name);
@@ -94,12 +82,17 @@ namespace MonoDevelop.PackageManagement public static bool HasPackages (this IDotNetProject project)
{
- return AnyFileExists (GetPossiblePackagesConfigFilePaths (project.BaseDirectory, project.Name));
+ return AnyFileExists (GetPossiblePackagesConfigOrProjectJsonFilePaths (project.BaseDirectory, project.Name));
+ }
+
+ public static bool HasPackagesConfig (this IDotNetProject project)
+ {
+ return FileExists (GetPackagesConfigFilePath (project));
}
static bool HasPackages (string projectDirectory, string projectName)
{
- return AnyFileExists (GetPossiblePackagesConfigFilePaths (projectDirectory, projectName));
+ return AnyFileExists (GetPossiblePackagesConfigOrProjectJsonFilePaths (projectDirectory, projectName));
}
static bool AnyFileExists (IEnumerable<string> files)
@@ -107,10 +100,11 @@ namespace MonoDevelop.PackageManagement return files.Any (FileExists);
}
- static IEnumerable<string> GetPossiblePackagesConfigFilePaths (string projectDirectory, string projectName)
+ static IEnumerable<string> GetPossiblePackagesConfigOrProjectJsonFilePaths (string projectDirectory, string projectName)
{
yield return GetNonDefaultProjectPackagesConfigFilePath (projectDirectory, projectName);
yield return GetDefaultPackagesConfigFilePath (projectDirectory);
+ yield return ProjectJsonPathUtilities.GetProjectConfigPath (projectDirectory, projectName);
}
static string GetNonDefaultProjectPackagesConfigFilePath (string projectDirectory, string projectName)
@@ -125,7 +119,7 @@ namespace MonoDevelop.PackageManagement static string GetDefaultPackagesConfigFilePath (string projectDirectory)
{
- return Path.Combine (projectDirectory, Constants.PackageReferenceFile);
+ return Path.Combine (projectDirectory, NuGet.Constants.PackageReferenceFile);
}
public static string GetPackagesConfigFilePath (this IDotNetProject project)
@@ -141,5 +135,18 @@ namespace MonoDevelop.PackageManagement }
return GetDefaultPackagesConfigFilePath (projectDirectory);
}
+
+ public static FilePath GetPackagesFolderPath (this DotNetProject project)
+ {
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution);
+ if (solutionManager == null)
+ return FilePath.Null;
+
+ NuGetProject nugetProject = solutionManager.GetNuGetProject (new DotNetProjectProxy (project));
+ if (nugetProject == null)
+ return FilePath.Null;
+
+ return nugetProject.GetPackagesFolderPath (solutionManager);
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectProxy.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectProxy.cs index 07dc225d42..dbdec9c948 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectProxy.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/DotNetProjectProxy.cs @@ -34,6 +34,7 @@ namespace MonoDevelop.PackageManagement {
DotNetProject project;
EventHandler<ProjectModifiedEventArgs> projectModifiedHandler;
+ EventHandler projectSavedHandler;
public DotNetProjectProxy (DotNetProject project)
: base (project)
@@ -108,6 +109,26 @@ namespace MonoDevelop.PackageManagement }
}
+ public event EventHandler Saved {
+ add {
+ if (projectSavedHandler == null) {
+ project.Saved += ProjectSaved;
+ }
+ projectSavedHandler += value;
+ }
+ remove {
+ projectSavedHandler -= value;
+ if (projectSavedHandler == null) {
+ project.Saved -= ProjectSaved;
+ }
+ }
+ }
+
+ void ProjectSaved (object sender, SolutionItemEventArgs e)
+ {
+ projectSavedHandler (this, new EventArgs ());
+ }
+
public bool Equals (IDotNetProject project)
{
return DotNetProject == project.DotNetProject;
@@ -122,6 +143,11 @@ namespace MonoDevelop.PackageManagement {
DotNetProject.ReloadProjectBuilder ();
}
+
+ public void RefreshReferenceStatus ()
+ {
+ DotNetProject.RefreshReferenceStatus ();
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FailingPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FailingPackageRepository.cs deleted file mode 100644 index 7315ccbde3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FailingPackageRepository.cs +++ /dev/null @@ -1,76 +0,0 @@ -//
-// FailingPackageRepository.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 System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- /// <summary>
- /// Wraps access to a package repository that could not be created due to an invalid
- /// Url. A call to any method will return the original exception that was thrown.
- /// This is only used when creating an AggregateRepository so it does not prevent packages
- /// being returned from other valid package repositories.
- /// </summary>
- internal class FailingPackageRepository : IPackageRepository
- {
- string source;
- Exception exception;
-
- public FailingPackageRepository (string source, Exception exception)
- {
- this.source = source;
- this.exception = exception;
- }
-
- public IQueryable<IPackage> GetPackages ()
- {
- throw exception;
- }
-
- public void AddPackage (IPackage package)
- {
- throw exception;
- }
-
- public void RemovePackage (IPackage package)
- {
- throw exception;
- }
-
- public string Source {
- get { return source; }
- }
-
- public PackageSaveModes PackageSaveMode { get; set; }
-
- public bool SupportsPrereleasePackages {
- get { return true; }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FallbackRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FallbackRepository.cs deleted file mode 100644 index 343472aff2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FallbackRepository.cs +++ /dev/null @@ -1,145 +0,0 @@ -//
-// From NuGet src/VisualStudio
-//
-// Copyright (c) 2010-2014 Outercurve Foundation
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Versioning;
-
-namespace NuGet
-{
- /// <summary>
- /// Represents a package repository that implements a dependency provider.
- /// </summary>
- internal class FallbackRepository : IDependencyResolver, IServiceBasedRepository, IPackageLookup, ILatestPackageLookup, IOperationAwareRepository
- {
- private readonly IPackageRepository _primaryRepository;
- private readonly IPackageRepository _dependencyResolver;
-
- public FallbackRepository (IPackageRepository primaryRepository, IPackageRepository dependencyResolver)
- {
- _primaryRepository = primaryRepository;
- _dependencyResolver = dependencyResolver;
- }
-
- public string Source {
- get { return _primaryRepository.Source; }
- }
-
- public PackageSaveModes PackageSaveMode {
- get {
- return _primaryRepository.PackageSaveMode;
- }
- set {
- _primaryRepository.PackageSaveMode = value;
- }
- }
-
- public bool SupportsPrereleasePackages {
- get {
- return _primaryRepository.SupportsPrereleasePackages;
- }
- }
-
- public IPackageRepository SourceRepository {
- get { return _primaryRepository; }
- }
-
- public IPackageRepository DependencyResolver {
- get { return _dependencyResolver; }
- }
-
- public IQueryable<IPackage> GetPackages ()
- {
- return _primaryRepository.GetPackages ();
- }
-
- public void AddPackage (IPackage package)
- {
- _primaryRepository.AddPackage (package);
- }
-
- public void RemovePackage (IPackage package)
- {
- _primaryRepository.RemovePackage (package);
- }
-
- public IPackage ResolveDependency (PackageDependency dependency, IPackageConstraintProvider constraintProvider, bool allowPrereleaseVersions, bool preferListedPackages, DependencyVersion dependencyVersion)
- {
- // Use the primary repository to look up dependencies. Fallback to the aggregate repository only if we can't find a package here.
- return _primaryRepository.ResolveDependency (dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion) ??
- _dependencyResolver.ResolveDependency (dependency, constraintProvider, allowPrereleaseVersions, preferListedPackages, dependencyVersion);
- }
-
- public IQueryable<IPackage> Search (string searchTerm, IEnumerable<string> targetFrameworks, bool allowPrereleaseVersions)
- {
- return _primaryRepository.Search (searchTerm, targetFrameworks, allowPrereleaseVersions);
- }
-
- public IEnumerable<IPackage> FindPackagesById (string packageId)
- {
- return _primaryRepository.FindPackagesById (packageId);
- }
-
- public IEnumerable<IPackage> GetUpdates (
- IEnumerable<IPackageName> packages,
- bool includePrerelease,
- bool includeAllVersions,
- IEnumerable<FrameworkName> targetFrameworks,
- IEnumerable<IVersionSpec> versionConstraints)
- {
- return _primaryRepository.GetUpdates (packages, includePrerelease, includeAllVersions, targetFrameworks, versionConstraints);
- }
-
- public IPackage FindPackage (string packageId, SemanticVersion version)
- {
- return _primaryRepository.FindPackage (packageId, version);
- }
-
- public bool Exists (string packageId, SemanticVersion version)
- {
- return _primaryRepository.Exists (packageId, version);
- }
-
- public bool TryFindLatestPackageById (string id, out SemanticVersion latestVersion)
- {
- var latestPackageLookup = _primaryRepository as ILatestPackageLookup;
- if (latestPackageLookup != null) {
- return latestPackageLookup.TryFindLatestPackageById (id, out latestVersion);
- }
-
- latestVersion = null;
- return false;
- }
-
- public bool TryFindLatestPackageById (string id, bool includePrerelease, out IPackage package)
- {
- var latestPackageLookup = _primaryRepository as ILatestPackageLookup;
- if (latestPackageLookup != null) {
- return latestPackageLookup.TryFindLatestPackageById (id, includePrerelease, out package);
- }
-
- package = null;
- return false;
- }
-
- public IDisposable StartOperation (string operation, string mainPackageId, string mainPackageVersion)
- {
- return SourceRepository.StartOperation (operation, mainPackageId, mainPackageVersion);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FileConflictResolver.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FileConflictResolver.cs index 54553ab561..6f20369bca 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FileConflictResolver.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FileConflictResolver.cs @@ -28,7 +28,7 @@ using MonoDevelop.Core;
using MonoDevelop.Ide;
-using NuGet;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -49,7 +49,7 @@ namespace MonoDevelop.PackageManagement const int NoButtonIndex = 2;
const int NoToAllButtonIndex = 3;
- public FileConflictResolution ResolveFileConflict(string message)
+ public FileConflictAction ResolveFileConflict (string message)
{
AlertButton result = MessageService.AskQuestion(
GettextCatalog.GetString ("File Conflict"),
@@ -59,16 +59,16 @@ namespace MonoDevelop.PackageManagement return MapResultToFileConflictResolution(result);
}
- FileConflictResolution MapResultToFileConflictResolution(AlertButton result)
+ FileConflictAction MapResultToFileConflictResolution (AlertButton result)
{
if (result == AlertButton.Yes) {
- return FileConflictResolution.Overwrite;
+ return FileConflictAction.Overwrite;
} else if (result == YesToAllButton) {
- return FileConflictResolution.OverwriteAll;
+ return FileConflictAction.OverwriteAll;
} else if (result == NoToAllButton) {
- return FileConflictResolution.IgnoreAll;
+ return FileConflictAction.IgnoreAll;
} else {
- return FileConflictResolution.Ignore;
+ return FileConflictAction.Ignore;
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FilePathExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FilePathExtensions.cs index d6ecfad26c..1c0f7d1837 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FilePathExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/FilePathExtensions.cs @@ -27,6 +27,7 @@ using System;
using MonoDevelop.Core;
using NuGet;
+using NuGet.Common;
namespace MonoDevelop.PackageManagement
{
@@ -38,14 +39,25 @@ namespace MonoDevelop.PackageManagement return false;
}
- return Constants.PackageReferenceFile.Equals (filePath.FileName, StringComparison.OrdinalIgnoreCase) ||
- IsProjectSpecificPackagesConfigFile (filePath.FileName);
+ return PackageReferenceFile.IsValidConfigFileName (filePath.FileName);
}
- static bool IsProjectSpecificPackagesConfigFile (FilePath filePath)
+ public static bool IsProjectJsonFileName (this FilePath filePath)
{
- return filePath.Extension.Equals (".config", StringComparison.OrdinalIgnoreCase) &&
- filePath.FileNameWithoutExtension.StartsWith ("packages.", StringComparison.OrdinalIgnoreCase);
+ if (filePath == null) {
+ return false;
+ }
+
+ return ProjectJsonPathUtilities.IsProjectConfig (filePath);
+ }
+
+ public static bool IsPackagesConfigOrProjectJsonFileName (this FilePath filePath)
+ {
+ if (filePath == null) {
+ return false;
+ }
+
+ return IsPackagesConfigFileName (filePath) || IsProjectJsonFileName (filePath);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/HttpHandlerResourceV3Extensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/HttpHandlerResourceV3Extensions.cs new file mode 100644 index 0000000000..48f5dc69ac --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/HttpHandlerResourceV3Extensions.cs @@ -0,0 +1,71 @@ +// +// HttpHandlerResourceV3Extensions.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Code taken from NuGet.Client src/NuGet.Clients/VsExtension/NuGetPackage.cs +// +// Copyright (c) 2016 Xamarin Inc. (http://xamarin.com) +// Copyright (c) .NET Foundation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using NuGet; +using NuGet.Credentials; + +namespace MonoDevelop.PackageManagement +{ + internal static class HttpHandlerResourceV3Extensions + { + public static void InitializeHttpHandlerResourceV3 (CredentialService credentialService) + { + // Set up proxy handling for v3 sources. + // We need to sync the v2 proxy cache and v3 proxy cache so that the user will not + // get prompted twice for the same authenticated proxy. + var v2ProxyCache = ProxyCache.Instance; + NuGet.Protocol.Core.v3.HttpHandlerResourceV3.PromptForProxyCredentials = async (uri, proxy, cancellationToken) => { + var v2Credentials = v2ProxyCache?.GetProxy (uri)?.Credentials; + if (v2Credentials != null && proxy.Credentials != v2Credentials) { + // if cached v2 credentials have not been used, try using it first. + return v2Credentials; + } + + return await credentialService + .GetCredentials (uri, proxy, isProxy: true, cancellationToken: cancellationToken); + }; + + NuGet.Protocol.Core.v3.HttpHandlerResourceV3.ProxyPassed = proxy => { + // add the proxy to v2 proxy cache. + v2ProxyCache?.Add (proxy); + }; + + NuGet.Protocol.Core.v3.HttpHandlerResourceV3.PromptForCredentials = async (uri, cancellationToken) => { + // Get the proxy for this URI so we can pass it to the credentialService methods + // this lets them use the proxy if they have to hit the network. + var proxyCache = ProxyCache.Instance; + var proxy = proxyCache?.GetProxy (uri); + + return await credentialService + .GetCredentials (uri, proxy: proxy, isProxy: false, cancellationToken: cancellationToken); + }; + + NuGet.Protocol.Core.v3.HttpHandlerResourceV3.CredentialsSuccessfullyUsed = (uri, credentials) => { + NuGet.CredentialStore.Instance.Add (uri, credentials); + NuGet.Configuration.CredentialStore.Instance.Add (uri, credentials); + }; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBackgroundPackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBackgroundPackageActionRunner.cs index ccd2b79b5c..e9d529c6b9 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBackgroundPackageActionRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBackgroundPackageActionRunner.cs @@ -26,15 +26,14 @@ using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Projects;
namespace MonoDevelop.PackageManagement
{
internal interface IBackgroundPackageActionRunner
{
- IEnumerable<InstallPackageAction> PendingInstallActions { get; }
- IEnumerable<InstallPackageAction> PendingInstallActionsForProject (DotNetProject project);
+ IEnumerable<IInstallNuGetPackageAction> PendingInstallActions { get; }
+ IEnumerable<IInstallNuGetPackageAction> PendingInstallActionsForProject (DotNetProject project);
void Run (ProgressMonitorStatusMessage progressMessage, IPackageAction action);
void Run (ProgressMonitorStatusMessage progressMessage, IEnumerable<IPackageAction> actions);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBuildIntegratedNuGetProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBuildIntegratedNuGetProject.cs new file mode 100644 index 0000000000..5be41cdf16 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IBuildIntegratedNuGetProject.cs @@ -0,0 +1,42 @@ +// +// IBuildIntegratedNuGetProject.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using NuGet.PackageManagement; +using NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement +{ + internal interface IBuildIntegratedNuGetProject + { + void OnBeforeUninstall (IEnumerable<NuGetProjectAction> actions); + void OnAfterExecuteActions (IEnumerable<NuGetProjectAction> actions); + Task PostProcessAsync (INuGetProjectContext nuGetProjectContext, CancellationToken token); + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ICompilerMessageView.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ICompilerMessageView.cs deleted file mode 100644 index 0defab266e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ICompilerMessageView.cs +++ /dev/null @@ -1,39 +0,0 @@ -//
-// ICompilerMessageView.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal interface ICompilerMessageView
- {
- IMessageViewCategory Create(string categoryName, string categoryDisplayName);
-
- IMessageViewCategory GetExisting(string name);
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IDotNetProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IDotNetProject.cs index d1e2fc0f11..e808d3a4aa 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IDotNetProject.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IDotNetProject.cs @@ -33,6 +33,7 @@ namespace MonoDevelop.PackageManagement internal interface IDotNetProject : IProject
{
event EventHandler<ProjectModifiedEventArgs> Modified;
+ event EventHandler Saved;
DotNetProject DotNetProject { get; }
TargetFrameworkMoniker TargetFrameworkMoniker { get; }
@@ -47,7 +48,8 @@ namespace MonoDevelop.PackageManagement void RemoveImport (string name);
bool Equals (IDotNetProject project);
void RefreshProjectBuilder ();
- void DisposeProjectBuilder ();
+ void DisposeProjectBuilder (); + void RefreshReferenceStatus (); }
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatedPackagesInSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IFileConflictResolver.cs index b1bb3e9cf8..6f072655c4 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatedPackagesInSolution.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IFileConflictResolver.cs @@ -1,39 +1,36 @@ -//
-// IUpdatedPackagesInSolution.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;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IUpdatedPackagesInSolution
- {
- void Clear ();
- void CheckForUpdates ();
- UpdatedPackagesInProject GetUpdatedPackages (IDotNetProject project);
- bool AnyUpdates ();
- }
-}
-
+// +// IFileConflictResolver.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement +{ + internal interface IFileConflictResolver + { + FileConflictAction ResolveFileConflict (string message); + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullOpenPackageReadMeMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IInstallNuGetPackageAction.cs index 679b82cb30..da2166d3cc 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullOpenPackageReadMeMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IInstallNuGetPackageAction.cs @@ -1,10 +1,10 @@ //
-// NullOpenPackageReadMeMonitor.cs
+// IInstallNuGetPackageAction.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2015 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -24,19 +24,16 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+using MonoDevelop.Projects;
+using NuGet.Versioning;
+
namespace MonoDevelop.PackageManagement
{
- internal class NullOpenPackageReadMeMonitor : IOpenPackageReadMeMonitor
+ internal interface IInstallNuGetPackageAction
{
- public static readonly IOpenPackageReadMeMonitor Null = new NullOpenPackageReadMeMonitor ();
-
- public void Dispose ()
- {
- }
-
- public void OpenReadMeFile ()
- {
- }
+ string PackageId { get; }
+ NuGetVersion Version { get; }
+ bool IsForProject (DotNetProject project);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ILicenseAcceptanceService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ILicenseAcceptanceService.cs index 1f98fe8e08..07649e98bb 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ILicenseAcceptanceService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ILicenseAcceptanceService.cs @@ -26,7 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Collections.Generic;
using NuGet;
@@ -35,5 +34,6 @@ namespace MonoDevelop.PackageManagement internal interface ILicenseAcceptanceService
{
bool AcceptLicenses(IEnumerable<IPackage> packages);
+ bool AcceptLicenses (IEnumerable<NuGetPackageLicense> licenses);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMessageViewCategory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMessageViewCategory.cs deleted file mode 100644 index 725d50a4bb..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMessageViewCategory.cs +++ /dev/null @@ -1,38 +0,0 @@ -//
-// IMessageViewCategory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal interface IMessageViewCategory
- {
- void AppendLine(string text);
- void Clear();
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageManager.cs deleted file mode 100644 index 0851e40070..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageManager.cs +++ /dev/null @@ -1,53 +0,0 @@ -//
-// IMonoDevelopPackageManager.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012-2013 Matthew Ward
-//
-// 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.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IMonoDevelopPackageManager : IPackageManager
- {
- IMonoDevelopProjectManager ProjectManager { get; }
-
- void InstallPackage(IPackage package, InstallPackageAction installAction);
- void UninstallPackage(IPackage package, UninstallPackageAction uninstallAction);
- void UpdatePackage(IPackage package, UpdatePackageAction updateAction);
- void UpdatePackages(UpdatePackagesAction updateAction);
- void UpdatePackageReference(IPackage package, IUpdatePackageSettings settings);
- void AddPackageReference (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions);
-
- IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, InstallPackageAction installAction);
- IEnumerable<PackageOperation> GetUpdatePackageOperations(IEnumerable<IPackage> packages, IUpdatePackageSettings settings);
- ReinstallPackageOperations GetReinstallPackageOperations (IEnumerable<IPackage> packages);
-
- void RunPackageOperations(IEnumerable<PackageOperation> operations);
-
- void InstallPackageIntoSolutionRepository (IPackage package);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageRepositoryFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageRepositoryFactory.cs index adc6245783..02360b2449 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageRepositoryFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopPackageRepositoryFactory.cs @@ -26,8 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Collections.Generic;
using NuGet;
namespace MonoDevelop.PackageManagement
@@ -38,11 +36,5 @@ namespace MonoDevelop.PackageManagement IPackagePathResolver pathResolver,
IFileSystem fileSystem,
IFileSystem configSettingsFileSystem);
-
- IRecentPackageRepository CreateRecentPackageRepository(
- IList<RecentPackageInfo> recentPackages,
- IPackageRepository aggregateRepository);
-
- IPackageRepository CreateAggregateRepository(IEnumerable<IPackageRepository> repositories);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopProjectManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopProjectManager.cs deleted file mode 100644 index 78e2b907f4..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopProjectManager.cs +++ /dev/null @@ -1,42 +0,0 @@ -//
-// IMonoDevelopProjectManager.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012-2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IMonoDevelopProjectManager : IProjectManager
- {
- IPackagePathResolver PathResolver { get; }
- bool IsInstalled(string packageId);
- bool HasOlderPackageInstalled(IPackage package);
- IEnumerable<PackageReference> GetPackageReferences ();
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopProjectSystemFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopProjectSystemFactory.cs deleted file mode 100644 index 80b5a8ca03..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopProjectSystemFactory.cs +++ /dev/null @@ -1,39 +0,0 @@ -//
-// IMonoDevelopProjectSystemFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IMonoDevelopProjectSystemFactory
- {
- IProjectSystem CreateProjectSystem(DotNetProject project);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopSolutionManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopSolutionManager.cs new file mode 100644 index 0000000000..495c2f2863 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IMonoDevelopSolutionManager.cs @@ -0,0 +1,42 @@ +//
+// IMonoDevelopSolutionManager.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 NuGet.Configuration;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal interface IMonoDevelopSolutionManager : ISolutionManager
+ {
+ ISettings Settings { get; }
+ NuGetProject GetNuGetProject (IDotNetProject project);
+ ISourceRepositoryProvider CreateSourceRepositoryProvider ();
+ void ReloadSettings ();
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageAction.cs new file mode 100644 index 0000000000..ea5cc2f692 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageAction.cs @@ -0,0 +1,34 @@ +//
+// INuGetPackageAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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
+{
+ internal interface INuGetPackageAction : IPackageAction
+ {
+ string PackageId { get; }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageManager.cs new file mode 100644 index 0000000000..c76a0d2455 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageManager.cs @@ -0,0 +1,100 @@ +// +// INuGetPackageManager.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Logging; +using NuGet.PackageManagement; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement +{ + internal interface INuGetPackageManager + { + Task<IEnumerable<NuGetProjectAction>> PreviewInstallPackageAsync ( + NuGetProject nuGetProject, + PackageIdentity packageIdentity, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token); + + Task<IEnumerable<NuGetProjectAction>> PreviewUpdatePackagesAsync ( + string packageId, + NuGetProject nuGetProject, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token); + + Task<IEnumerable<NuGetProjectAction>> PreviewUpdatePackagesAsync( + NuGetProject nuGetProject, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token); + + Task<IEnumerable<NuGetProjectAction>> PreviewUninstallPackageAsync( + NuGetProject nuGetProject, + string packageId, + UninstallationContext uninstallationContext, + INuGetProjectContext nuGetProjectContext, + CancellationToken token); + + Task<NuGetVersion> GetLatestVersionAsync ( + string packageId, + NuGetProject project, + ResolutionContext resolutionContext, + IEnumerable<SourceRepository> sources, + ILogger log, + CancellationToken token); + + Task ExecuteNuGetProjectActionsAsync ( + NuGetProject nuGetProject, + IEnumerable<NuGetProjectAction> nuGetProjectActions, + INuGetProjectContext nuGetProjectContext, + CancellationToken token); + + void SetDirectInstall (PackageIdentity directInstall, INuGetProjectContext nuGetProjectContext); + void ClearDirectInstall (INuGetProjectContext nuGetProjectContext); + + bool PackageExistsInPackagesFolder (PackageIdentity packageIdentity); + + Task OpenReadmeFiles ( + NuGetProject project, + IEnumerable<PackageIdentity> packages, + INuGetProjectContext nuGetProjectContext, + CancellationToken token); + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageNewImportsHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageNewImportsHandler.cs index 766d06270b..3a0f47ff83 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageNewImportsHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetPackageNewImportsHandler.cs @@ -25,13 +25,13 @@ // THE SOFTWARE. using System; -using NuGet; +using NuGet.ProjectManagement; namespace MonoDevelop.PackageManagement { internal interface INuGetPackageNewImportsHandler : IDisposable { - void AddImportIfMissing (string name, string condition, ProjectImportLocation location); + void AddImportIfMissing (string name, string condition, ImportLocation location); } } diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetProjectActionsProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetProjectActionsProvider.cs new file mode 100644 index 0000000000..b9884c701f --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/INuGetProjectActionsProvider.cs @@ -0,0 +1,37 @@ +// +// INuGetProjectActionsProvider.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Collections.Generic; +using NuGet.PackageManagement; + +namespace MonoDevelop.PackageManagement +{ + internal interface INuGetProjectActionsProvider + { + IEnumerable<NuGetProjectAction> GetNuGetProjectActions (); + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageAction.cs index fcd937dd40..ad4fee068e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageAction.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageAction.cs @@ -26,14 +26,14 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
+using System.Threading;
namespace MonoDevelop.PackageManagement
{
internal interface IPackageAction
{
- void Execute();
+ void Execute ();
+ void Execute (CancellationToken cancellationToken);
bool HasPackageScriptsToRun();
- //IPackageScriptRunner PackageScriptRunner { get; set; }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageActionRunner.cs deleted file mode 100644 index bfd26ce4b7..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageActionRunner.cs +++ /dev/null @@ -1,39 +0,0 @@ -//
-// IPackageActionRunner.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageActionRunner
- {
- void Run(IPackageAction action);
- void Run(IEnumerable<IPackageAction> actions);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageExtensions.cs deleted file mode 100644 index fc730e53a9..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageExtensions.cs +++ /dev/null @@ -1,56 +0,0 @@ -//
-// IPackageExtensions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal static class IPackageExtensions
- {
- /// <summary>
- /// Returns description if summary is missing.
- /// </summary>
- public static string SummaryOrDescription(this IPackage package)
- {
- if (String.IsNullOrEmpty(package.Summary))
- return package.Description;
- return package.Summary;
- }
-
- /// <summary>
- /// Returns package Id if it has no title.
- /// </summary>
- public static string GetName(this IPackage package)
- {
- if (String.IsNullOrEmpty(package.Title))
- return package.Id;
- return package.Title;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageFromRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageFromRepository.cs deleted file mode 100644 index 42742205c2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageFromRepository.cs +++ /dev/null @@ -1,42 +0,0 @@ -//
-// IPackageFromRepository.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageFromRepository : IPackage
- {
- IPackageRepository Repository { get; }
- bool HasDependencies { get; }
- DateTime? LastUpdated { get; }
- Uri GalleryUrl { get; }
- bool IsValid { get; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageFromRepositoryExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageFromRepositoryExtensions.cs deleted file mode 100644 index d2ec8f6c11..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageFromRepositoryExtensions.cs +++ /dev/null @@ -1,54 +0,0 @@ -//
-// IPackageFromRepositoryExtensions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal static class IPackageFromRepositoryExtensions
- {
- public static IDisposable StartInstallOperation(this IPackageFromRepository package)
- {
- return package.Repository.StartInstallOperation(package.Id, GetVersion(package.Version));
- }
-
- public static IDisposable StartUpdateOperation(this IPackageFromRepository package)
- {
- return package.Repository.StartUpdateOperation(package.Id, GetVersion(package.Version));
- }
-
- static string GetVersion(SemanticVersion version)
- {
- if (version != null) {
- return version.ToString();
- }
- return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs index 468567a479..86fbba1e04 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementEvents.cs @@ -29,9 +29,9 @@ using System;
using System.Collections.Generic;
using MonoDevelop.Core;
-using MonoDevelop.PackageManagement;
-using NuGet;
using MonoDevelop.Projects;
+using NuGet;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -39,43 +39,33 @@ namespace MonoDevelop.PackageManagement {
event EventHandler PackageOperationsStarting;
event EventHandler PackageOperationsFinished;
- event EventHandler<AcceptLicensesEventArgs> AcceptLicenses;
- event EventHandler<SelectProjectsEventArgs> SelectProjects;
event EventHandler<ResolveFileConflictEventArgs> ResolveFileConflict;
event EventHandler<PackageOperationExceptionEventArgs> PackageOperationError;
- event EventHandler<ParentPackageOperationEventArgs> ParentPackageInstalled;
- event EventHandler<ParentPackageOperationEventArgs> ParentPackageUninstalled;
- event EventHandler<ParentPackagesOperationEventArgs> ParentPackagesUpdated;
event EventHandler<PackageOperationMessageLoggedEventArgs> PackageOperationMessageLogged;
event EventHandler PackagesRestored;
event EventHandler<FileEventArgs> FileChanged;
event EventHandler<FileRemovingEventArgs> FileRemoving;
event EventHandler UpdatedPackagesAvailable;
- event EventHandler<PackageRestoredEventArgs> PackageRestored;
event EventHandler<DotNetProjectReferenceEventArgs> ReferenceAdding;
event EventHandler<DotNetProjectReferenceEventArgs> ReferenceRemoving;
event EventHandler<DotNetProjectImportEventArgs> ImportRemoved;
+ event EventHandler<PackageManagementEventArgs> PackageInstalled;
+ event EventHandler<PackageManagementEventArgs> PackageUninstalling;
+ event EventHandler<PackageManagementEventArgs> PackageUninstalled;
+ event EventHandler<DotNetProjectEventArgs> NoUpdateFound;
void OnPackageOperationsStarting();
void OnPackageOperationsFinished();
void OnPackageOperationError(Exception ex);
- bool OnAcceptLicenses(IEnumerable<IPackage> packages);
- void OnParentPackageInstalled (IPackage package, IPackageManagementProject project, IEnumerable<PackageOperation> operations);
- void OnParentPackageUninstalled(IPackage package, IPackageManagementProject project);
- void OnParentPackagesUpdated(IEnumerable<IPackage> packages);
- void OnPackageOperationMessageLogged(MessageLevel level, string message, params object[] args);
- bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> selectedProjects);
- FileConflictResolution OnResolveFileConflict(string message);
+ void OnPackageOperationMessageLogged(NuGet.MessageLevel level, string message, params object[] args);
+ FileConflictAction OnResolveFileConflict(string message);
void OnPackagesRestored();
void OnFileChanged(string path);
void OnUpdatedPackagesAvailable ();
bool OnFileRemoving (string path);
- void OnPackageRestored (IPackage package);
void OnReferenceAdding (ProjectReference reference);
void OnReferenceRemoving (ProjectReference reference);
void OnImportRemoved (IDotNetProject project, string import);
-
- [Obsolete]
- void OnParentPackageInstalled (IPackage package, IPackageManagementProject project);
+ void OnNoUpdateFound (IDotNetProject project);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementOutputMessagesView.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementOutputMessagesView.cs deleted file mode 100644 index 949f0a0eff..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementOutputMessagesView.cs +++ /dev/null @@ -1,37 +0,0 @@ -//
-// IPackageManagementOutputMessagesView.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageManagementOutputMessagesView
- {
- void Clear();
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProject.cs deleted file mode 100644 index b5c91c7e86..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProject.cs +++ /dev/null @@ -1,87 +0,0 @@ -//
-// IPackageManagementProject.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012-2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Runtime.Versioning;
-using System.Linq;
-
-using NuGet;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageManagementProject
- {
- event EventHandler<PackageOperationEventArgs> PackageInstalled;
- event EventHandler<PackageOperationEventArgs> PackageUninstalled;
- event EventHandler<PackageOperationEventArgs> PackageReferenceAdded;
- event EventHandler<PackageOperationEventArgs> PackageReferenceRemoved;
-
- string Name { get; }
- ILogger Logger { get; set; }
- IPackageRepository SourceRepository { get; }
- FrameworkName TargetFramework { get; }
-
- DotNetProject DotNetProject { get; }
- IDotNetProject Project { get; }
-
- IPackageConstraintProvider ConstraintProvider { get; }
-
- bool IsPackageInstalled(IPackage package);
- bool IsPackageInstalled(string packageId);
- bool HasOlderPackageInstalled(IPackage package);
-
- IQueryable<IPackage> GetPackages();
- IEnumerable<IPackage> GetPackagesInReverseDependencyOrder();
- IPackage FindPackage(string packageId);
- bool AnyUnrestoredPackages ();
-
- IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, InstallPackageAction installAction);
- IEnumerable<PackageOperation> GetUpdatePackagesOperations(IEnumerable<IPackage> packages, IUpdatePackageSettings settings);
- ReinstallPackageOperations GetReinstallPackageOperations (IEnumerable<IPackage> packages);
-
- void InstallPackage(IPackage package, InstallPackageAction installAction);
- void UpdatePackage(IPackage package, UpdatePackageAction updateAction);
- void UninstallPackage(IPackage package, UninstallPackageAction uninstallAction);
- void UpdatePackages(UpdatePackagesAction action);
-
- void UpdatePackageReference(IPackage package, IUpdatePackageSettings settings);
- void AddPackageReference (IPackage package);
- IEnumerable<PackageReference> GetPackageReferences ();
-
- InstallPackageAction CreateInstallPackageAction();
- UninstallPackageAction CreateUninstallPackageAction();
- UpdatePackageAction CreateUpdatePackageAction();
- UpdatePackagesAction CreateUpdatePackagesAction();
- ReinstallPackageAction CreateReinstallPackageAction ();
-
- void RunPackageOperations(IEnumerable<PackageOperation> expectedOperations);
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectFactory.cs deleted file mode 100644 index 11d33f3c5c..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -//
-// IPackageManagementProjectFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageManagementProjectFactory
- {
- IPackageManagementProject CreateProject (IPackageRepository sourceRepository, IDotNetProject project);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectOperations.cs index f47cbe3c0b..53ca160045 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectOperations.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectOperations.cs @@ -27,6 +27,7 @@ using System;
using MonoDevelop.Projects;
using System.Collections.Generic;
+using System.Threading.Tasks;
namespace MonoDevelop.PackageManagement
{
@@ -38,7 +39,42 @@ namespace MonoDevelop.PackageManagement /// </summary>
public interface IPackageManagementProjectOperations
{
+ /// <summary>
+ /// Installs NuGet packages into the selected project. If a NuGet package requires a license to be
+ /// accepted then a dialog will be displayed.
+ /// </summary>
+ /// <param name="packageSourceUrl">Package source URL.</param>
+ /// <param name="project">Project.</param>
+ /// <param name="packages">Packages.</param>
void InstallPackages (string packageSourceUrl, Project project, IEnumerable<PackageManagementPackageReference> packages);
+
+ /// <summary>
+ /// Installs NuGet packages into the selected project.
+ /// </summary>
+ /// <param name="packageSourceUrl">Package source URL.</param>
+ /// <param name="project">Project.</param>
+ /// <param name="packages">Packages.</param>
+ /// <param name="licensesAccepted">True if NuGet package licenses have already been accepted. If false then the
+ /// license acceptance dialog will be displayed for any licences that require a license to be accepted.</param>
+ void InstallPackages (string packageSourceUrl, Project project, IEnumerable<PackageManagementPackageReference> packages, bool licensesAccepted);
+
+ /// <summary>
+ /// Installs NuGet packages into the selected project using the enabled package sources.
+ /// </summary>
+ /// <param name="project">Project.</param>
+ /// <param name="packages">Packages.</param>
+ void InstallPackages (Project project, IEnumerable<PackageManagementPackageReference> packages);
+
+ /// <summary>
+ /// Installs NuGet packages into the selected project. If a NuGet package requires a license to be
+ /// accepted then a dialog will be displayed.
+ /// </summary>
+ /// <returns>A task that can be used to determine when all the packages have been installed.</returns>
+ /// <param name="packageSourceUrl">Package source URL.</param>
+ /// <param name="project">Project.</param>
+ /// <param name="packages">Packages.</param>
+ Task InstallPackagesAsync (string packageSourceUrl, Project project, IEnumerable<PackageManagementPackageReference> packages);
+
IEnumerable<PackageManagementPackageReference> GetInstalledPackages (Project project);
event EventHandler<PackageManagementPackageReferenceEventArgs> PackageReferenceAdded;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectService.cs index 8e16b8eaa1..d8ef88f407 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementProjectService.cs @@ -43,9 +43,7 @@ namespace MonoDevelop.PackageManagement ISolution OpenSolution { get; }
IEnumerable<IDotNetProject> GetOpenProjects ();
-
- IProjectBrowserUpdater CreateProjectBrowserUpdater();
-
+
string GetDefaultCustomToolForFileName(ProjectFile projectItem);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementSelectedProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementSelectedProject.cs deleted file mode 100644 index 09d7f66efa..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementSelectedProject.cs +++ /dev/null @@ -1,43 +0,0 @@ -//
-// IPackageManagementSelectedProject.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageManagementSelectedProject
- {
- string Name { get; }
- bool IsSelected { get; set; }
- bool IsEnabled { get; set; }
-
- IPackageManagementProject Project { get; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementSolution.cs deleted file mode 100644 index 6e187b79af..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagementSolution.cs +++ /dev/null @@ -1,59 +0,0 @@ -//
-// IPackageManagementSolution.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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.Collections.Generic;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageManagementSolution
- {
- IPackageManagementProject GetActiveProject();
- IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository);
- IPackageManagementProject GetProject(PackageSource source, string projectName);
- IPackageManagementProject GetProject(IPackageRepository sourceRepository, string projectName);
- IPackageManagementProject GetProject (IPackageRepository sourceRepository, IDotNetProject project);
- IPackageManagementProject GetProject (IDotNetProject project);
- IEnumerable<IPackageManagementProject> GetProjects(IPackageRepository sourceRepository);
-
- IDotNetProject GetActiveDotNetProject ();
- IEnumerable<IDotNetProject> GetDotNetProjects ();
- bool HasMultipleProjects();
-
- bool IsPackageInstalled(IPackage package);
- IQueryable<IPackage> GetPackages();
- IEnumerable<IPackage> GetPackagesInReverseDependencyOrder();
- string GetInstallPath(IPackage package);
- ISolutionPackageRepository GetRepository ();
-
- bool IsOpen { get; }
- string FileName { get; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagerFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagerFactory.cs deleted file mode 100644 index fda6556de6..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageManagerFactory.cs +++ /dev/null @@ -1,45 +0,0 @@ -//
-// IPackageManagerFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageManagerFactory
- {
- IMonoDevelopPackageManager CreatePackageManager (
- IPackageRepository sourceRepository,
- IDotNetProject project);
-
- IPackageManager CreatePackageManager (
- IPackageRepository sourceRepository,
- ISolutionPackageRepository solutionPackageRepository);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageOperationResolverFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageOperationResolverFactory.cs deleted file mode 100644 index 104662c580..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageOperationResolverFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -//
-// IPackageOperationResolverFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageOperationResolverFactory
- {
- IPackageOperationResolver CreateInstallPackageOperationResolver(
- IPackageRepository localRepository,
- IPackageRepository sourceRepository,
- ILogger logger,
- InstallPackageAction installAction);
-
- IPackageOperationResolver CreateUpdatePackageOperationResolver(
- IPackageRepository localRepository,
- IPackageRepository sourceRepository,
- ILogger logger,
- IUpdatePackageSettings settings);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryCache.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryCache.cs deleted file mode 100644 index e8199509ac..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryCache.cs +++ /dev/null @@ -1,40 +0,0 @@ -//
-// IPackageRepositoryCache.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageRepositoryCache : IMonoDevelopPackageRepositoryFactory
- {
- IRecentPackageRepository RecentPackageRepository { get; }
- IPackageRepository CreateAggregateRepository();
- IPackageRepository CreateAggregateWithPriorityMachineCacheRepository ();
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryExtensions.cs deleted file mode 100644 index d5858da9a3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryExtensions.cs +++ /dev/null @@ -1,51 +0,0 @@ -//
-// IPackageRepositoryExtensions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal static class IPackageRepositoryExtensions
- {
- public static IDisposable StartInstallOperation(this IPackageRepository repository, string mainPackageId = null, string mainPackageVersion = null)
- {
- return repository.StartOperation(RepositoryOperationNames.Install, mainPackageId, mainPackageVersion);
- }
-
- public static IDisposable StartUpdateOperation(this IPackageRepository repository, string mainPackageId = null, string mainPackageVersion = null)
- {
- return repository.StartOperation(RepositoryOperationNames.Update, mainPackageId, mainPackageVersion);
- }
-
- public static IDisposable StartRestoreOperation (this IPackageRepository repository, string mainPackageId = null, string mainPackageVersion = null)
- {
- return repository.StartOperation (RepositoryOperationNames.Restore, mainPackageId, mainPackageVersion);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryFactoryEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryFactoryEvents.cs deleted file mode 100644 index 7495928d47..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageRepositoryFactoryEvents.cs +++ /dev/null @@ -1,37 +0,0 @@ -//
-// IPackageRepositoryFactoryEvents.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal interface IPackageRepositoryFactoryEvents
- {
- event EventHandler<PackageRepositoryFactoryEventArgs> RepositoryCreated;
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageViewModelFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageViewModelFactory.cs deleted file mode 100644 index e8506064fb..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageViewModelFactory.cs +++ /dev/null @@ -1,44 +0,0 @@ -//
-// IPackageViewModelFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IPackageViewModelFactory
- {
- PackageViewModel CreatePackageViewModel(IPackageViewModelParent parent, IPackageFromRepository package);
-
- IPackageManagementSolution Solution { get; }
- PackageManagementSelectedProjects SelectedProjects { get; }
- IPackageManagementEvents PackageManagementEvents { get; }
- IPackageActionRunner PackageActionRunner { get; }
- ILogger Logger { get; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageViewModelParent.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageViewModelParent.cs deleted file mode 100644 index 4b7079404b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IPackageViewModelParent.cs +++ /dev/null @@ -1,38 +0,0 @@ -//
-// IPackageFromRepository.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal interface IPackageViewModelParent
- {
- bool IncludePrerelease { get; }
- void OnPackageCheckedChanged (PackageViewModel packageViewModel);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IProcess.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IProcess.cs deleted file mode 100644 index b936f1701a..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IProcess.cs +++ /dev/null @@ -1,37 +0,0 @@ -//
-// IProcess.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal interface IProcess
- {
- void Start(string fileName);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IProjectBrowserUpdater.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IProjectBrowserUpdater.cs deleted file mode 100644 index f49363208c..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IProjectBrowserUpdater.cs +++ /dev/null @@ -1,36 +0,0 @@ -//
-// IProjectBrowserUpdater.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal interface IProjectBrowserUpdater : IDisposable
- {
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IRecentPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IRecentPackageRepository.cs deleted file mode 100644 index 1fa838eafc..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IRecentPackageRepository.cs +++ /dev/null @@ -1,39 +0,0 @@ -//
-// IRecentPackageRepository.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IRecentPackageRepository : IPackageRepository
- {
- void Clear();
- bool HasRecentPackages { get; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IRegisteredPackageRepositories.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IRegisteredPackageRepositories.cs deleted file mode 100644 index 5adc777250..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IRegisteredPackageRepositories.cs +++ /dev/null @@ -1,49 +0,0 @@ -//
-// IRegisteredPackageRepositories.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IRegisteredPackageRepositories
- {
- IPackageRepository ActiveRepository { get; }
- IRecentPackageRepository RecentPackageRepository { get; }
-
- IPackageRepository CreateRepository(PackageSource source);
- IPackageRepository CreateAggregateRepository();
-
- bool HasMultiplePackageSources { get; }
- PackageSource ActivePackageSource { get; set; }
- RegisteredPackageSources PackageSources { get; }
-
- void UpdatePackageSources (IEnumerable<PackageSource> updatedPackageSources);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISelectProjectsService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISelectProjectsService.cs deleted file mode 100644 index cf632388aa..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISelectProjectsService.cs +++ /dev/null @@ -1,38 +0,0 @@ -//
-// ISelectProjectsService.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface ISelectProjectsService
- {
- bool SelectProjects(IEnumerable<IPackageManagementSelectedProject> projects);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISettingsFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISettingsFactory.cs deleted file mode 100644 index 4a57175be2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISettingsFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -//
-// ISettingsFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface ISettingsFactory
- {
- ISettings CreateSettings(string directory);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolution.cs index 072b2a235c..ff0a2fb3a0 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolution.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolution.cs @@ -39,6 +39,7 @@ namespace MonoDevelop.PackageManagement FilePath FileName { get; }
IEnumerable<IDotNetProject> GetAllProjects ();
+ bool Equals (ISolution solution);
event EventHandler<DotNetProjectEventArgs> ProjectAdded;
event EventHandler<DotNetProjectEventArgs> ProjectRemoved;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepository.cs index ec46b343c8..650d7594b7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepository.cs @@ -36,14 +36,6 @@ namespace MonoDevelop.PackageManagement {
internal interface ISolutionPackageRepository
{
- string GetInstallPath(IPackage package);
- IEnumerable<IPackage> GetPackagesByDependencyOrder();
- IEnumerable<IPackage> GetPackagesByReverseDependencyOrder();
- IQueryable<IPackage> GetPackages();
- bool IsInstalled(IPackage package);
- bool IsRestored (PackageReference packageReference);
- IEnumerable<PackageReference> GetPackageReferences ();
-
ISharedPackageRepository Repository { get; }
IFileSystem FileSystem { get; }
IPackagePathResolver PackagePathResolver { get; }
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepositoryFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepositoryFactory.cs deleted file mode 100644 index ddbc2c948e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ISolutionPackageRepositoryFactory.cs +++ /dev/null @@ -1,39 +0,0 @@ -//
-// ISolutionPackageRepositoryFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface ISolutionPackageRepositoryFactory
- {
- ISolutionPackageRepository CreateSolutionPackageRepository (ISolution solution);
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IThreadSafePackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IThreadSafePackageManagementEvents.cs deleted file mode 100644 index 436f2e7621..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IThreadSafePackageManagementEvents.cs +++ /dev/null @@ -1,36 +0,0 @@ -//
-// IThreadSafePackageManagementEvents.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal interface IThreadSafePackageManagementEvents : IPackageManagementEvents, IDisposable
- {
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackageActions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackageActions.cs deleted file mode 100644 index 105698dab4..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackageActions.cs +++ /dev/null @@ -1,40 +0,0 @@ -//
-// IUpdatePackageActions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IUpdatePackageActions : IUpdatePackageSettings
- {
- //IPackageScriptRunner PackageScriptRunner { get; set; }
-
- IEnumerable<UpdatePackageAction> CreateActions();
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackageSettings.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackageSettings.cs deleted file mode 100644 index e8091917ae..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackageSettings.cs +++ /dev/null @@ -1,38 +0,0 @@ -//
-// IUpdatePackageSettings.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal interface IUpdatePackageSettings
- {
- bool UpdateDependencies { get; set; }
- bool AllowPrereleaseVersions { get; set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackagesAction.cs deleted file mode 100644 index 37953cacb9..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatePackagesAction.cs +++ /dev/null @@ -1,43 +0,0 @@ -//
-// IUpdatePackagesAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal interface IUpdatePackagesAction : IPackageAction, IUpdatePackageSettings
- {
- IEnumerable<PackageOperation> Operations { get; }
- ILogger Logger { get; set; }
-
- void AddPackages(IEnumerable<IPackageFromRepository> packages);
- void AddOperations(IEnumerable<PackageOperation> operations);
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolutionExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatedNuGetPackagesInWorkspace.cs index 128412cff8..05e2304687 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolutionExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IUpdatedNuGetPackagesInWorkspace.cs @@ -1,40 +1,38 @@ -// -// PackageManagementSolutionExtensions.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 MonoDevelop.Projects; - -namespace MonoDevelop.PackageManagement -{ - internal static class PackageManagementSolutionExtensions - { - public static IPackageManagementProject GetProject (this IPackageManagementSolution solution, DotNetProject project) - { - var projectProxy = new DotNetProjectProxy (project); - return solution.GetProject (projectProxy); - } - } -} - +//
+// IUpdatedNuGetPackagesInWorkspace.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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
+{
+ internal interface IUpdatedNuGetPackagesInWorkspace
+ {
+ void Clear ();
+ void Clear (ISolution solution);
+ void CheckForUpdates (ISolution solution);
+ UpdatedNuGetPackagesInProject GetUpdatedPackages (IDotNetProject project);
+ bool AnyUpdates ();
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs index 64cf38aa79..a16ff29b32 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ImageLoader.cs @@ -28,7 +28,7 @@ using System; using System.IO;
using System.Net;
using System.Threading.Tasks;
-using MonoDevelop.Ide;
+using MonoDevelop.Core;
using NuGet;
using MonoDevelop.PackageManagement;
using Xwt.Drawing;
@@ -40,7 +40,7 @@ namespace MonoDevelop.PackageManagement {
public event EventHandler<ImageLoadedEventArgs> Loaded;
- PackageManagementTaskFactory taskFactory = new PackageManagementTaskFactory ();
+ BackgroundDispatcher dispatcher;
Dictionary<Uri, List<object>> callersWaitingForImageLoad = new Dictionary<Uri, List<object>> ();
static readonly ImageCache imageCache = new ImageCache ();
@@ -60,11 +60,18 @@ namespace MonoDevelop.PackageManagement if (AddToCallersWaitingForImageLoad (uri, state))
return;
- ITask<ImageLoadedEventArgs> loadTask = taskFactory.CreateTask (
- () => LoadImage (uri, state),
- (task) => OnLoaded (task, uri, state));
+ if (dispatcher == null) {
+ dispatcher = new BackgroundDispatcher ();
+ dispatcher.Start ("NuGet image loader");
+ }
- loadTask.Start ();
+ dispatcher.Dispatch (() => {
+ ImageLoadedEventArgs eventArgs = LoadImage (uri, state);
+ Runtime.RunInMainThread (() => {
+ OnLoaded (eventArgs);
+ eventArgs = null;
+ });
+ });
}
bool AddToCallersWaitingForImageLoad (Uri uri, object state)
@@ -111,17 +118,6 @@ namespace MonoDevelop.PackageManagement return httpClient.GetResponse ().GetResponseStream ();
}
- void OnLoaded (ITask<ImageLoadedEventArgs> task, Uri uri, object state)
- {
- if (task.IsFaulted) {
- OnError (task.Exception, uri, state);
- } else if (task.IsCancelled) {
- // Do nothing.
- } else {
- OnLoaded (task.Result);
- }
- }
-
void OnLoaded (ImageLoadedEventArgs eventArgs)
{
if (eventArgs.Image != null) {
@@ -137,11 +133,6 @@ namespace MonoDevelop.PackageManagement }
}
- void OnError (Exception ex, Uri uri, object state)
- {
- OnLoaded (new ImageLoadedEventArgs (ex, uri, state));
- }
-
void OnLoaded (object sender, ImageLoadedEventArgs eventArgs)
{
if (Loaded != null) {
@@ -163,6 +154,7 @@ namespace MonoDevelop.PackageManagement public void Dispose ()
{
+ dispatcher?.Stop ();
ShrinkImageCache ();
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallNuGetPackageAction.cs new file mode 100644 index 0000000000..77f0b8daa7 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallNuGetPackageAction.cs @@ -0,0 +1,246 @@ +//
+// InstallNuGetPackageAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Projects;
+using NuGet.PackageManagement;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+using NuGet.Resolver;
+using NuGet.Versioning;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class InstallNuGetPackageAction : INuGetPackageAction, IInstallNuGetPackageAction, INuGetProjectActionsProvider
+ {
+ List<SourceRepository> primarySources;
+ List<SourceRepository> secondarySources;
+ INuGetPackageManager packageManager;
+ IPackageManagementEvents packageManagementEvents;
+ NuGetProject project;
+ INuGetProjectContext context;
+ IDotNetProject dotNetProject;
+ IEnumerable<NuGetProjectAction> actions;
+
+ public InstallNuGetPackageAction (
+ IEnumerable<SourceRepository> primarySources,
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext)
+ : this (
+ primarySources,
+ null,
+ solutionManager,
+ dotNetProject,
+ projectContext)
+ {
+ }
+
+ public InstallNuGetPackageAction (
+ IEnumerable<SourceRepository> primarySources,
+ IEnumerable<SourceRepository> secondarySources,
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext)
+ : this (
+ primarySources,
+ secondarySources,
+ solutionManager,
+ dotNetProject,
+ projectContext,
+ new MonoDevelopNuGetPackageManager (solutionManager),
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public InstallNuGetPackageAction (
+ IEnumerable<SourceRepository> primarySources,
+ IEnumerable<SourceRepository> secondarySources,
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext,
+ INuGetPackageManager packageManager,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.primarySources = primarySources.ToList ();
+ this.secondarySources = secondarySources?.ToList ();
+ this.dotNetProject = dotNetProject;
+ this.context = projectContext;
+ this.packageManager = packageManager;
+ this.packageManagementEvents = packageManagementEvents;
+
+ project = solutionManager.GetNuGetProject (dotNetProject);
+
+ LicensesMustBeAccepted = true;
+ PreserveLocalCopyReferences = true;
+ OpenReadmeFile = true;
+ }
+
+ public string PackageId { get; set; }
+ public NuGetVersion Version { get; set; }
+ public bool IncludePrerelease { get; set; }
+ public bool LicensesMustBeAccepted { get; set; }
+ public bool PreserveLocalCopyReferences { get; set; }
+ public bool OpenReadmeFile { get; set; }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ using (var monitor = new NuGetPackageEventsMonitor (dotNetProject, packageManagementEvents)) {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ if (Version == null) {
+ Version = await GetLatestPackageVersion (PackageId, cancellationToken);
+ }
+
+ var identity = new PackageIdentity (PackageId, Version);
+
+ actions = await packageManager.PreviewInstallPackageAsync (
+ project,
+ identity,
+ CreateResolutionContext (),
+ context,
+ primarySources,
+ secondarySources,
+ cancellationToken);
+
+ if (LicensesMustBeAccepted) {
+ await CheckLicenses (cancellationToken);
+ }
+
+ if (ShouldOpenReadmeFile (identity)) {
+ packageManager.SetDirectInstall (identity, context);
+ }
+
+ using (IDisposable fileMonitor = CreateFileMonitor ()) {
+ using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
+ await packageManager.ExecuteNuGetProjectActionsAsync (
+ project,
+ actions,
+ context,
+ cancellationToken);
+ }
+ }
+
+ packageManager.ClearDirectInstall (context);
+
+ project.OnAfterExecuteActions (actions);
+
+ await project.RunPostProcessAsync (context, cancellationToken);
+ }
+
+ Task<NuGetVersion> GetLatestPackageVersion (string packageId, CancellationToken cancellationToken)
+ {
+ return packageManager.GetLatestVersionAsync (
+ packageId,
+ project,
+ CreateResolutionContext (includeUnlisted: false),
+ primarySources,
+ new ProjectContextLogger (context),
+ cancellationToken);
+ }
+ + public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ ResolutionContext CreateResolutionContext (bool includeUnlisted = true)
+ {
+ return new ResolutionContext (
+ DependencyBehavior.Lowest,
+ IncludePrerelease,
+ includeUnlisted,
+ VersionConstraints.None
+ );
+ }
+
+ public bool IsForProject (DotNetProject project)
+ {
+ return dotNetProject.DotNetProject == project;
+ }
+
+ Task CheckLicenses (CancellationToken cancellationToken)
+ {
+ return NuGetPackageLicenseAuditor.AcceptLicenses (
+ primarySources,
+ actions,
+ packageManager,
+ GetLicenseAcceptanceService (),
+ cancellationToken);
+ }
+
+ protected virtual ILicenseAcceptanceService GetLicenseAcceptanceService ()
+ {
+ return new LicenseAcceptanceService ();
+ }
+
+ IDisposable CreateLocalCopyReferenceMaintainer ()
+ {
+ if (PreserveLocalCopyReferences) {
+ return new LocalCopyReferenceMaintainer (packageManagementEvents);
+ }
+
+ return new NullDisposable ();
+ }
+
+ public IEnumerable<NuGetProjectAction> GetNuGetProjectActions ()
+ {
+ return actions;
+ }
+
+ bool ShouldOpenReadmeFile (PackageIdentity identity)
+ {
+ return OpenReadmeFile && !packageManager.PackageExistsInPackagesFolder (identity);
+ }
+
+ IDisposable CreateFileMonitor ()
+ {
+ return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
+ packageManagementEvents,
+ GetFileRemover ());
+ }
+
+ protected virtual IFileRemover GetFileRemover ()
+ {
+ return new FileRemover ();
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs deleted file mode 100644 index 63537562d3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstallPackageAction.cs +++ /dev/null @@ -1,107 +0,0 @@ -//
-// InstallPackageAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class InstallPackageAction : ProcessPackageOperationsAction
- {
- IFileRemover fileRemover;
-
- public InstallPackageAction(
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- : this (project, packageManagementEvents, new FileRemover ())
- {
- }
-
- public InstallPackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- IFileRemover fileRemover)
- : this (project, packageManagementEvents, fileRemover, new LicenseAcceptanceService ())
- {
- }
-
- public InstallPackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- IFileRemover fileRemover,
- ILicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents, licenseAcceptanceService)
- {
- this.fileRemover = fileRemover;
-
- OpenReadMeText = true;
- PreserveLocalCopyReferences = true;
- LicensesMustBeAccepted = true;
- }
-
- public bool IgnoreDependencies { get; set; }
- public bool OpenReadMeText { get; set; }
- public bool PreserveLocalCopyReferences { get; set; }
-
- protected override IEnumerable<PackageOperation> GetPackageOperations()
- {
- return Project.GetInstallPackageOperations(Package, this);
- }
-
- protected override void ExecuteCore()
- {
- using (IOpenPackageReadMeMonitor monitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
- using (IDisposable fileMonitor = CreateFileMonitor (fileRemover)) {
- if (PreserveLocalCopyReferences) {
- using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
- Project.InstallPackage (Package, this);
- }
- } else {
- Project.InstallPackage (Package, this);
- }
- }
- monitor.OpenReadMeFile ();
- OnParentPackageInstalled ();
- }
- }
-
- protected override string StartingMessageFormat {
- get { return GettextCatalog.GetString ("Adding {0}..."); }
- }
-
- protected override IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
- {
- if (OpenReadMeText) {
- return base.CreateOpenPackageReadMeMonitor (packageId);
- }
- return NullOpenPackageReadMeMonitor.Null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackageViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackageViewModel.cs deleted file mode 100644 index cd88ac2f02..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackageViewModel.cs +++ /dev/null @@ -1,89 +0,0 @@ -//
-// InstalledPackageViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class InstalledPackageViewModel : PackageViewModel
- {
- public InstalledPackageViewModel(
- IPackageViewModelParent parent,
- IPackageFromRepository package,
- SelectedProjectsForInstalledPackages selectedProjects,
- IPackageManagementEvents packageManagementEvents,
- IPackageActionRunner actionRunner,
- ILogger logger)
- : base(parent, package, selectedProjects, packageManagementEvents, actionRunner, logger)
- {
- }
-
- public override IList<ProcessPackageAction> GetProcessPackageActionsForSelectedProjects(
- IList<IPackageManagementSelectedProject> selectedProjects)
- {
- var actions = new List<ProcessPackageAction>();
- foreach (IPackageManagementSelectedProject selectedProject in selectedProjects) {
- ProcessPackageAction action = CreatePackageAction(selectedProject);
- if (action != null) {
- actions.Add(action);
- }
- }
- return actions;
- }
-
- ProcessPackageAction CreatePackageAction(IPackageManagementSelectedProject selectedProject)
- {
- if (selectedProject.IsSelected) {
- return base.CreateInstallPackageAction(selectedProject);
- }
- return CreateUninstallPackageActionForSelectedProject(selectedProject);
- }
-
- ProcessPackageAction CreateUninstallPackageActionForSelectedProject(IPackageManagementSelectedProject selectedProject)
- {
- ProcessPackageAction action = base.CreateUninstallPackageAction(selectedProject);
- if (IsPackageInstalled(action.Project)) {
- return action;
- }
- return null;
- }
-
- bool IsPackageInstalled(IPackageManagementProject project)
- {
- IPackage package = GetPackage();
- return project.IsPackageInstalled(package);
- }
-
- protected override bool AnyProjectsSelected(IList<IPackageManagementSelectedProject> projects)
- {
- return true;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackageViewModelFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackageViewModelFactory.cs deleted file mode 100644 index f14164dacc..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackageViewModelFactory.cs +++ /dev/null @@ -1,54 +0,0 @@ -//
-// InstalledPackageViewModelFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal class InstalledPackageViewModelFactory : PackageViewModelFactory
- {
- SelectedProjectsForInstalledPackages selectedProjectsForInstalledPackages;
-
- public InstalledPackageViewModelFactory(IPackageViewModelFactory packageViewModelFactory)
- : base(packageViewModelFactory)
- {
- selectedProjectsForInstalledPackages = new SelectedProjectsForInstalledPackages(Solution);
- }
-
- public override PackageViewModel CreatePackageViewModel(IPackageViewModelParent parent, IPackageFromRepository package)
- {
- return new InstalledPackageViewModel(
- parent,
- package,
- selectedProjectsForInstalledPackages,
- PackageManagementEvents,
- PackageActionRunner,
- Logger);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackagesViewModel.cs deleted file mode 100644 index 9348cfa62c..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/InstalledPackagesViewModel.cs +++ /dev/null @@ -1,102 +0,0 @@ -//
-// InstalledPackagesViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Linq;
-using System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class InstalledPackagesViewModel : PackagesViewModel
- {
- IPackageManagementSolution solution;
- IPackageManagementEvents packageManagementEvents;
- IPackageManagementProject project;
- string errorMessage;
-
- public InstalledPackagesViewModel(
- IPackageManagementSolution solution,
- IPackageManagementEvents packageManagementEvents,
- IRegisteredPackageRepositories registeredPackageRepositories,
- InstalledPackageViewModelFactory packageViewModelFactory,
- ITaskFactory taskFactory)
- : base(registeredPackageRepositories, packageViewModelFactory, taskFactory)
- {
- this.solution = solution;
- this.packageManagementEvents = packageManagementEvents;
-
- RegisterEvents();
- TryGetActiveProject();
- }
-
- void RegisterEvents()
- {
- packageManagementEvents.ParentPackageInstalled += InstalledPackagesChanged;
- packageManagementEvents.ParentPackageUninstalled += InstalledPackagesChanged;
- packageManagementEvents.ParentPackagesUpdated += InstalledPackagesChanged;
- }
-
- void TryGetActiveProject()
- {
- try {
- project = solution.GetActiveProject();
- } catch (Exception ex) {
- errorMessage = ex.Message;
- }
- }
-
- void InstalledPackagesChanged(object sender, EventArgs e)
- {
- ReadPackages();
- }
-
- protected override void OnDispose()
- {
- packageManagementEvents.ParentPackageInstalled -= InstalledPackagesChanged;
- packageManagementEvents.ParentPackageUninstalled -= InstalledPackagesChanged;
- packageManagementEvents.ParentPackagesUpdated -= InstalledPackagesChanged;
- }
-
- protected override IQueryable<IPackage> GetAllPackages()
- {
- if (errorMessage != null) {
- ThrowOriginalExceptionWhenTryingToGetProjectManager();
- }
- if (project != null) {
- return project.GetPackages();
- }
- return solution.GetPackages();
- }
-
- void ThrowOriginalExceptionWhenTryingToGetProjectManager()
- {
- throw new ApplicationException(errorMessage);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceService.cs index a5110e4a2e..64bcb77514 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceService.cs @@ -27,6 +27,7 @@ //
using System.Collections.Generic;
+using System.Linq;
using MonoDevelop.Core;
using MonoDevelop.Ide;
using NuGet;
@@ -37,29 +38,38 @@ namespace MonoDevelop.PackageManagement {
public bool AcceptLicenses (IEnumerable<IPackage> packages)
{
+ var licenses = packages
+ .Select (package => new NuGetPackageLicense (package))
+ .ToList ();
+
+ return AcceptLicenses (licenses);
+ }
+
+ public bool AcceptLicenses (IEnumerable<NuGetPackageLicense> licenses)
+ {
if (Runtime.IsMainThread) {
- return ShowLicenseAcceptanceDialog (packages);
+ return ShowLicenseAcceptanceDialog (licenses);
}
bool accepted = false;
Runtime.RunInMainThread (() => {
- accepted = ShowLicenseAcceptanceDialog (packages);
+ accepted = ShowLicenseAcceptanceDialog (licenses);
}).Wait ();
return accepted;
}
- bool ShowLicenseAcceptanceDialog (IEnumerable<IPackage> packages)
+ bool ShowLicenseAcceptanceDialog (IEnumerable<NuGetPackageLicense> licenses)
{
- using (LicenseAcceptanceDialog dialog = CreateLicenseAcceptanceDialog (packages)) {
+ using (LicenseAcceptanceDialog dialog = CreateLicenseAcceptanceDialog (licenses)) {
dialog.Modal = false;
int result = MessageService.ShowCustomDialog (dialog, IdeApp.Workbench.RootWindow);
return result == (int)Gtk.ResponseType.Ok;
}
}
- LicenseAcceptanceDialog CreateLicenseAcceptanceDialog(IEnumerable<IPackage> packages)
+ LicenseAcceptanceDialog CreateLicenseAcceptanceDialog (IEnumerable<NuGetPackageLicense> licenses)
{
- var viewModel = new LicenseAcceptanceViewModel(packages);
+ var viewModel = new LicenseAcceptanceViewModel (licenses);
return new LicenseAcceptanceDialog(viewModel);
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceViewModel.cs index bc17c68314..ab44c5b9ca 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceViewModel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/LicenseAcceptanceViewModel.cs @@ -26,22 +26,20 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using System.Collections.Generic;
using System.Linq;
-using NuGet;
namespace MonoDevelop.PackageManagement
{
internal class LicenseAcceptanceViewModel : ViewModelBase<LicenseAcceptanceViewModel>
{
IList<PackageLicenseViewModel> packages;
-
- public LicenseAcceptanceViewModel(IEnumerable<IPackage> packages)
+
+ public LicenseAcceptanceViewModel (IEnumerable<NuGetPackageLicense> packageLicenses)
{
- this.packages = packages
- .Select(p => new PackageLicenseViewModel(p))
- .ToList();
+ packages = packageLicenses
+ .Select (p => new PackageLicenseViewModel (p))
+ .ToList ();
}
public IEnumerable<PackageLicenseViewModel> Packages {
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MSBuildProjectExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MSBuildProjectExtensions.cs index 48b81b69ba..37545c9cd8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MSBuildProjectExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MSBuildProjectExtensions.cs @@ -32,7 +32,7 @@ using System.Linq; using System.Xml;
using MonoDevelop.Projects.MSBuild;
-using NuGet;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -49,7 +49,7 @@ namespace MonoDevelop.PackageManagement public static void AddImportIfMissing (
this MSBuildProject project,
string importedProjectFile,
- ProjectImportLocation importLocation,
+ ImportLocation importLocation,
string condition)
{
if (project.ImportExists (importedProjectFile))
@@ -61,12 +61,23 @@ namespace MonoDevelop.PackageManagement public static void AddImport (
this MSBuildProject project,
string importedProjectFile,
- ProjectImportLocation importLocation,
+ ImportLocation importLocation,
string condition)
{
- var before = importLocation == ProjectImportLocation.Top ? project.GetAllObjects ().FirstOrDefault () : null;
+ MSBuildObject before = GetInsertBeforeObject (project, importLocation);
project.AddNewImport (importedProjectFile, condition, before);
}
+
+ static MSBuildObject GetInsertBeforeObject (MSBuildProject project, ImportLocation importLocation)
+ {
+ if (importLocation == ImportLocation.Top) {
+ return project.GetAllObjects ().FirstOrDefault ();
+ }
+
+ // Return an unknown MSBuildItem instead of null so the MSBuildProject adds the import as the last
+ // child in the project.
+ return new MSBuildItem ();
+ }
public static void RemoveImportIfExists (this MSBuildProject project, string importedProjectFile)
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ManagePackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ManagePackagesViewModel.cs deleted file mode 100644 index eda1c66dfa..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ManagePackagesViewModel.cs +++ /dev/null @@ -1,125 +0,0 @@ -//
-// ManagePackagesViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.ObjectModel;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ManagePackagesViewModel : ViewModelBase<ManagePackagesViewModel>, IDisposable
- {
- IThreadSafePackageManagementEvents packageManagementEvents;
- PackagesViewModels packagesViewModels;
- ManagePackagesViewTitle viewTitle;
- string message;
- bool hasError;
-
- public ManagePackagesViewModel(
- PackagesViewModels packagesViewModels,
- ManagePackagesViewTitle viewTitle,
- IThreadSafePackageManagementEvents packageManagementEvents)
- {
- this.packagesViewModels = packagesViewModels;
- this.viewTitle = viewTitle;
- this.packageManagementEvents = packageManagementEvents;
-
- packageManagementEvents.PackageOperationError += PackageOperationError;
- packageManagementEvents.PackageOperationsStarting += PackageOperationsStarting;
- }
-
- public AvailablePackagesViewModel AvailablePackagesViewModel {
- get { return packagesViewModels.AvailablePackagesViewModel; }
- }
-
- public InstalledPackagesViewModel InstalledPackagesViewModel {
- get { return packagesViewModels.InstalledPackagesViewModel; }
- }
-
- public RecentPackagesViewModel RecentPackagesViewModel {
- get { return packagesViewModels.RecentPackagesViewModel; }
- }
-
- public UpdatedPackagesViewModel UpdatedPackagesViewModel {
- get { return packagesViewModels.UpdatedPackagesViewModel; }
- }
-
- public string Title {
- get { return viewTitle.Title; }
- }
-
- public void Dispose()
- {
- packagesViewModels.Dispose();
-
- packageManagementEvents.PackageOperationError -= PackageOperationError;
- packageManagementEvents.PackageOperationsStarting -= PackageOperationsStarting;
- packageManagementEvents.Dispose();
- }
-
- void PackageOperationError(object sender, PackageOperationExceptionEventArgs e)
- {
- ShowErrorMessage(e.Exception.Message);
- }
-
- void ShowErrorMessage(string message)
- {
- this.Message = message;
- this.HasError = true;
- }
-
- public string Message {
- get { return message; }
- set {
- message = value;
- OnPropertyChanged(model => model.Message);
- }
- }
-
- public bool HasError {
- get { return hasError; }
- set {
- hasError = value;
- OnPropertyChanged(model => model.HasError);
- }
- }
-
- void PackageOperationsStarting(object sender, EventArgs e)
- {
- ClearMessage();
- }
-
- void ClearMessage()
- {
- this.Message = null;
- this.HasError = false;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ManagePackagesViewTitle.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ManagePackagesViewTitle.cs deleted file mode 100644 index ef35018dd2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ManagePackagesViewTitle.cs +++ /dev/null @@ -1,49 +0,0 @@ -//
-// ManagePackagesViewTitle.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ManagePackagesViewTitle
- {
- public ManagePackagesViewTitle(IPackageManagementSolution solution)
- {
- GetTitle(solution);
- }
-
- void GetTitle(IPackageManagementSolution solution)
- {
- var selectedProjects = new PackageManagementSelectedProjects(solution);
- string selectionName = selectedProjects.SelectionName;
- Title = GettextCatalog.GetString ("{0} - Manage Packages", selectionName);
- }
-
- public string Title { get; private set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopBuildIntegratedRestorer.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopBuildIntegratedRestorer.cs new file mode 100644 index 0000000000..59cd1f77a8 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopBuildIntegratedRestorer.cs @@ -0,0 +1,137 @@ +//
+// MonoDevelopBuildIntegratedRestorer.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using NuGet.Commands;
+using NuGet.Configuration;
+using NuGet.LibraryModel;
+using NuGet.Logging;
+using NuGet.PackageManagement;
+using NuGet.Packaging;
+using NuGet.ProjectManagement;
+using NuGet.ProjectManagement.Projects;
+using NuGet.Protocol.Core.Types;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class MonoDevelopBuildIntegratedRestorer
+ {
+ IPackageManagementEvents packageManagementEvents;
+ List<SourceRepository> sourceRepositories;
+ string packagesFolder;
+ ExternalProjectReferenceContext context;
+
+ public MonoDevelopBuildIntegratedRestorer (
+ ISourceRepositoryProvider repositoryProvider,
+ ISettings settings,
+ string solutionDirectory)
+ {
+ sourceRepositories = repositoryProvider.GetRepositories ().ToList ();
+
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+
+ packagesFolder = BuildIntegratedProjectUtility.GetEffectiveGlobalPackagesFolder (
+ solutionDirectory,
+ settings);
+
+ context = CreateRestoreContext ();
+ }
+
+ public async Task RestorePackages (
+ IEnumerable<BuildIntegratedNuGetProject> projects,
+ CancellationToken cancellationToken)
+ {
+ foreach (BuildIntegratedNuGetProject project in projects) {
+ await RestorePackages (project, cancellationToken);
+ }
+ }
+
+ public async Task RestorePackages (
+ BuildIntegratedNuGetProject project,
+ CancellationToken cancellationToken)
+ {
+ RestoreResult restoreResult = await BuildIntegratedRestoreUtility.RestoreAsync (
+ project,
+ context,
+ sourceRepositories,
+ packagesFolder,
+ cancellationToken);
+
+ if (!restoreResult.Success) {
+ ReportRestoreError (restoreResult);
+ }
+ }
+
+ ILogger CreateLogger ()
+ {
+ return new PackageManagementLogger (packageManagementEvents);
+ }
+
+ ExternalProjectReferenceContext CreateRestoreContext ()
+ {
+ return new ExternalProjectReferenceContext (CreateLogger ());
+ }
+
+ void ReportRestoreError (RestoreResult restoreResult)
+ {
+ foreach (LibraryRange libraryRange in restoreResult.GetAllUnresolved ()) {
+ packageManagementEvents.OnPackageOperationMessageLogged (
+ NuGet.MessageLevel.Info,
+ GettextCatalog.GetString ("Restore failed for '{0}'."),
+ libraryRange.ToString ());
+ }
+ throw new ApplicationException (GettextCatalog.GetString ("Restore failed."));
+ }
+
+ public Task<bool> IsRestoreRequired (BuildIntegratedNuGetProject project)
+ {
+ var pathResolver = new VersionFolderPathResolver (packagesFolder);
+ var projects = new BuildIntegratedNuGetProject[] { project };
+ return BuildIntegratedRestoreUtility.IsRestoreRequired (projects, pathResolver, context);
+ }
+
+ public async Task<IEnumerable<BuildIntegratedNuGetProject>> GetProjectsRequiringRestore (
+ IEnumerable<BuildIntegratedNuGetProject> projects)
+ {
+ var projectsToBeRestored = new List<BuildIntegratedNuGetProject> ();
+
+ foreach (BuildIntegratedNuGetProject project in projects) {
+ bool restoreRequired = await IsRestoreRequired (project);
+ if (restoreRequired) {
+ projectsToBeRestored.Add (project);
+ }
+ }
+
+ return projectsToBeRestored;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCommonOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCommonOperations.cs new file mode 100644 index 0000000000..995fc8ac3c --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCommonOperations.cs @@ -0,0 +1,55 @@ +//
+// MonoDevelopCommonOperations.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using NuGet.PackageManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class MonoDevelopCommonOperations : ICommonOperations
+ {
+ public Task CollapseAllNodes (ISolutionManager solutionManager)
+ {
+ return Task.FromResult (0);
+ }
+
+ public Task OpenFile (string fullPath)
+ {
+ return Runtime.RunInMainThread (async () => {
+ await IdeApp.Workbench.OpenDocument (new FilePath (fullPath), null, true);
+ });
+ }
+
+ public Task SaveSolutionExplorerNodeStates (ISolutionManager solutionManager)
+ {
+ return Task.FromResult (0);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCredentialProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCredentialProvider.cs index 3678763e21..f6efd0c8cc 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCredentialProvider.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopCredentialProvider.cs @@ -28,19 +28,36 @@ using System;
using System.Net;
-using NuGet;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Web;
+using NuGet.Credentials;
namespace MonoDevelop.PackageManagement
{
- class MonoDevelopCredentialProvider : ICredentialProvider + class MonoDevelopCredentialProvider : NuGet.Credentials.ICredentialProvider
{
- public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying)
+ public string Id {
+ get { return "MonoDevelop.PackageManagement.CredentialProvider"; }
+ }
+
+ public Task<CredentialResponse> Get (Uri uri, IWebProxy proxy, bool isProxyRequest, bool isRetry, bool nonInteractive, CancellationToken cancellationToken)
{
- var cp = MonoDevelop.Core.WebRequestHelper.CredentialProvider; - if (cp == null) + var cp = WebRequestHelper.CredentialProvider;
+ if (cp == null)
return null;
- return cp.GetCredentials (uri, proxy, (MonoDevelop.Core.Web.CredentialType)credentialType, retrying); + var credentialType = isProxyRequest ? CredentialType.ProxyCredentials : CredentialType.RequestCredentials;
+
+ return Task.Run (() => {
+ ICredentials credentials = cp.GetCredentials (uri, proxy, credentialType, isRetry);
+ if (credentials != null) {
+ return new CredentialResponse (credentials, CredentialStatus.Success);
+ }
+ return new CredentialResponse (CredentialStatus.ProviderNotApplicable);
+ });
}
}
}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopHttpUserAgent.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopHttpUserAgent.cs index 8a2e703a0f..c1cbfebe3b 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopHttpUserAgent.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopHttpUserAgent.cs @@ -30,6 +30,7 @@ using System; using MonoDevelop.Core;
using MonoDevelop.Ide;
using NuGet;
+using NuGet.Protocol.Core.Types;
namespace MonoDevelop.PackageManagement
{
@@ -42,23 +43,36 @@ namespace MonoDevelop.PackageManagement public string Client { get; private set; }
public string Host { get; private set; }
- public string UserAgent { get; private set; }
+ public string HttpUserAgent { get; private set; }
void CreateUserAgent()
{
- Client = BrandingService.ApplicationName;
+ Client = GetClient ();
Host = GetHost();
- UserAgent = HttpUtility.CreateUserAgentString(Client, Host);
+ HttpUserAgent = HttpUtility.CreateUserAgentString(Client, Host);
+
+ var builder = new UserAgentStringBuilder (Client).WithVisualStudioSKU (Host);
+ UserAgent.SetUserAgentString (builder);
+ }
+
+ static string GetClient ()
+ {
+ string client = BrandingService.ApplicationName;
+ if (client.StartsWith ("Xamarin Studio", StringComparison.OrdinalIgnoreCase)) {
+ return "Xamarin Studio";
+ }
+
+ return client;
}
string GetHost()
{
- return String.Format("{0}/{1}", Client, IdeApp.Version);
+ return String.Format ("{0}/{1}", BrandingService.ApplicationName, IdeApp.Version);
}
public override string ToString()
{
- return UserAgent;
+ return HttpUserAgent;
}
}
}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopMSBuildNuGetProjectSystem.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopMSBuildNuGetProjectSystem.cs new file mode 100644 index 0000000000..27138c094a --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopMSBuildNuGetProjectSystem.cs @@ -0,0 +1,563 @@ +//
+// MonoDevelopMSBuildNuGetProjectSystem.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using MonoDevelop.Projects.MSBuild;
+using NuGet.Frameworks;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class MonoDevelopMSBuildNuGetProjectSystem : IMSBuildNuGetProjectSystem
+ {
+ IDotNetProject project;
+ NuGetFramework targetFramework;
+ string projectFullPath;
+ IPackageManagementEvents packageManagementEvents;
+ IPackageManagementFileService fileService;
+ Action<Action> guiSyncDispatcher;
+ Func<Func<Task>,Task> guiSyncDispatcherFunc;
+
+ public MonoDevelopMSBuildNuGetProjectSystem (DotNetProject project, INuGetProjectContext context)
+ : this (
+ new DotNetProjectProxy (project),
+ context,
+ new PackageManagementFileService (),
+ PackageManagementServices.PackageManagementEvents,
+ DefaultGuiSyncDispatcher,
+ GuiSyncDispatchWithException)
+ {
+ }
+
+ public MonoDevelopMSBuildNuGetProjectSystem (
+ IDotNetProject project,
+ INuGetProjectContext context,
+ IPackageManagementFileService fileService,
+ IPackageManagementEvents packageManagementEvents,
+ Action<Action> guiSyncDispatcher,
+ Func<Func<Task>, Task> guiSyncDispatcherFunc)
+ {
+ this.project = project;
+ NuGetProjectContext = context;
+ this.fileService = fileService;
+ this.packageManagementEvents = packageManagementEvents;
+ this.guiSyncDispatcher = guiSyncDispatcher;
+ this.guiSyncDispatcherFunc = guiSyncDispatcherFunc;
+ }
+
+ public INuGetProjectContext NuGetProjectContext { get; private set; }
+
+ public string ProjectFullPath {
+ get {
+ if (projectFullPath == null) {
+ projectFullPath = GuiSyncDispatch (() => project.BaseDirectory);
+ }
+ return projectFullPath;
+ }
+ }
+
+ public string ProjectName {
+ get {
+ return GuiSyncDispatch (() => project.Name);
+ }
+ }
+
+ public string ProjectUniqueName {
+ get { return ProjectName; }
+ }
+
+ public NuGetFramework TargetFramework {
+ get {
+ if (targetFramework == null) {
+ targetFramework = GuiSyncDispatch (() => GetTargetFramework ());
+ }
+ return targetFramework;
+ }
+ }
+
+ NuGetFramework GetTargetFramework()
+ {
+ var projectTargetFramework = new ProjectTargetFramework (project);
+ return NuGetFramework.Parse (projectTargetFramework.TargetFrameworkName.FullName);
+ }
+
+ public void AddBindingRedirects ()
+ {
+ }
+
+ public void AddExistingFile (string path)
+ {
+ GuiSyncDispatch (async () => await AddFileToProject (path));
+ }
+
+ public void AddFile (string path, Stream stream)
+ {
+ PhysicalFileSystemAddFile (path, stream);
+ GuiSyncDispatch (async () => await AddFileToProject (path));
+ }
+
+ protected virtual void PhysicalFileSystemAddFile (string path, Stream stream)
+ {
+ FileSystemUtility.AddFile (ProjectFullPath, path, stream, NuGetProjectContext);
+ }
+
+ async Task AddFileToProject (string path)
+ {
+ if (ShouldAddFileToProject (path)) {
+ await AddFileProjectItemToProject (path);
+ }
+ OnFileChanged (path);
+ LogAddedFileToProject (path);
+ }
+
+ bool ShouldAddFileToProject (string path)
+ {
+ return !IsBinDirectory (path) && !FileExistsInProject (path);
+ }
+
+ void OnFileChanged (string path)
+ {
+ GuiSyncDispatch (() => fileService.OnFileChanged (GetFullPath (path)));
+ }
+
+ bool IsBinDirectory(string path)
+ {
+ string directoryName = Path.GetDirectoryName (path);
+ return IsMatchIgnoringCase (directoryName, "bin");
+ }
+
+ async Task AddFileProjectItemToProject(string path)
+ {
+ ProjectFile fileItem = CreateFileProjectItem (path);
+ project.AddFile (fileItem);
+ await project.SaveAsync ();
+ }
+
+ ProjectFile CreateFileProjectItem(string path)
+ {
+ //TODO custom tool?
+ string fullPath = GetFullPath (path);
+ string buildAction = project.GetDefaultBuildAction (fullPath);
+ return new ProjectFile (fullPath) {
+ BuildAction = buildAction
+ };
+ }
+
+ void LogAddedFileToProject (string fileName)
+ {
+ LogAddedFileToProject (fileName, ProjectName);
+ }
+
+ protected virtual void LogAddedFileToProject (string fileName, string projectName)
+ {
+ DebugLogFormat("Added file '{0}' to project '{1}'.", fileName, projectName);
+ }
+
+ public void AddFrameworkReference (string name)
+ {
+ GuiSyncDispatch (async () => {
+ ProjectReference assemblyReference = CreateGacReference (name);
+ await AddReferenceToProject (assemblyReference);
+ });
+ }
+
+ ProjectReference CreateGacReference (string name)
+ {
+ return ProjectReference.CreateAssemblyReference (name);
+ }
+
+ public void AddImport (string targetFullPath, ImportLocation location)
+ {
+ GuiSyncDispatch (async () => {
+ string relativeTargetPath = GetRelativePath (targetFullPath);
+ string condition = GetCondition (relativeTargetPath);
+ using (var handler = CreateNewImportsHandler ()) {
+ handler.AddImportIfMissing (relativeTargetPath, condition, location);
+ await project.SaveAsync ();
+ }
+ });
+ }
+
+ protected virtual INuGetPackageNewImportsHandler CreateNewImportsHandler ()
+ {
+ return new NuGetPackageNewImportsHandler ();
+ }
+
+ static string GetCondition (string targetPath)
+ {
+ return String.Format ("Exists('{0}')", targetPath);
+ }
+
+ string GetRelativePath (string path)
+ {
+ return MSBuildProjectService.ToMSBuildPath (project.BaseDirectory, path);
+ }
+
+ public void AddReference (string referencePath)
+ {
+ GuiSyncDispatch (async () => {
+ ProjectReference assemblyReference = CreateReference (referencePath);
+ packageManagementEvents.OnReferenceAdding (assemblyReference);
+ await AddReferenceToProject (assemblyReference);
+ });
+ }
+
+ ProjectReference CreateReference (string referencePath)
+ {
+ string fullPath = GetFullPath (referencePath);
+ return ProjectReference.CreateAssemblyFileReference (fullPath);
+ }
+
+ string GetFullPath (string relativePath)
+ {
+ return project.BaseDirectory.Combine (relativePath);
+ }
+
+ async Task AddReferenceToProject (ProjectReference assemblyReference)
+ {
+ project.References.Add (assemblyReference);
+ await project.SaveAsync ();
+ LogAddedReferenceToProject (assemblyReference);
+ }
+
+ void LogAddedReferenceToProject (ProjectReference referenceProjectItem)
+ {
+ LogAddedReferenceToProject (referenceProjectItem.Reference, ProjectName);
+ }
+
+ protected virtual void LogAddedReferenceToProject (string referenceName, string projectName)
+ {
+ DebugLogFormat ("Added reference '{0}' to project '{1}'.", referenceName, projectName);
+ }
+
+ void DebugLogFormat (string format, params object[] args)
+ {
+ NuGetProjectContext.Log (MessageLevel.Debug, format, args);
+ }
+
+ public void BeginProcessing ()
+ {
+ }
+
+ // TODO: Support recursive.
+ public void DeleteDirectory (string path, bool recursive)
+ {
+ GuiSyncDispatch (async () => {
+ string directory = GetFullPath (path);
+ fileService.RemoveDirectory (directory);
+ await project.SaveAsync ();
+ LogDeletedDirectory (path);
+ });
+ }
+
+ protected virtual void LogDeletedDirectory (string folder)
+ {
+ DebugLogFormat ("Removed folder '{0}'.", folder);
+ }
+
+ public void EndProcessing ()
+ {
+ }
+
+ public Task ExecuteScriptAsync (PackageIdentity identity, string packageInstallPath, string scriptRelativePath, NuGetProject nuGetProject, bool throwOnFailure)
+ {
+ string message = GettextCatalog.GetString (
+ "WARNING: {0} Package contains PowerShell script '{1}' which will not be run.",
+ identity.Id,
+ scriptRelativePath);
+
+ NuGetProjectContext.Log (MessageLevel.Info, message);
+
+ return Task.FromResult (0);
+ }
+
+ public bool FileExistsInProject (string path)
+ {
+ return GuiSyncDispatch (() => {
+ string fullPath = GetFullPath (path);
+ return project.IsFileInProject (fullPath);
+ });
+ }
+
+ public IEnumerable<string> GetDirectories (string path)
+ {
+ string fullPath = GetFullPath (path);
+ return EnumerateDirectories (fullPath);
+ }
+
+ protected virtual IEnumerable<string> EnumerateDirectories (string path)
+ {
+ return Directory.EnumerateDirectories (path);
+ }
+
+ public IEnumerable<string> GetFiles (string path, string filter, bool recursive)
+ {
+ if (recursive) {
+ // Visual Studio does not support recursive so we do the same.
+ throw new NotImplementedException ();
+ }
+
+ string fullPath = GetFullPath (path);
+ return EnumerateFiles (fullPath, filter, SearchOption.TopDirectoryOnly);
+ }
+
+ protected virtual IEnumerable<string> EnumerateFiles (string path, string searchPattern, SearchOption searchOption)
+ {
+ return Directory.EnumerateFiles (path, searchPattern, searchOption);
+ }
+
+ /// <summary>
+ /// This method is only used when adding/removing binding redirects which are not
+ /// currently supported.
+ /// </summary>
+ public IEnumerable<string> GetFullPaths (string fileName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public dynamic GetPropertyValue (string propertyName)
+ {
+ return GuiSyncDispatch (() => {
+ if ("RootNamespace".Equals(propertyName, StringComparison.OrdinalIgnoreCase)) {
+ return project.DefaultNamespace;
+ }
+ return String.Empty;
+ });
+ }
+
+ public bool IsSupportedFile (string path)
+ {
+ return GuiSyncDispatch (() => {
+ if (project.IsWebProject ()) {
+ return !IsAppConfigFile (path);
+ }
+ return !IsWebConfigFile (path);
+ });
+ }
+
+ bool IsWebConfigFile (string path)
+ {
+ return IsFileNameMatchIgnoringPath ("web.config", path);
+ }
+
+ bool IsAppConfigFile (string path)
+ {
+ return IsFileNameMatchIgnoringPath ("app.config", path);
+ }
+
+ bool IsFileNameMatchIgnoringPath (string fileName1, string path)
+ {
+ string fileName2 = Path.GetFileName (path);
+ return IsMatchIgnoringCase (fileName1, fileName2);
+ }
+
+ public bool ReferenceExists (string name)
+ {
+ return GuiSyncDispatch (() => {
+ ProjectReference referenceProjectItem = FindReference (name);
+ if (referenceProjectItem != null) {
+ return true;
+ }
+ return false;
+ });
+ }
+
+ ProjectReference FindReference (string name)
+ {
+ string referenceName = GetReferenceName (name);
+ foreach (ProjectReference referenceProjectItem in project.References) {
+ string projectReferenceName = GetProjectReferenceName (referenceProjectItem.Reference);
+ if (IsMatchIgnoringCase (projectReferenceName, referenceName)) {
+ return referenceProjectItem;
+ }
+ }
+ return null;
+ }
+
+ string GetReferenceName (string name)
+ {
+ if (HasDllOrExeFileExtension (name)) {
+ return Path.GetFileNameWithoutExtension (name);
+ }
+ return name;
+ }
+
+ string GetProjectReferenceName (string name)
+ {
+ string referenceName = GetReferenceName(name);
+ return GetAssemblyShortName(referenceName);
+ }
+
+ string GetAssemblyShortName(string name)
+ {
+ string[] parts = name.Split(',');
+ return parts[0];
+ }
+
+ bool HasDllOrExeFileExtension (string name)
+ {
+ string extension = Path.GetExtension (name);
+ return
+ IsMatchIgnoringCase (extension, ".dll") ||
+ IsMatchIgnoringCase (extension, ".exe");
+ }
+
+ bool IsMatchIgnoringCase (string lhs, string rhs)
+ {
+ return String.Equals (lhs, rhs, StringComparison.InvariantCultureIgnoreCase);
+ }
+
+ public void RegisterProcessedFiles (IEnumerable<string> files)
+ {
+ }
+
+ public void RemoveFile (string path)
+ {
+ GuiSyncDispatch (async () => {
+ string fileName = GetFullPath (path);
+ project.Files.Remove (fileName);
+ fileService.RemoveFile (fileName);
+ await project.SaveAsync ();
+ LogDeletedFileInfo (path);
+ });
+ }
+
+ void LogDeletedFileInfo (string path)
+ {
+ string fileName = Path.GetFileName (path);
+ string directory = Path.GetDirectoryName (path);
+ if (String.IsNullOrEmpty (directory)) {
+ LogDeletedFile (fileName);
+ } else {
+ LogDeletedFileFromDirectory (fileName, directory);
+ }
+ }
+
+ protected virtual void LogDeletedFile (string fileName)
+ {
+ DebugLogFormat ("Removed file '{0}'.", fileName);
+ }
+
+ protected virtual void LogDeletedFileFromDirectory (string fileName, string directory)
+ {
+ DebugLogFormat ("Removed file '{0}' from folder '{1}'.", fileName, directory);
+ }
+
+ public void RemoveImport (string targetFullPath)
+ {
+ GuiSyncDispatch (async () => {
+ string relativeTargetPath = GetRelativePath (targetFullPath);
+ project.RemoveImport (relativeTargetPath);
+ RemoveImportWithForwardSlashes (targetFullPath);
+
+ using (var updater = new EnsureNuGetPackageBuildImportsTargetUpdater ()) {
+ updater.RemoveImport (relativeTargetPath);
+ await project.SaveAsync ();
+ }
+
+ packageManagementEvents.OnImportRemoved (project, relativeTargetPath);
+ });
+ }
+
+ void RemoveImportWithForwardSlashes (string targetPath)
+ {
+ string relativeTargetPath = FileService.AbsoluteToRelativePath (project.BaseDirectory, targetPath);
+ if (Path.DirectorySeparatorChar == '\\') {
+ relativeTargetPath = relativeTargetPath.Replace ('\\', '/');
+ }
+ project.RemoveImport (relativeTargetPath);
+ }
+
+ public void RemoveReference (string name)
+ {
+ GuiSyncDispatch (async () => {
+ ProjectReference referenceProjectItem = FindReference (name);
+ if (referenceProjectItem != null) {
+ packageManagementEvents.OnReferenceRemoving (referenceProjectItem);
+ project.References.Remove (referenceProjectItem);
+ await project.SaveAsync ();
+ LogRemovedReferenceFromProject (referenceProjectItem);
+ }
+ });
+ }
+
+ void LogRemovedReferenceFromProject (ProjectReference referenceProjectItem)
+ {
+ LogRemovedReferenceFromProject (referenceProjectItem.Reference, ProjectName);
+ }
+
+ protected virtual void LogRemovedReferenceFromProject (string referenceName, string projectName)
+ {
+ DebugLogFormat ("Removed reference '{0}' from project '{1}'.", referenceName, projectName);
+ }
+
+ public string ResolvePath (string path)
+ {
+ return path;
+ }
+
+ public void SetNuGetProjectContext (INuGetProjectContext nuGetProjectContext)
+ {
+ NuGetProjectContext = nuGetProjectContext;
+ }
+
+ T GuiSyncDispatch<T> (Func<T> action)
+ {
+ T result = default(T);
+ guiSyncDispatcher (() => result = action ());
+ return result;
+ }
+
+ void GuiSyncDispatch (Action action)
+ {
+ guiSyncDispatcher (() => action ());
+ }
+
+ static Task GuiSyncDispatchWithException (Func<Task> func)
+ {
+ if (Runtime.IsMainThread)
+ throw new InvalidOperationException ("GuiSyncDispatch called from GUI thread");
+ return Runtime.RunInMainThread (func);
+ }
+
+ public static void DefaultGuiSyncDispatcher (Action action)
+ {
+ Runtime.RunInMainThread (action).Wait ();
+ }
+
+ void GuiSyncDispatch (Func<Task> func)
+ {
+ guiSyncDispatcherFunc (func).Wait ();
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopNuGetPackageManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopNuGetPackageManager.cs new file mode 100644 index 0000000000..ccba160293 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopNuGetPackageManager.cs @@ -0,0 +1,232 @@ +// +// MonoDevelopNuGetPackageManager.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// OpenReadmeFiles based on NuGet.Clients +// src/NuGet.Core/NuGet.PackageManagement/NuGetPackageManager.cs +// +// Copyright (c) 2016 Xamarin Inc. +// Copyright (c) .NET Foundation. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Configuration; +using NuGet.Logging; +using NuGet.PackageManagement; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.ProjectManagement.Projects; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement +{ + internal class MonoDevelopNuGetPackageManager : INuGetPackageManager + { + NuGetPackageManager packageManager; + ISettings settings; + + public MonoDevelopNuGetPackageManager (IMonoDevelopSolutionManager solutionManager) + { + var restartManager = new DeleteOnRestartManager (); + + settings = solutionManager.Settings; + + packageManager = new NuGetPackageManager ( + solutionManager.CreateSourceRepositoryProvider (), + settings, + solutionManager, + restartManager + ); + } + + public MonoDevelopNuGetPackageManager (NuGetPackageManager packageManager) + { + this.packageManager = packageManager; + } + + public void ClearDirectInstall (INuGetProjectContext nuGetProjectContext) + { + NuGetPackageManager.ClearDirectInstall (nuGetProjectContext); + } + + public void SetDirectInstall (PackageIdentity directInstall, INuGetProjectContext nuGetProjectContext) + { + NuGetPackageManager.SetDirectInstall (directInstall, nuGetProjectContext); + } + + public Task ExecuteNuGetProjectActionsAsync ( + NuGetProject nuGetProject, + IEnumerable<NuGetProjectAction> nuGetProjectActions, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + return packageManager.ExecuteNuGetProjectActionsAsync ( + nuGetProject, + nuGetProjectActions, + nuGetProjectContext, + token); + } + + public Task<NuGetVersion> GetLatestVersionAsync ( + string packageId, + NuGetProject project, + ResolutionContext resolutionContext, + IEnumerable<SourceRepository> sources, + ILogger log, + CancellationToken token) + { + return NuGetPackageManager.GetLatestVersionAsync ( + packageId, + project, + resolutionContext, + sources, + log, + token + ); + } + + public Task<IEnumerable<NuGetProjectAction>> PreviewInstallPackageAsync ( + NuGetProject nuGetProject, + PackageIdentity packageIdentity, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token) + { + return packageManager.PreviewInstallPackageAsync ( + nuGetProject, + packageIdentity, + resolutionContext, + nuGetProjectContext, + primarySources, + secondarySources, + token + ); + } + + public bool PackageExistsInPackagesFolder (PackageIdentity packageIdentity) + { + return packageManager.PackageExistsInPackagesFolder (packageIdentity); + } + + public Task<IEnumerable<NuGetProjectAction>> PreviewUpdatePackagesAsync ( + string packageId, + NuGetProject nuGetProject, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token) + { + return packageManager.PreviewUpdatePackagesAsync ( + packageId, + nuGetProject, + resolutionContext, + nuGetProjectContext, + primarySources, + secondarySources, + token + ); + } + + public Task<IEnumerable<NuGetProjectAction>> PreviewUpdatePackagesAsync ( + NuGetProject nuGetProject, + ResolutionContext resolutionContext, + INuGetProjectContext nuGetProjectContext, + IEnumerable<SourceRepository> primarySources, + IEnumerable<SourceRepository> secondarySources, + CancellationToken token) + { + return packageManager.PreviewUpdatePackagesAsync ( + nuGetProject, + resolutionContext, + nuGetProjectContext, + primarySources, + secondarySources, + token + ); + } + + public Task<IEnumerable<NuGetProjectAction>> PreviewUninstallPackageAsync ( + NuGetProject nuGetProject, + string packageId, + UninstallationContext uninstallationContext, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + return packageManager.PreviewUninstallPackageAsync ( + nuGetProject, + packageId, + uninstallationContext, + nuGetProjectContext, + token + ); + } + + public async Task OpenReadmeFiles ( + NuGetProject nuGetProject, + IEnumerable<PackageIdentity> packages, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + var executionContext = nuGetProjectContext.ExecutionContext; + if (executionContext != null) { + foreach (var package in packages) { + await OpenReadmeFiles (nuGetProject, package, executionContext, token); + } + } + } + + Task OpenReadmeFiles ( + NuGetProject nuGetProject, + PackageIdentity package, + NuGet.ProjectManagement.ExecutionContext executionContext, + CancellationToken token) + { + //packagesPath is different for project.json vs Packages.config scenarios. So check if the project is a build-integrated project + var buildIntegratedProject = nuGetProject as BuildIntegratedNuGetProject; + var readmeFilePath = String.Empty; + + if (buildIntegratedProject != null) { + var packageFolderPath = BuildIntegratedProjectUtility.GetPackagePathFromGlobalSource ( + SettingsUtility.GetGlobalPackagesFolder (settings), + package); + + if (Directory.Exists (packageFolderPath)) { + readmeFilePath = Path.Combine (packageFolderPath, Constants.ReadmeFileName); + } + } else { + var packagePath = packageManager.PackagesFolderNuGetProject.GetInstalledPackageFilePath (package); + if (File.Exists(packagePath)) { + readmeFilePath = Path.Combine (Path.GetDirectoryName (packagePath), Constants.ReadmeFileName); + } + } + + if (File.Exists (readmeFilePath) && !token.IsCancellationRequested) { + return executionContext.OpenFile (readmeFilePath); + } + return Task.FromResult (0); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopNuGetProjectFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopNuGetProjectFactory.cs new file mode 100644 index 0000000000..ff8f81b2a9 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopNuGetProjectFactory.cs @@ -0,0 +1,107 @@ +//
+// MonoDevelopNuGetProjectFactory.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.IO;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.Common;
+using NuGet.Configuration;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class MonoDevelopNuGetProjectFactory
+ {
+ ISettings settings;
+
+ public MonoDevelopNuGetProjectFactory ()
+ : this (SettingsLoader.LoadDefaultSettings ())
+ {
+ }
+
+ public MonoDevelopNuGetProjectFactory (ISettings settings)
+ {
+ this.settings = settings;
+ }
+
+ public NuGetProject CreateNuGetProject (IDotNetProject project)
+ {
+ return CreateNuGetProject (project.DotNetProject);
+ }
+
+ public NuGetProject CreateNuGetProject (DotNetProject project)
+ {
+ return CreateNuGetProject (project, new EmptyNuGetProjectContext ());
+ }
+
+ public NuGetProject CreateNuGetProject (IDotNetProject project, INuGetProjectContext context)
+ {
+ return CreateNuGetProject (project.DotNetProject, context);
+ }
+
+ public NuGetProject CreateNuGetProject (DotNetProject project, INuGetProjectContext context)
+ {
+ Runtime.AssertMainThread ();
+
+ var projectSystem = new MonoDevelopMSBuildNuGetProjectSystem (project, context);
+
+ string projectJsonPath = ProjectJsonPathUtilities.GetProjectConfigPath (project.BaseDirectory, project.Name);
+
+ if (File.Exists (projectJsonPath)) {
+ return new BuildIntegratedProjectSystem (
+ projectJsonPath,
+ project.FileName,
+ project,
+ projectSystem,
+ project.Name,
+ settings);
+ }
+
+ string baseDirectory = GetBaseDirectory (project);
+ string folderNuGetProjectFullPath = PackagesFolderPathUtility.GetPackagesFolderPath (baseDirectory, settings);
+
+ string packagesConfigFolderPath = project.BaseDirectory;
+
+ return new MSBuildNuGetProject (
+ projectSystem,
+ folderNuGetProjectFullPath,
+ packagesConfigFolderPath);
+ }
+
+ static string GetBaseDirectory (DotNetProject project)
+ {
+ if (project.ParentSolution != null)
+ return project.ParentSolution.BaseDirectory;
+
+ LoggingService.LogWarning ("Project has no solution. Using project directory as base directory for NuGet. Project: '{0}'", project.FileName);
+
+ return project.BaseDirectory;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageManager.cs deleted file mode 100644 index dd3985fa06..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageManager.cs +++ /dev/null @@ -1,251 +0,0 @@ -//
-// MonoDevelopPackageManager.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012-2013 Matthew Ward
-//
-// 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.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class MonoDevelopPackageManager : PackageManager, IMonoDevelopPackageManager
- {
- IProjectSystem projectSystem;
- IPackageOperationResolverFactory packageOperationResolverFactory;
-
- public MonoDevelopPackageManager(
- IPackageRepository sourceRepository,
- IProjectSystem projectSystem,
- ISolutionPackageRepository solutionPackageRepository,
- IPackageOperationResolverFactory packageOperationResolverFactory)
- : base(
- sourceRepository,
- solutionPackageRepository.PackagePathResolver,
- solutionPackageRepository.FileSystem,
- solutionPackageRepository.Repository)
- {
- this.projectSystem = projectSystem;
- this.packageOperationResolverFactory = packageOperationResolverFactory;
- CreateProjectManager();
- }
-
- /// <summary>
- /// project manager should be created with:
- /// local repo = PackageReferenceRepository(projectSystem, sharedRepo)
- /// packageRefRepo should have its RegisterIfNecessary() method called before creating the project manager.
- /// source repo = sharedRepository
- /// </summary>
- void CreateProjectManager()
- {
- var packageRefRepository = CreatePackageReferenceRepository();
- ProjectManager = CreateProjectManager(packageRefRepository);
- }
-
- PackageReferenceRepository CreatePackageReferenceRepository()
- {
- var sharedRepository = LocalRepository as ISharedPackageRepository;
- var packageRefRepository = new PackageReferenceRepository(projectSystem, projectSystem.ProjectName, sharedRepository);
- packageRefRepository.RegisterIfNecessary();
- return packageRefRepository;
- }
-
- public IMonoDevelopProjectManager ProjectManager { get; set; }
-
- MonoDevelopProjectManager CreateProjectManager(PackageReferenceRepository packageRefRepository)
- {
- IPackageRepository sourceRepository = CreateProjectManagerSourceRepository ();
- return new MonoDevelopProjectManager (sourceRepository, PathResolver, projectSystem, packageRefRepository);
- }
-
- IPackageRepository CreateProjectManagerSourceRepository ()
- {
- var fallbackRepository = SourceRepository as FallbackRepository;
- if (fallbackRepository != null) {
- var primaryRepositories = new [] {
- LocalRepository,
- fallbackRepository.SourceRepository.Clone () };
-
- return new FallbackRepository (
- new AggregateRepository (primaryRepositories),
- fallbackRepository.DependencyResolver);
- }
- return new AggregateRepository (new [] { LocalRepository, SourceRepository.Clone () });
- }
- - public void InstallPackage(IPackage package)
- {
- bool ignoreDependencies = false;
- bool allowPreleaseVersions = false;
- InstallPackage(package, ignoreDependencies, allowPreleaseVersions);
- }
-
- public void InstallPackage(IPackage package, InstallPackageAction installAction)
- {
- RunPackageOperations(installAction.Operations);
- AddPackageReference(package, installAction.IgnoreDependencies, installAction.AllowPrereleaseVersions);
- }
-
- public void AddPackageReference (IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- var monitor = new PackageReferenceMonitor (ProjectManager, this);
- using (monitor) {
- ProjectManager.AddPackageReference(package.Id, package.Version, ignoreDependencies, allowPrereleaseVersions);
- }
-
- monitor.PackagesRemoved.ForEach(packageRemoved => UninstallPackageFromSolutionRepository(packageRemoved));
- }
-
- public override void InstallPackage(IPackage package, bool ignoreDependencies, bool allowPrereleaseVersions)
- {
- base.InstallPackage(package, ignoreDependencies, allowPrereleaseVersions);
- AddPackageReference(package, ignoreDependencies, allowPrereleaseVersions);
- }
-
- public void UninstallPackage(IPackage package, UninstallPackageAction uninstallAction)
- {
- UninstallPackage(package, uninstallAction.ForceRemove, uninstallAction.RemoveDependencies);
- }
-
- public override void UninstallPackage(IPackage package, bool forceRemove, bool removeDependencies)
- {
- ProjectManager.RemovePackageReference(package.Id, forceRemove, removeDependencies);
- if (!IsPackageReferencedByOtherProjects(package)) {
- base.UninstallPackage(package, forceRemove, removeDependencies);
- }
- }
-
- public void UninstallPackageFromSolutionRepository(IPackage package)
- {
- if (!IsPackageReferencedByOtherProjects(package)) {
- ExecuteUninstall(package);
- }
- }
-
- public void InstallPackageIntoSolutionRepository (IPackage package)
- {
- if (!LocalRepository.Exists (package)) {
- ExecuteInstall (package);
- }
- }
-
- bool IsPackageReferencedByOtherProjects(IPackage package)
- {
- var sharedRepository = LocalRepository as ISharedPackageRepository;
- return sharedRepository.IsReferenced(package.Id, package.Version);
- }
-
- public IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, InstallPackageAction installAction)
- {
- IPackageOperationResolver resolver = CreateInstallPackageOperationResolver(installAction);
- return resolver.ResolveOperations(package);
- }
-
- IPackageOperationResolver CreateInstallPackageOperationResolver(InstallPackageAction installAction)
- {
- return packageOperationResolverFactory.CreateInstallPackageOperationResolver(
- LocalRepository,
- SourceRepository,
- Logger,
- installAction);
- }
-
- public void UpdatePackage(IPackage package, UpdatePackageAction updateAction)
- {
- RunPackageOperations(updateAction.Operations);
- UpdatePackageReference(package, updateAction);
- }
-
- public void UpdatePackageReference(IPackage package, IUpdatePackageSettings settings)
- {
- UpdatePackageReference(package, settings.UpdateDependencies, settings.AllowPrereleaseVersions);
- }
-
- void UpdatePackageReference(IPackage package, bool updateDependencies, bool allowPrereleaseVersions)
- {
- var monitor = new PackageReferenceMonitor (ProjectManager, this);
- using (monitor) {
- ProjectManager.UpdatePackageReference(package.Id, package.Version, updateDependencies, allowPrereleaseVersions);
- }
-
- monitor.PackagesRemoved.ForEach(packageRemoved => UninstallPackageFromSolutionRepository(packageRemoved));
- }
-
- public void UpdatePackages(UpdatePackagesAction updateAction)
- {
- RunPackageOperations(updateAction.Operations);
- foreach (IPackage package in updateAction.Packages) {
- UpdatePackageReference(package, updateAction);
- }
- }
-
- public IEnumerable<PackageOperation> GetUpdatePackageOperations(
- IEnumerable<IPackage> packages,
- IUpdatePackageSettings settings)
- {
- IPackageOperationResolver resolver = CreateUpdatePackageOperationResolver(settings);
-
- var reducedOperations = new ReducedPackageOperations(resolver, packages);
- reducedOperations.Reduce();
- return reducedOperations.Operations;
- }
-
- IPackageOperationResolver CreateUpdatePackageOperationResolver(IUpdatePackageSettings settings)
- {
- return packageOperationResolverFactory.CreateUpdatePackageOperationResolver(
- LocalRepository,
- SourceRepository,
- Logger,
- settings);
- }
-
- public void RunPackageOperations(IEnumerable<PackageOperation> operations)
- {
- foreach (PackageOperation operation in operations) {
- Execute(operation);
- }
- }
-
- public ReinstallPackageOperations GetReinstallPackageOperations (IEnumerable<IPackage> packages)
- {
- var installWalker = new InstallWalker (
- LocalRepository,
- SourceRepository,
- ProjectManager.Project.TargetFramework,
- ProjectManager.Logger,
- ignoreDependencies: true,
- allowPrereleaseVersions: false,
- dependencyVersion: DependencyVersion.Lowest);
-
- IList<IPackage> packagesInDependencyOrder;
- IList<PackageOperation> operations = installWalker.ResolveOperations (
- packages,
- out packagesInDependencyOrder,
- allowPrereleaseVersionsBasedOnPackage: true);
-
- return new ReinstallPackageOperations (operations, packagesInDependencyOrder);
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageManagerFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageManagerFactory.cs deleted file mode 100644 index f9b191e565..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageManagerFactory.cs +++ /dev/null @@ -1,95 +0,0 @@ -//
-// MonoDevelopPackageManagerFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class MonoDevelopPackageManagerFactory : IPackageManagerFactory
- {
- PackageManagementOptions options;
- IMonoDevelopPackageRepositoryFactory packageRepositoryFactory;
- IMonoDevelopProjectSystemFactory projectSystemFactory;
-
- public MonoDevelopPackageManagerFactory()
- : this(
- new MonoDevelopPackageRepositoryFactory(),
- new MonoDevelopProjectSystemFactory(),
- PackageManagementServices.Options)
- {
- }
-
- public MonoDevelopPackageManagerFactory(
- IMonoDevelopPackageRepositoryFactory packageRepositoryFactory,
- IMonoDevelopProjectSystemFactory projectSystemFactory,
- PackageManagementOptions options)
- {
- this.packageRepositoryFactory = packageRepositoryFactory;
- this.projectSystemFactory = projectSystemFactory;
- this.options = options;
- }
-
- public IMonoDevelopPackageManager CreatePackageManager(
- IPackageRepository sourceRepository,
- IDotNetProject project)
- {
- SolutionPackageRepository solutionPackageRepository = CreateSolutionPackageRepository (project.ParentSolution);
- IProjectSystem projectSystem = CreateProjectSystem (project.DotNetProject);
- PackageOperationsResolverFactory packageOperationResolverFactory = new PackageOperationsResolverFactory();
-
- return new MonoDevelopPackageManager(
- sourceRepository,
- projectSystem,
- solutionPackageRepository,
- packageOperationResolverFactory);
- }
-
- SolutionPackageRepository CreateSolutionPackageRepository (ISolution solution)
- {
- return new SolutionPackageRepository (solution, packageRepositoryFactory, options);
- }
-
- IProjectSystem CreateProjectSystem(DotNetProject project)
- {
- return projectSystemFactory.CreateProjectSystem(project);
- }
-
- public IPackageManager CreatePackageManager (
- IPackageRepository sourceRepository,
- ISolutionPackageRepository solutionPackageRepository)
- {
- return new PackageManager (
- sourceRepository,
- solutionPackageRepository.PackagePathResolver,
- solutionPackageRepository.FileSystem,
- solutionPackageRepository.Repository);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRepositoryFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRepositoryFactory.cs index 47a35521cc..fe044a748a 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRepositoryFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRepositoryFactory.cs @@ -42,17 +42,5 @@ namespace MonoDevelop.PackageManagement {
return new SharedPackageRepository(pathResolver, fileSystem, configSettingsFileSystem);
}
-
- public IRecentPackageRepository CreateRecentPackageRepository(
- IList<RecentPackageInfo> recentPackages,
- IPackageRepository aggregateRepository)
- {
- return new RecentPackageRepository(recentPackages, aggregateRepository);
- }
-
- public IPackageRepository CreateAggregateRepository(IEnumerable<IPackageRepository> repositories)
- {
- return new MonoDevelopAggregateRepository (repositories);
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRestoreManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRestoreManager.cs new file mode 100644 index 0000000000..cb6383eb76 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageRestoreManager.cs @@ -0,0 +1,126 @@ +// +// MonoDevelopPackageRestoreManager.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using NuGet.PackageManagement; +using NuGet.ProjectManagement; + +namespace MonoDevelop.PackageManagement +{ + internal class MonoDevelopPackageRestoreManager : IPackageRestoreManager + { + PackageRestoreManager restoreManager; + + public MonoDevelopPackageRestoreManager (IMonoDevelopSolutionManager solutionManager) + { + restoreManager = new PackageRestoreManager ( + solutionManager.CreateSourceRepositoryProvider (), + solutionManager.Settings, + solutionManager); + } + + public bool IsCurrentSolutionEnabledForRestore { + get { + return restoreManager.IsCurrentSolutionEnabledForRestore; + } + } + + public event EventHandler<NuGet.PackageManagement.PackageRestoredEventArgs> PackageRestoredEvent { + add { restoreManager.PackageRestoredEvent += value; } + remove { restoreManager.PackageRestoredEvent -= value; } + } + + public event EventHandler<PackageRestoreFailedEventArgs> PackageRestoreFailedEvent{ + add { restoreManager.PackageRestoreFailedEvent += value; } + remove { restoreManager.PackageRestoreFailedEvent -= value; } + } + public event EventHandler<PackagesMissingStatusEventArgs> PackagesMissingStatusChanged{ + add { restoreManager.PackagesMissingStatusChanged += value; } + remove { restoreManager.PackagesMissingStatusChanged -= value; } + } + + public void EnableCurrentSolutionForRestore (bool fromActivation) + { + restoreManager.EnableCurrentSolutionForRestore (fromActivation); + } + + public Task<IEnumerable<PackageRestoreData>> GetPackagesInSolutionAsync ( + string solutionDirectory, + CancellationToken token) + { + return restoreManager.GetPackagesInSolutionAsync (solutionDirectory, token); + } + + public Task RaisePackagesMissingEventForSolutionAsync (string solutionDirectory, CancellationToken token) + { + return restoreManager.RaisePackagesMissingEventForSolutionAsync (solutionDirectory, token); + } + + public Task<PackageRestoreResult> RestoreMissingPackagesAsync ( + string solutionDirectory, + IEnumerable<PackageRestoreData> packages, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + return restoreManager.RestoreMissingPackagesAsync ( + solutionDirectory, + packages, + nuGetProjectContext, + token + ); + } + + public Task<PackageRestoreResult> RestoreMissingPackagesAsync ( + string solutionDirectory, + NuGetProject nuGetProject, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + return restoreManager.RestoreMissingPackagesAsync ( + solutionDirectory, + nuGetProject, + nuGetProjectContext, + token + ); + } + + public Task<PackageRestoreResult> RestoreMissingPackagesInSolutionAsync ( + string solutionDirectory, + INuGetProjectContext nuGetProjectContext, + CancellationToken token) + { + return restoreManager.RestoreMissingPackagesInSolutionAsync ( + solutionDirectory, + nuGetProjectContext, + token + ); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageSourceProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageSourceProvider.cs new file mode 100644 index 0000000000..330632b340 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopPackageSourceProvider.cs @@ -0,0 +1,102 @@ +// +// MonoDevelopPackageSourceProvider.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using MonoDevelop.Core; +using NuGet.Configuration; + +namespace MonoDevelop.PackageManagement +{ + internal class MonoDevelopPackageSourceProvider : IPackageSourceProvider + { + readonly PackageSourceProvider packageSourceProvider; + + public MonoDevelopPackageSourceProvider (ISettings settings) + { + packageSourceProvider = new PackageSourceProvider (settings); + } + + public string ActivePackageSourceName { + get { return packageSourceProvider.ActivePackageSourceName; } + } + + public event EventHandler PackageSourcesChanged { + add { + packageSourceProvider.PackageSourcesChanged += value; + } + + remove { + packageSourceProvider.PackageSourcesChanged -= value; + } + } + + public void DisablePackageSource (PackageSource source) + { + packageSourceProvider.DisablePackageSource (source); + } + + public bool IsPackageSourceEnabled (PackageSource source) + { + return packageSourceProvider.IsPackageSourceEnabled (source); + } + + public IEnumerable<PackageSource> LoadPackageSources () + { + bool atLeastOnePackageSource = false; + + foreach (PackageSource source in packageSourceProvider.LoadPackageSources ()) { + atLeastOnePackageSource = true; + yield return source; + } + + if (!atLeastOnePackageSource) { + yield return GetDefaultPackageSource (); + } + } + + public void SaveActivePackageSource (PackageSource source) + { + packageSourceProvider.SaveActivePackageSource (source); + } + + public void SavePackageSources (IEnumerable<PackageSource> sources) + { + packageSourceProvider.SavePackageSources (sources); + } + + static PackageSource GetDefaultPackageSource () + { + return new PackageSource ( + NuGetConstants.V3FeedUrl, + GettextCatalog.GetString ("Official NuGet Gallery") + ) { + ProtocolVersion = 3 + }; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectManager.cs deleted file mode 100644 index 445c6260f5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectManager.cs +++ /dev/null @@ -1,64 +0,0 @@ -//
-// MonoDevelopProjectManager.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class MonoDevelopProjectManager : ProjectManager, IMonoDevelopProjectManager
- {
- public MonoDevelopProjectManager(
- IPackageRepository sourceRepository,
- IPackagePathResolver pathResolver,
- IProjectSystem project,
- IPackageRepository localRepository)
- : base(sourceRepository, pathResolver, project, localRepository)
- {
- }
-
- public bool IsInstalled(string packageId)
- {
- return LocalRepository.Exists(packageId);
- }
-
- public bool HasOlderPackageInstalled(IPackage package)
- {
- IPackage installedPackage = LocalRepository.FindPackage(package.Id);
- return (installedPackage != null) &&
- (installedPackage.Version < package.Version);
- }
-
- public IEnumerable<PackageReference> GetPackageReferences ()
- {
- var repository = LocalRepository as PackageReferenceRepository;
- return repository.ReferenceFile.GetPackageReferences ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs deleted file mode 100644 index 3ea935f025..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystem.cs +++ /dev/null @@ -1,504 +0,0 @@ -//
-// MonoDevelopProjectSystem.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.IO;
-using System.Runtime.Versioning;
-using System.Threading.Tasks;
-
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.MSBuild;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class MonoDevelopProjectSystem : PhysicalFileSystem, IProjectSystem
- {
- IDotNetProject project;
- ProjectTargetFramework targetFramework;
- IPackageManagementFileService fileService;
- IPackageManagementEvents packageManagementEvents;
- Action<Action> guiSyncDispatcher;
- Func<Func<Task>,Task> guiSyncDispatcherFunc;
-
- public MonoDevelopProjectSystem(DotNetProject project)
- : this (
- new DotNetProjectProxy (project),
- new PackageManagementFileService (),
- PackageManagementServices.ProjectService,
- PackageManagementServices.PackageManagementEvents,
- DefaultGuiSyncDispatcher,
- GuiSyncDispatchWithException)
- {
- }
-
- public MonoDevelopProjectSystem (
- IDotNetProject project,
- IPackageManagementFileService fileService,
- IPackageManagementProjectService projectService,
- IPackageManagementEvents packageManagementEvents,
- Action<Action> guiSyncDispatcher,
- Func<Func<Task>, Task> guiSyncDispatcherFunc)
- : base (AppendTrailingSlashToDirectory (project.BaseDirectory))
- {
- this.project = project;
- this.fileService = fileService;
- this.packageManagementEvents = packageManagementEvents;
- this.guiSyncDispatcher = guiSyncDispatcher;
- this.guiSyncDispatcherFunc = guiSyncDispatcherFunc;
- }
-
- static string AppendTrailingSlashToDirectory(string directory)
- {
- return directory + Path.DirectorySeparatorChar.ToString();
- }
-
- public bool IsBindingRedirectSupported { get; set; }
-
- public FrameworkName TargetFramework {
- get {
- return GuiSyncDispatch (() => GetTargetFramework ());
- }
- }
-
- FrameworkName GetTargetFramework()
- {
- if (targetFramework == null) {
- targetFramework = new ProjectTargetFramework(project);
- }
- return targetFramework.TargetFrameworkName;
- }
-
- public string ProjectName {
- get {
- return GuiSyncDispatch (() => project.Name);
- }
- }
-
- public dynamic GetPropertyValue (string propertyName)
- {
- return GuiSyncDispatch (() => {
- if ("RootNamespace".Equals(propertyName, StringComparison.OrdinalIgnoreCase)) {
- return project.DefaultNamespace;
- }
- return String.Empty;
- });
- }
-
- public void AddReference(string referencePath, Stream stream)
- {
- GuiSyncDispatch (async () => {
- ProjectReference assemblyReference = CreateReference (referencePath);
- packageManagementEvents.OnReferenceAdding (assemblyReference);
- await AddReferenceToProject (assemblyReference);
- });
- }
-
- ProjectReference CreateReference(string referencePath)
- {
- string fullPath = GetFullPath(referencePath);
- return ProjectReference.CreateAssemblyFileReference (fullPath);
- }
-
- async Task AddReferenceToProject(ProjectReference assemblyReference)
- {
- project.References.Add (assemblyReference);
- await project.SaveAsync ();
- LogAddedReferenceToProject(assemblyReference);
- }
-
- void LogAddedReferenceToProject(ProjectReference referenceProjectItem)
- {
- LogAddedReferenceToProject(referenceProjectItem.Reference, ProjectName);
- }
-
- protected virtual void LogAddedReferenceToProject(string referenceName, string projectName)
- {
- string message = GettextCatalog.GetString ("Added reference '{0}' to project '{1}'.", referenceName, projectName);
- DebugLog (message);
- }
-
- void DebugLog (string message)
- {
- Logger.Log (MessageLevel.Debug, message);
- }
-
- public bool ReferenceExists(string name)
- {
- return GuiSyncDispatch (() => {
- ProjectReference referenceProjectItem = FindReference (name);
- if (referenceProjectItem != null) {
- return true;
- }
- return false;
- });
- }
-
- ProjectReference FindReference(string name)
- {
- string referenceName = GetReferenceName(name);
- foreach (ProjectReference referenceProjectItem in project.References) {
- string projectReferenceName = GetProjectReferenceName(referenceProjectItem.Reference);
- if (IsMatchIgnoringCase(projectReferenceName, referenceName)) {
- return referenceProjectItem;
- }
- }
- return null;
- }
-
- string GetReferenceName(string name)
- {
- if (HasDllOrExeFileExtension(name)) {
- return Path.GetFileNameWithoutExtension(name);
- }
- return name;
- }
-
- string GetProjectReferenceName(string name)
- {
- string referenceName = GetReferenceName(name);
- return GetAssemblyShortName(referenceName);
- }
-
- string GetAssemblyShortName(string name)
- {
- string[] parts = name.Split(',');
- return parts[0];
- }
-
- bool HasDllOrExeFileExtension(string name)
- {
- string extension = Path.GetExtension(name);
- return
- IsMatchIgnoringCase(extension, ".dll") ||
- IsMatchIgnoringCase(extension, ".exe");
- }
-
- bool IsMatchIgnoringCase(string lhs, string rhs)
- {
- return String.Equals(lhs, rhs, StringComparison.InvariantCultureIgnoreCase);
- }
-
- public void RemoveReference(string name)
- {
- GuiSyncDispatch (async () => {
- ProjectReference referenceProjectItem = FindReference (name);
- if (referenceProjectItem != null) {
- packageManagementEvents.OnReferenceRemoving (referenceProjectItem);
- project.References.Remove (referenceProjectItem);
- await project.SaveAsync ();
- LogRemovedReferenceFromProject (referenceProjectItem);
- }
- });
- }
-
- void LogRemovedReferenceFromProject(ProjectReference referenceProjectItem)
- {
- LogRemovedReferenceFromProject(referenceProjectItem.Reference, ProjectName);
- }
-
- protected virtual void LogRemovedReferenceFromProject(string referenceName, string projectName)
- {
- string message = GettextCatalog.GetString ("Removed reference '{0}' from project '{1}'.", referenceName, projectName);
- DebugLog (message);
- }
-
- public bool IsSupportedFile(string path)
- {
- return GuiSyncDispatch (() => {
- if (project.IsWebProject ()) {
- return !IsAppConfigFile (path);
- }
- return !IsWebConfigFile (path);
- });
- }
-
- bool IsWebConfigFile(string path)
- {
- return IsFileNameMatchIgnoringPath("web.config", path);
- }
-
- bool IsAppConfigFile(string path)
- {
- return IsFileNameMatchIgnoringPath("app.config", path);
- }
-
- bool IsFileNameMatchIgnoringPath(string fileName1, string path)
- {
- string fileName2 = Path.GetFileName(path);
- return IsMatchIgnoringCase(fileName1, fileName2);
- }
-
- public override void AddFile(string path, Stream stream)
- {
- PhysicalFileSystemAddFile(path, stream);
- GuiSyncDispatch (async () => await AddFileToProject (path));
- }
-
- protected virtual void PhysicalFileSystemAddFile(string path, Stream stream)
- {
- base.AddFile(path, stream);
- }
-
- public override void AddFile(string path, Action<Stream> writeToStream)
- {
- PhysicalFileSystemAddFile (path, writeToStream);
- GuiSyncDispatch (async () => await AddFileToProject (path));
- }
-
- protected virtual void PhysicalFileSystemAddFile (string path, Action<Stream> writeToStream)
- {
- base.AddFile(path, writeToStream);
- }
-
- async Task AddFileToProject(string path)
- {
- if (ShouldAddFileToProject(path)) {
- await AddFileProjectItemToProject(path);
- }
- OnFileChanged (path);
- LogAddedFileToProject(path);
- }
-
- bool ShouldAddFileToProject(string path)
- {
- return !IsBinDirectory(path) && !FileExistsInProject(path);
- }
-
- void OnFileChanged (string path)
- {
- GuiSyncDispatch (() => fileService.OnFileChanged (GetFullPath (path)));
- }
-
- bool IsBinDirectory(string path)
- {
- string directoryName = Path.GetDirectoryName(path);
- return IsMatchIgnoringCase(directoryName, "bin");
- }
-
- public bool FileExistsInProject(string path)
- {
- string fullPath = GetFullPath(path);
- return GuiSyncDispatch (() => {
- return project.IsFileInProject (fullPath);
- });
- }
-
- async Task AddFileProjectItemToProject(string path)
- {
- ProjectFile fileItem = CreateFileProjectItem (path);
- project.AddFile (fileItem);
- await project.SaveAsync ();
- }
-
- ProjectFile CreateFileProjectItem(string path)
- {
- //TODO custom tool?
- string fullPath = GetFullPath(path);
- string buildAction = project.GetDefaultBuildAction(fullPath);
- return new ProjectFile(fullPath) {
- BuildAction = buildAction
- };
- }
-
- void LogAddedFileToProject(string fileName)
- {
- LogAddedFileToProject(fileName, ProjectName);
- }
-
- protected virtual void LogAddedFileToProject(string fileName, string projectName)
- {
- string message = GettextCatalog.GetString ("Added file '{0}' to project '{1}'.", fileName, projectName);
- DebugLog (message);
- }
-
- public override void DeleteDirectory(string path, bool recursive)
- {
- GuiSyncDispatch (async () => {
- string directory = GetFullPath (path);
- fileService.RemoveDirectory (directory);
- await project.SaveAsync ();
- LogDeletedDirectory (path);
- });
- }
-
- public override void DeleteFile(string path)
- {
- GuiSyncDispatch (async () => {
- string fileName = GetFullPath (path);
- project.Files.Remove (fileName);
- fileService.RemoveFile (fileName);
- await project.SaveAsync ();
- LogDeletedFileInfo (path);
- });
- }
-
- protected virtual void LogDeletedDirectory(string folder)
- {
- string message = GettextCatalog.GetString ("Removed folder '{0}'.", folder);
- DebugLog (message);
- }
-
- void LogDeletedFileInfo(string path)
- {
- string fileName = Path.GetFileName(path);
- string directory = Path.GetDirectoryName(path);
- if (String.IsNullOrEmpty(directory)) {
- LogDeletedFile(fileName);
- } else {
- LogDeletedFileFromDirectory(fileName, directory);
- }
- }
-
- protected virtual void LogDeletedFile(string fileName)
- {
- string message = GettextCatalog.GetString ("Removed file '{0}'.", fileName);
- DebugLog (message);
- }
-
- protected virtual void LogDeletedFileFromDirectory(string fileName, string directory)
- {
- string message = GettextCatalog.GetString ("Removed file '{0}' from folder '{1}'.", fileName, directory);
- DebugLog (message);
- }
-
- public void AddFrameworkReference(string name)
- {
- GuiSyncDispatch (async () => {
- ProjectReference assemblyReference = CreateGacReference (name);
- await AddReferenceToProject (assemblyReference);
- });
- }
-
- ProjectReference CreateGacReference(string name)
- {
- return ProjectReference.CreateAssemblyReference (name);
- }
-
- public string ResolvePath(string path)
- {
- return path;
- }
-
- public void AddImport(string targetPath, ProjectImportLocation location)
- {
- GuiSyncDispatch (async () => {
- string relativeTargetPath = GetRelativePath (targetPath);
- string condition = GetCondition (relativeTargetPath);
- using (var handler = CreateNewImportsHandler ()) {
- handler.AddImportIfMissing (relativeTargetPath, condition, location);
- await project.SaveAsync ();
- }
- });
- }
-
- protected virtual INuGetPackageNewImportsHandler CreateNewImportsHandler ()
- {
- return new NuGetPackageNewImportsHandler ();
- }
-
- static string GetCondition (string targetPath)
- {
- return String.Format ("Exists('{0}')", targetPath);
- }
-
- string GetRelativePath(string path)
- {
- return MSBuildProjectService.ToMSBuildPath (project.BaseDirectory, path);
- }
-
- public void RemoveImport(string targetPath)
- {
- GuiSyncDispatch (async () => {
- string relativeTargetPath = GetRelativePath (targetPath);
- project.RemoveImport (relativeTargetPath);
- RemoveImportWithForwardSlashes (targetPath);
-
- using (var updater = new EnsureNuGetPackageBuildImportsTargetUpdater ()) {
- updater.RemoveImport (relativeTargetPath);
- await project.SaveAsync ();
- }
-
- packageManagementEvents.OnImportRemoved (project, relativeTargetPath);
- });
- }
-
- void RemoveImportWithForwardSlashes (string targetPath)
- {
- string relativeTargetPath = FileService.AbsoluteToRelativePath (project.BaseDirectory, targetPath);
- if (Path.DirectorySeparatorChar == '\\') {
- relativeTargetPath = relativeTargetPath.Replace ('\\', '/');
- }
- project.RemoveImport (relativeTargetPath);
- }
-
- /// <summary>
- /// NuGet sometimes uses CreateFile to replace an existing file.
- /// This happens when the XML transformation (web.config.transform) is reverted on
- /// uninstalling a NuGet package. It also happens when an XML document transform
- /// (.install.xdt, .uninstall.xdt) is run.
- /// </summary>
- public override Stream CreateFile (string path)
- {
- OnFileChanged (path);
- return base.CreateFile (path);
- }
-
- T GuiSyncDispatch<T> (Func<T> action)
- {
- T result = default(T);
- guiSyncDispatcher (() => result = action ());
- return result;
- }
-
- void GuiSyncDispatch (Action action)
- {
- guiSyncDispatcher (() => action ());
- }
-
- static Task GuiSyncDispatchWithException (Func<Task> func)
- {
- if (Runtime.IsMainThread)
- throw new InvalidOperationException ("GuiSyncDispatch called from GUI thread");
- return Runtime.RunInMainThread (func);
- }
-
- public static void DefaultGuiSyncDispatcher (Action action)
- {
- Runtime.RunInMainThread (action).Wait ();
- }
-
- void GuiSyncDispatch (Func<Task> func)
- {
- guiSyncDispatcherFunc (func).Wait ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystemFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystemFactory.cs deleted file mode 100644 index 62dc7d1817..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopProjectSystemFactory.cs +++ /dev/null @@ -1,42 +0,0 @@ -//
-// MonoDevelopProjectSystemFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class MonoDevelopProjectSystemFactory : IMonoDevelopProjectSystemFactory
- {
- public IProjectSystem CreateProjectSystem(DotNetProject project)
- {
- return new MonoDevelopProjectSystem(project);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopSolutionManager.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopSolutionManager.cs new file mode 100644 index 0000000000..7fc379988a --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopSolutionManager.cs @@ -0,0 +1,158 @@ +//
+// MonoDevelopSolutionManager.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.Configuration;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class MonoDevelopSolutionManager : IMonoDevelopSolutionManager
+ {
+ List<NuGetProject> projects;
+
+ public MonoDevelopSolutionManager (ISolution solution)
+ : this (solution.Solution)
+ {
+ }
+
+ public MonoDevelopSolutionManager (Solution solution)
+ {
+ Solution = solution;
+ LoadSettings ();
+ }
+
+ public Solution Solution { get; private set; }
+ public ISettings Settings { get; private set; }
+
+ public NuGetProject DefaultNuGetProject {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public string DefaultNuGetProjectName {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public bool IsSolutionAvailable {
+ get { return true; }
+ }
+
+ public bool IsSolutionOpen {
+ get { return true; }
+ }
+
+ public INuGetProjectContext NuGetProjectContext { get; set; }
+
+ public string SolutionDirectory {
+ get { return Solution.BaseDirectory; }
+ }
+
+ #pragma warning disable 67
+ public event EventHandler<ActionsExecutedEventArgs> ActionsExecuted;
+ public event EventHandler<NuGetProjectEventArgs> NuGetProjectAdded;
+ public event EventHandler<NuGetProjectEventArgs> NuGetProjectRemoved;
+ public event EventHandler<NuGetProjectEventArgs> NuGetProjectRenamed;
+ public event EventHandler SolutionClosed;
+ public event EventHandler SolutionClosing;
+ public event EventHandler SolutionOpened;
+ public event EventHandler SolutionOpening;
+ #pragma warning restore 67
+
+ public NuGetProject GetNuGetProject (string nuGetProjectSafeName)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public IEnumerable<NuGetProject> GetNuGetProjects ()
+ {
+ if (projects == null) {
+ Runtime.RunInMainThread (() => {
+ projects = GetNuGetProjects (Solution, Settings).ToList ();
+ }).Wait ();
+ }
+ return projects;
+ }
+
+ static IEnumerable<NuGetProject> GetNuGetProjects (Solution solution, ISettings settings)
+ {
+ var factory = new MonoDevelopNuGetProjectFactory (settings);
+ foreach (DotNetProject project in solution.GetAllDotNetProjects ()) {
+ yield return factory.CreateNuGetProject (project);
+ }
+ }
+
+ public string GetNuGetProjectSafeName (NuGetProject nuGetProject)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public void OnActionsExecuted (IEnumerable<ResolvedAction> actions)
+ {
+ }
+
+ public NuGetProject GetNuGetProject (IDotNetProject project)
+ {
+ return new MonoDevelopNuGetProjectFactory (Settings)
+ .CreateNuGetProject (project);
+ }
+
+ public ISourceRepositoryProvider CreateSourceRepositoryProvider ()
+ {
+ return SourceRepositoryProviderFactory.CreateSourceRepositoryProvider (Settings);
+ }
+
+ public void ReloadSettings ()
+ {
+ try {
+ LoadSettings ();
+ } catch (Exception ex) {
+ LoggingService.LogError ("Failed to reload settings.", ex);
+ }
+ }
+
+ void LoadSettings ()
+ {
+ string rootDirectory = Path.Combine (Solution.BaseDirectory, ".nuget");
+ Settings = SettingsLoader.LoadDefaultSettings (rootDirectory, reportError: true);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageEventsMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageEventsMonitor.cs new file mode 100644 index 0000000000..5625dbaa85 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageEventsMonitor.cs @@ -0,0 +1,92 @@ +//
+// NuGetPackageEventsMonitor.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class NuGetPackageEventsMonitor : IDisposable
+ {
+ IDotNetProject project;
+ PackageEvents packageEvents;
+ PackageManagementEvents packageManagementEvents;
+
+ public NuGetPackageEventsMonitor (IDotNetProject project)
+ : this (
+ project,
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public NuGetPackageEventsMonitor (
+ IDotNetProject project,
+ IPackageManagementEvents packageManagementEvents)
+ : this (
+ project,
+ new PackageEventsProvider (),
+ packageManagementEvents)
+ {
+ }
+
+ public NuGetPackageEventsMonitor (
+ IDotNetProject project,
+ IPackageEventsProvider provider,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.project = project;
+ packageEvents = provider.GetPackageEvents ();
+ this.packageManagementEvents = (PackageManagementEvents)packageManagementEvents;
+
+ packageEvents.PackageInstalled += PackageInstalled;
+ packageEvents.PackageUninstalling += PackageUninstalling;
+ packageEvents.PackageUninstalled += PackageUninstalled;
+ }
+
+ public void Dispose ()
+ {
+ packageEvents.PackageInstalled -= PackageInstalled;
+ packageEvents.PackageUninstalling -= PackageUninstalling;
+ packageEvents.PackageUninstalled -= PackageUninstalled;
+ }
+
+ void PackageInstalled (object sender, PackageEventArgs e)
+ {
+ packageManagementEvents.OnPackageInstalled (project, e);
+ }
+
+ void PackageUninstalling (object sender, PackageEventArgs e)
+ {
+ packageManagementEvents.OnPackageUninstalling (project, e);
+ }
+
+ void PackageUninstalled (object sender, PackageEventArgs e)
+ {
+ packageManagementEvents.OnPackageUninstalled (project, e);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageForcedImportsRemover.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageForcedImportsRemover.cs new file mode 100644 index 0000000000..52f9a1e099 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageForcedImportsRemover.cs @@ -0,0 +1,74 @@ +// +// NuGetPackageForcedImportsRemover.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Linq; +using MonoDevelop.Core; +using MonoDevelop.Projects.MSBuild; + +namespace MonoDevelop.PackageManagement +{ + internal class NuGetPackageForcedImportsRemover : IDisposable + { + FilePath importsBaseDirectory; + + public NuGetPackageForcedImportsRemover (FilePath importsBaseDirectory) + { + this.importsBaseDirectory = importsBaseDirectory; + PackageManagementMSBuildExtension.ForcedImportsRemover = this; + } + + public void Dispose () + { + PackageManagementMSBuildExtension.ForcedImportsRemover = null; + } + + public void UpdateProject (MSBuildProject project) + { + string importsRelativeDirectory = MSBuildProjectService.ToMSBuildPath (project.BaseDirectory, importsBaseDirectory); + + var importsToRemove = project.Imports.Where (import => IsMatch (import, importsRelativeDirectory)).ToList (); + + using (var updater = new EnsureNuGetPackageBuildImportsTargetUpdater ()) { + foreach (MSBuildImport import in importsToRemove) { + project.RemoveImport (import.Project); + + updater.RemoveImport (import.Project); + updater.UpdateProject (project); + } + } + } + + static bool IsMatch (MSBuildImport import, string importsRelativeDirectory) + { + if (String.IsNullOrEmpty (import.Project)) + return false; + + return import.Project.StartsWith (importsRelativeDirectory, StringComparison.OrdinalIgnoreCase); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MSBuildTargetsRestoredMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageLicense.cs index a9e8ee54dc..442dd7a3de 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MSBuildTargetsRestoredMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageLicense.cs @@ -1,10 +1,10 @@ //
-// MSBuildTargetsRestoredMonitor.cs
+// NuGetPackageLicense.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -25,40 +25,41 @@ // THE SOFTWARE.
using System;
-using System.Linq;
-using MonoDevelop.PackageManagement;
using NuGet;
+using NuGet.Packaging.Core;
+using NuGet.Protocol.Core.Types;
namespace MonoDevelop.PackageManagement
{
- internal class MSBuildTargetsRestoredMonitor : IDisposable
+ internal class NuGetPackageLicense
{
- IPackageManagementEvents packageManagementEvents;
-
- public MSBuildTargetsRestoredMonitor (IPackageManagementEvents packageManagementEvents)
+ public NuGetPackageLicense (IPackageSearchMetadata metadata)
{
- this.packageManagementEvents = packageManagementEvents;
- this.packageManagementEvents.PackageRestored += PackageRestored;
+ PackageIdentity = metadata.Identity;
+ PackageId = metadata.Identity.Id;
+ PackageTitle = metadata.Title;
+ PackageAuthor = metadata.Authors;
+ LicenseUrl = metadata.LicenseUrl;
}
- void PackageRestored (object sender, PackageRestoredEventArgs e)
+ public NuGetPackageLicense (IPackage package)
{
- if (PackageHasMSBuildTargetsFile (e.Package)) {
- AnyMSBuildTargetsRestored = true;
- }
+ PackageId = package.Id;
+ PackageTitle = package.Title;
+ PackageAuthor = GetAuthor (package);
+ LicenseUrl = package.LicenseUrl;
}
- bool PackageHasMSBuildTargetsFile (IPackage package)
- {
- return package.GetBuildFiles ().Any ();
- }
+ public PackageIdentity PackageIdentity { get; private set; } + public string PackageId { get; private set; }
+ public string PackageTitle { get; private set; }
+ public string PackageAuthor { get; private set; }
+ public Uri LicenseUrl { get; private set; }
- public void Dispose ()
+ static string GetAuthor (IPackage package)
{
- this.packageManagementEvents.PackageRestored -= PackageRestored;
+ return String.Join (", ", package.Authors);
}
-
- public bool AnyMSBuildTargetsRestored { get; private set; }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageLicenseAuditor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageLicenseAuditor.cs new file mode 100644 index 0000000000..14a2c16205 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageLicenseAuditor.cs @@ -0,0 +1,166 @@ +//
+// NuGetPackageLicenseAuditor.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using NuGet.Logging;
+using NuGet.PackageManagement;
+using NuGet.Packaging.Core;
+using NuGet.Protocol.Core.Types;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class NuGetPackageLicenseAuditor
+ {
+ List<SourceRepository> sources;
+ INuGetPackageManager packageManager;
+ ILicenseAcceptanceService licenseAcceptanceService;
+
+ public NuGetPackageLicenseAuditor (
+ IEnumerable<SourceRepository> sources,
+ INuGetPackageManager packageManager)
+ : this (
+ sources,
+ packageManager,
+ new LicenseAcceptanceService ())
+ {
+ }
+
+ public NuGetPackageLicenseAuditor (
+ IEnumerable<SourceRepository> sources,
+ INuGetPackageManager packageManager,
+ ILicenseAcceptanceService licenseAcceptanceService)
+ {
+ this.sources = sources.ToList ();
+ this.packageManager = packageManager;
+ this.licenseAcceptanceService = licenseAcceptanceService;
+ }
+
+ public static Task AcceptLicenses (
+ IEnumerable<SourceRepository> sources,
+ IEnumerable<NuGetProjectAction> actions,
+ NuGetPackageManager packageManager,
+ CancellationToken cancellationToken)
+ {
+ return AcceptLicenses (
+ sources,
+ actions,
+ new MonoDevelopNuGetPackageManager (packageManager),
+ new LicenseAcceptanceService (),
+ cancellationToken);
+ }
+
+ public static Task AcceptLicenses (
+ IEnumerable<SourceRepository> sources,
+ IEnumerable<NuGetProjectAction> actions,
+ INuGetPackageManager packageManager,
+ ILicenseAcceptanceService licenseAcceptanceService,
+ CancellationToken cancellationToken)
+ {
+ var auditor = new NuGetPackageLicenseAuditor (sources, packageManager, licenseAcceptanceService);
+ return auditor.AcceptLicenses (actions, cancellationToken);
+ }
+
+ async Task AcceptLicenses (
+ IEnumerable<NuGetProjectAction> actions,
+ CancellationToken cancellationToken)
+ {
+ var licenses = await GetPackagesWithLicences (actions, cancellationToken);
+ licenses = RemovePackagesAlreadyInstalled (licenses);
+ if (licenses.Any ()) {
+ if (!licenseAcceptanceService.AcceptLicenses (licenses)) {
+ throw new ApplicationException (GettextCatalog.GetString ("Licenses not accepted."));
+ }
+ }
+ } + + public async Task<IEnumerable<NuGetPackageLicense>> GetPackagesWithLicences (
+ IEnumerable<NuGetProjectAction> actions,
+ CancellationToken cancellationToken)
+ {
+ var licenses = new List<NuGetPackageLicense> ();
+
+ foreach (PackageIdentity package in GetPackages (actions)) {
+ NuGetPackageLicense license = await GetPackageLicense (package, cancellationToken);
+ if (license != null) {
+ licenses.Add (license);
+ }
+ }
+
+ return licenses;
+ }
+
+ async Task<NuGetPackageLicense> GetPackageLicense (
+ PackageIdentity package,
+ CancellationToken cancellationToken)
+ {
+ foreach (SourceRepository source in sources) {
+ var metadataResource = source.GetResource<PackageMetadataResource> ();
+ if (metadataResource != null) {
+ var packagesMetadata = await metadataResource.GetMetadataAsync (
+ package.Id,
+ includePrerelease: true,
+ includeUnlisted: true,
+ log: NullLogger.Instance,
+ token: cancellationToken);
+
+ var metadata = packagesMetadata.FirstOrDefault (p => p.Identity.Version == package.Version);
+ if (metadata != null) {
+ if (metadata.RequireLicenseAcceptance) {
+ return new NuGetPackageLicense (metadata);
+ }
+ return null;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ IEnumerable<PackageIdentity> GetPackages (IEnumerable<NuGetProjectAction> actions)
+ {
+ var installActions = actions
+ .Where (action => action.NuGetProjectActionType == NuGetProjectActionType.Install);
+
+ var packages = new HashSet<PackageIdentity> (PackageIdentity.Comparer);
+ foreach (NuGetProjectAction action in installActions) {
+ packages.Add (action.PackageIdentity);
+ }
+
+ return packages;
+ }
+
+ IEnumerable<NuGetPackageLicense> RemovePackagesAlreadyInstalled (IEnumerable<NuGetPackageLicense> licenses) + { + return licenses.Where (license => !packageManager.PackageExistsInPackagesFolder (license.PackageIdentity)); + }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageNewImportsHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageNewImportsHandler.cs index ba687b81a1..32189b89df 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageNewImportsHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageNewImportsHandler.cs @@ -26,7 +26,7 @@ using System; using MonoDevelop.Projects.MSBuild; -using NuGet; +using NuGet.ProjectManagement; namespace MonoDevelop.PackageManagement { @@ -34,7 +34,7 @@ namespace MonoDevelop.PackageManagement { string name; string condition; - ProjectImportLocation location; + ImportLocation location; public NuGetPackageNewImportsHandler () { @@ -46,7 +46,7 @@ namespace MonoDevelop.PackageManagement PackageManagementMSBuildExtension.NewImportsHandler = null; } - public void AddImportIfMissing (string name, string condition, ProjectImportLocation location) + public void AddImportIfMissing (string name, string condition, ImportLocation location) { this.name = name; this.condition = condition; diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageUninstaller.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageUninstaller.cs new file mode 100644 index 0000000000..aab2608b0b --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetPackageUninstaller.cs @@ -0,0 +1,74 @@ +// +// NuGetPackageUninstaller.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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.Linq; +using System.Threading.Tasks; +using MonoDevelop.Core; +using MonoDevelop.Projects.MSBuild; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement +{ + internal class NuGetPackageUninstaller + { + IDotNetProject project; + PackagePathResolver packagePathResolver; + PackageIdentity packageIdentity; + + public NuGetPackageUninstaller (IDotNetProject project, PackagePathResolver packagePathResolver) + { + this.project = project; + this.packagePathResolver = packagePathResolver; + } + + public async Task ForceUninstall (string packageId, NuGetVersion packageVersion) + { + packageIdentity = new PackageIdentity (packageId, packageVersion); + + FilePath installPath = packagePathResolver.GetInstallPath (packageIdentity); + RemoveReferences (installPath); + + using (var importRemover = new NuGetPackageForcedImportsRemover (installPath)) { + await project.SaveAsync (); + } + } + + void RemoveReferences (FilePath installPath) + { + var references = project.References + .Where (reference => reference.HintPath.IsNotNull) + .Where (reference => reference.HintPath.IsChildPathOf (installPath)) + .ToList (); + + if (references.Any ()) { + project.References.RemoveRange (references); + } + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetProjectContext.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetProjectContext.cs new file mode 100644 index 0000000000..675aaf40f7 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetProjectContext.cs @@ -0,0 +1,75 @@ +//
+// NuGetProjectContext.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Xml.Linq;
+using NuGet.PackageManagement;
+using NuGet.Packaging;
+using NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class NuGetProjectContext : INuGetProjectContext
+ {
+ IPackageManagementEvents packageManagementEvents;
+ IDEExecutionContext executionContext;
+
+ public NuGetProjectContext ()
+ {
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+ var commonOperations = new MonoDevelopCommonOperations ();
+ executionContext = new IDEExecutionContext (commonOperations);
+ }
+
+ public ExecutionContext ExecutionContext {
+ get { return executionContext; }
+ }
+
+ public NuGetActionType ActionType { get; set; }
+ public XDocument OriginalPackagesConfig { get; set; }
+ public PackageExtractionContext PackageExtractionContext { get; set; }
+
+ public ISourceControlManagerProvider SourceControlManagerProvider {
+ get { return null; }
+ }
+
+ public void Log (MessageLevel level, string message, params object [] args)
+ {
+ packageManagementEvents.OnPackageOperationMessageLogged ((NuGet.MessageLevel)level, message, args);
+ }
+
+ public void ReportError (string message)
+ {
+ packageManagementEvents.OnPackageOperationMessageLogged (NuGet.MessageLevel.Error, message);
+ }
+
+ public FileConflictAction ResolveFileConflict (string message)
+ {
+ return packageManagementEvents.OnResolveFileConflict (message);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetProjectExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetProjectExtensions.cs new file mode 100644 index 0000000000..c2c9405175 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetProjectExtensions.cs @@ -0,0 +1,84 @@ +//
+// NuGetProjectExtensions.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+using NuGet.ProjectManagement.Projects;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal static class NuGetProjectExtensions
+ {
+ public static FilePath GetPackagesFolderPath (this NuGetProject project, IMonoDevelopSolutionManager solutionManager)
+ {
+ if (project is BuildIntegratedProjectSystem) {
+ string globalPackagesPath = BuildIntegratedProjectUtility.GetEffectiveGlobalPackagesFolder (
+ solutionManager.SolutionDirectory,
+ solutionManager.Settings);
+
+ return new FilePath (globalPackagesPath).FullPath;
+ }
+
+ string path = PackagesFolderPathUtility.GetPackagesFolderPath (solutionManager, solutionManager.Settings);
+ return new FilePath (path).FullPath;
+ }
+
+ /// <summary>
+ /// PostProcessAsync is not run for BuildIntegratedNuGetProjects so we run it directly after
+ /// running a NuGet action.
+ /// </summary>
+ public static Task RunPostProcessAsync (this NuGetProject project, INuGetProjectContext context, CancellationToken token)
+ {
+ var buildIntegratedProject = project as IBuildIntegratedNuGetProject;
+ if (buildIntegratedProject != null) {
+ return buildIntegratedProject.PostProcessAsync (context, token);
+ }
+
+ return Task.FromResult (0);
+ }
+
+ public static void OnAfterExecuteActions (this NuGetProject project, IEnumerable<NuGetProjectAction> actions)
+ {
+ var buildIntegratedProject = project as IBuildIntegratedNuGetProject;
+ if (buildIntegratedProject != null) {
+ buildIntegratedProject.OnAfterExecuteActions (actions);
+ }
+ }
+
+ public static void OnBeforeUninstall (this NuGetProject project, IEnumerable<NuGetProjectAction> actions)
+ {
+ var buildIntegratedProject = project as IBuildIntegratedNuGetProject;
+ if (buildIntegratedProject != null) {
+ buildIntegratedProject.OnBeforeUninstall (actions);
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetSystemInformation.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetSystemInformation.cs new file mode 100644 index 0000000000..a191e10493 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NuGetSystemInformation.cs @@ -0,0 +1,56 @@ +//
+// NuGetSystemInformation.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 MonoDevelop.Core;
+using NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ class NuGetSystemInformation : ISystemInformationProvider
+ {
+ public string Title {
+ get { return "NuGet"; }
+ }
+
+ public string Description {
+ get {
+ return GetDescription ();
+ }
+ }
+
+ static string GetDescription ()
+ {
+ return GettextCatalog.GetString ("Version: {0}", GetNuGetVersion ());
+ }
+
+ static Version GetNuGetVersion ()
+ {
+ return typeof(NuGetProject).Assembly.GetName ().Version;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IOpenPackageReadMeMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs index d7ca135f49..c206ec9714 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/IOpenPackageReadMeMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/NullDisposable.cs @@ -1,36 +1,38 @@ -//
-// IOpenPackageReadMeMonitor.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
-{
- internal interface IOpenPackageReadMeMonitor : IDisposable
- {
- void OpenReadMeFile ();
- }
-}
-
+// +// NullDisposable.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 +{ + class NullDisposable : IDisposable + { + public void Dispose () + { + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenDotNetProjects.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenDotNetProjects.cs deleted file mode 100644 index 1faa3b74a9..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenDotNetProjects.cs +++ /dev/null @@ -1,66 +0,0 @@ -//
-// OpenDotNetProjects.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using MonoDevelop.Projects;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class OpenDotNetProjects
- {
- IPackageManagementProjectService projectService;
-
- public OpenDotNetProjects (IPackageManagementProjectService projectService)
- {
- this.projectService = projectService;
- }
-
- public IDotNetProject FindProject (string name)
- {
- foreach (IProject project in projectService.GetOpenProjects ()) {
- if (IsProjectNameMatch (project, name)) {
- return project as IDotNetProject;
- }
- }
- return null;
- }
-
- bool IsProjectNameMatch (IProject project, string name)
- {
- return IsMatchIgnoringCase (project.Name, name) ||
- (project.FileName == name);
- }
-
- bool IsMatchIgnoringCase (string a, string b)
- {
- return String.Equals (a, b, StringComparison.OrdinalIgnoreCase);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs deleted file mode 100644 index a88d721192..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/OpenPackageReadmeMonitor.cs +++ /dev/null @@ -1,99 +0,0 @@ -//
-// OpenPackageReadMeMonitor.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;
-using System.IO;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class OpenPackageReadMeMonitor : IOpenPackageReadMeMonitor
- {
- IPackageManagementProject project;
- IPackageManagementFileService fileService;
-
- public OpenPackageReadMeMonitor (
- string packageId,
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- : this (packageId, project, new PackageManagementFileService (packageManagementEvents))
- {
- }
-
- public OpenPackageReadMeMonitor (
- string packageId,
- IPackageManagementProject project,
- IPackageManagementFileService fileService)
- {
- PackageId = packageId;
- this.project = project;
- this.fileService = fileService;
- project.PackageInstalled += PackageInstalled;
- }
-
- public string PackageId { get; private set; }
-
- public bool IsDisposed { get; private set; }
-
- string ReadMeFile { get; set; }
-
- public void Dispose ()
- {
- if (IsDisposed) {
- return;
- }
-
- IsDisposed = true;
- project.PackageInstalled -= PackageInstalled;
- }
-
- void PackageInstalled (object sender, PackageOperationEventArgs e)
- {
- if (e.Package.Id != PackageId) {
- return;
- }
-
- ReadMeFile = FindReadMeFileInPackage (e.InstallPath, e.Package);
- }
-
- string FindReadMeFileInPackage (string installPath, IPackage package)
- {
- return package.GetFiles ()
- .Where (file => "readme.txt".Equals (file.Path, StringComparison.OrdinalIgnoreCase))
- .Select (file => Path.Combine (installPath, file.Path))
- .FirstOrDefault ();
- }
-
- public void OpenReadMeFile ()
- {
- if ((ReadMeFile != null) && fileService.FileExists (ReadMeFile)) {
- fileService.OpenFile (ReadMeFile);
- }
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageActionRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageActionRunner.cs deleted file mode 100644 index d7f9fec845..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageActionRunner.cs +++ /dev/null @@ -1,85 +0,0 @@ -//
-// PackageActionRunner.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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.Collections.Generic;
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageActionRunner : IPackageActionRunner
- {
- IPackageManagementEvents packageManagementEvents;
-
- public PackageActionRunner(IPackageManagementEvents packageManagementEvents)
- {
- this.packageManagementEvents = packageManagementEvents;
- }
-
- public void Run(IEnumerable<IPackageAction> actions)
- {
- if (ShouldRunActionsInConsole(actions)) {
- ReportScriptsWillNotBeRun();
- }
-
- foreach (IPackageAction action in actions) {
- action.Execute();
- }
- }
-
- bool ShouldRunActionsInConsole(IEnumerable<IPackageAction> actions)
- {
- foreach (ProcessPackageAction action in actions) {
- if (ShouldRunActionInConsole(action)) {
- return true;
- }
- }
- return false;
- }
-
- public void Run(IPackageAction action)
- {
- if (ShouldRunActionInConsole(action)) {
- ReportScriptsWillNotBeRun();
- }
-
- action.Execute();
- }
-
- bool ShouldRunActionInConsole(IPackageAction action)
- {
- return action.HasPackageScriptsToRun();
- }
-
- void ReportScriptsWillNotBeRun()
- {
- string message = GettextCatalog.GetString ("PowerShell scripts will not be run.");
- packageManagementEvents.OnPackageOperationMessageLogged(MessageLevel.Warning, message);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs index 38ae89ad1e..d34d38abb6 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityChecker.cs @@ -29,8 +29,6 @@ using System.Collections.Generic; using System.IO;
using System.Linq;
using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
using NuGet;
using MonoDevelop.Core; @@ -38,19 +36,20 @@ namespace MonoDevelop.PackageManagement {
internal class PackageCompatibilityChecker
{
- IPackageManagementSolution solution;
- IRegisteredPackageRepositories registeredRepositories;
+ ISolutionPackageRepository packageRepository;
List<IPackage> packagesRequiringReinstallation = new List<IPackage> ();
PackageReferenceFile packageReferenceFile;
List<PackageReference> packageReferences;
- ProjectPackagesCompatibilityReport compatibilityReport;
+ ProjectPackagesCompatibilityReport compatibilityReport; - public PackageCompatibilityChecker (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredRepositories)
- {
- this.solution = solution;
- this.registeredRepositories = registeredRepositories;
+ public PackageCompatibilityChecker (ISolution solution) + : this (new SolutionPackageRepository (solution)) + { + } + + public PackageCompatibilityChecker (ISolutionPackageRepository packageRepository) + { + this.packageRepository = packageRepository; }
public string PackageReferenceFileName {
@@ -59,15 +58,14 @@ namespace MonoDevelop.PackageManagement public void CheckProjectPackages (IDotNetProject project)
{
- IPackageManagementProject packageManagementProject = solution.GetProject (registeredRepositories.ActiveRepository, project);
-
packageReferenceFile = CreatePackageReferenceFile (project.GetPackagesConfigFilePath ());
packageReferences = packageReferenceFile.GetPackageReferences ().ToList ();
-
- compatibilityReport = new ProjectPackagesCompatibilityReport (packageManagementProject.TargetFramework);
+ + var targetFramework = new ProjectTargetFramework (project);
+ compatibilityReport = new ProjectPackagesCompatibilityReport (targetFramework.TargetFrameworkName);
foreach (PackageReference packageReference in packageReferences) {
- IPackage package = packageManagementProject.FindPackage (packageReference.Id);
+ IPackage package = packageRepository.Repository.FindPackage (packageReference.Id);
if (package != null) {
if (PackageNeedsReinstall (project, package, packageReference.TargetFramework)) {
packagesRequiringReinstallation.Add (package);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityHandler.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityHandler.cs index f01886e712..33fb937119 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityHandler.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityHandler.cs @@ -39,7 +39,7 @@ namespace MonoDevelop.PackageManagement void ProjectTargetFrameworkChanged (object sender, ProjectTargetFrameworkChangedEventArgs e)
{
- if (e.Project.HasPackages ()) {
+ if (e.Project.HasPackagesConfig ()) {
var runner = new PackageCompatibilityRunner (e.Project);
runner.Run ();
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityRunner.cs index 90ed0fe71e..bd106e3dfe 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityRunner.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageCompatibilityRunner.cs @@ -25,50 +25,33 @@ // THE SOFTWARE.
using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using NuGet;
namespace MonoDevelop.PackageManagement
{
internal class PackageCompatibilityRunner
{
IDotNetProject project;
- IPackageManagementSolution solution;
- IRegisteredPackageRepositories registeredRepositories;
IPackageManagementProgressMonitorFactory progressMonitorFactory;
ProgressMonitorStatusMessage progressMessage;
ProgressMonitor progressMonitor;
IPackageManagementEvents packageManagementEvents;
- IProgressProvider progressProvider;
public PackageCompatibilityRunner (
IDotNetProject project,
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredRepositories,
IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ IPackageManagementEvents packageManagementEvents)
{
this.project = project;
- this.solution = solution;
- this.registeredRepositories = registeredRepositories;
this.progressMonitorFactory = progressMonitorFactory;
this.packageManagementEvents = packageManagementEvents;
- this.progressProvider = progressProvider;
}
public PackageCompatibilityRunner (IDotNetProject project)
: this (
project,
- PackageManagementServices.Solution,
- PackageManagementServices.RegisteredPackageRepositories,
PackageManagementServices.ProgressMonitorFactory,
- PackageManagementServices.PackageManagementEvents,
- PackageManagementServices.ProgressProvider)
+ PackageManagementServices.PackageManagementEvents)
{
}
@@ -109,20 +92,19 @@ namespace MonoDevelop.PackageManagement PackageManagementEventsMonitor CreateEventMonitor (ProgressMonitor monitor)
{
- return CreateEventMonitor (monitor, packageManagementEvents, progressProvider);
+ return CreateEventMonitor (monitor, packageManagementEvents);
}
protected virtual PackageManagementEventsMonitor CreateEventMonitor (
ProgressMonitor monitor,
- IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ IPackageManagementEvents packageManagementEvents)
{
- return new PackageManagementEventsMonitor (monitor, packageManagementEvents, progressProvider);
+ return new PackageManagementEventsMonitor (monitor, packageManagementEvents);
}
void CheckCompatibility ()
{
- PackageCompatibilityChecker checker = CreatePackageCompatibilityChecker (solution, registeredRepositories);
+ PackageCompatibilityChecker checker = CreatePackageCompatibilityChecker (project.ParentSolution);
checker.CheckProjectPackages (project);
if (checker.AnyPackagesRequireReinstallation ()) {
@@ -136,9 +118,9 @@ namespace MonoDevelop.PackageManagement }
}
- protected virtual PackageCompatibilityChecker CreatePackageCompatibilityChecker (IPackageManagementSolution solution, IRegisteredPackageRepositories registeredRepositories)
+ protected virtual PackageCompatibilityChecker CreatePackageCompatibilityChecker (ISolution solution)
{
- return new PackageCompatibilityChecker (solution, registeredRepositories);
+ return new PackageCompatibilityChecker (solution);
}
void MarkPackagesForReinstallation (PackageCompatibilityChecker checker)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFiles.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFiles.cs deleted file mode 100644 index c809d8585e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFiles.cs +++ /dev/null @@ -1,108 +0,0 @@ -//
-// PackageFiles.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageFiles
- {
- IEnumerable<IPackageFile> files;
-
- public PackageFiles(IPackage package)
- : this(package.GetFiles())
- {
- }
-
- public PackageFiles(IEnumerable<IPackageFile> files)
- {
- this.files = files;
- }
-
- public bool HasAnyPackageScripts()
- {
- foreach (string fileName in GetFileNames()) {
- if (IsPackageScriptFile(fileName)) {
- return true;
- }
- }
- return false;
- }
-
- IEnumerable<string> GetFileNames()
- {
- foreach (IPackageFile file in files) {
- string fileName = Path.GetFileName(file.Path);
- yield return fileName;
- }
- }
-
- public bool HasUninstallPackageScript()
- {
- foreach (string fileName in GetFileNames()) {
- if (IsPackageUninstallScriptFile(fileName)) {
- return true;
- }
- }
- return false;
- }
-
- bool IsPackageScriptFile(string fileName)
- {
- return
- IsPackageInitializationScriptFile(fileName) ||
- IsPackageInstallScriptFile(fileName) ||
- IsPackageUninstallScriptFile(fileName);
- }
-
- bool IsPackageInitializationScriptFile(string fileName)
- {
- return IsCaseInsensitiveMatch(fileName, "init.ps1");
- }
-
- bool IsPackageInstallScriptFile(string fileName)
- {
- return IsCaseInsensitiveMatch(fileName, "install.ps1");
- }
-
- bool IsPackageUninstallScriptFile(string fileName)
- {
- return IsCaseInsensitiveMatch(fileName, "uninstall.ps1");
- }
-
- bool IsCaseInsensitiveMatch(string a, string b)
- {
- return String.Equals(a, b, StringComparison.InvariantCultureIgnoreCase);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFilesForOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFilesForOperations.cs deleted file mode 100644 index d8d8f9ec7c..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFilesForOperations.cs +++ /dev/null @@ -1,61 +0,0 @@ -//
-// PackageFilesForOperations.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageFilesForOperations
- {
- IEnumerable<PackageOperation> operations;
-
- public PackageFilesForOperations(IEnumerable<PackageOperation> operations)
- {
- this.operations = operations;
- }
-
- public bool HasAnyPackageScripts()
- {
- foreach (PackageFiles files in GetPackageFilesForEachOperation()) {
- if (files.HasAnyPackageScripts()) {
- return true;
- }
- }
- return false;
- }
-
- IEnumerable<PackageFiles> GetPackageFilesForEachOperation()
- {
- foreach (PackageOperation operation in operations) {
- yield return new PackageFiles(operation.Package);
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFromRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFromRepository.cs deleted file mode 100644 index c5b6ec36f5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageFromRepository.cs +++ /dev/null @@ -1,240 +0,0 @@ -//
-// PackageFromRepository.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.IO;
-using System.Runtime.Versioning;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageFromRepository : IPackageFromRepository
- {
- IPackage package;
- bool? hasDependencies;
-
- public PackageFromRepository(IPackage package, IPackageRepository repository)
- {
- this.package = package;
- this.Repository = repository;
- }
-
- public IPackageRepository Repository { get; private set; }
-
- public IEnumerable<IPackageAssemblyReference> AssemblyReferences {
- get { return package.AssemblyReferences; }
- }
-
- public string Id {
- get { return package.Id; }
- }
-
- public SemanticVersion Version {
- get { return package.Version; }
- }
-
- public string Title {
- get { return package.Title; }
- }
-
- public IEnumerable<string> Authors {
- get { return package.Authors; }
- }
-
- public IEnumerable<string> Owners {
- get { return package.Owners; }
- }
-
- public Uri IconUrl {
- get { return package.IconUrl; }
- }
-
- public Uri LicenseUrl {
- get { return package.LicenseUrl; }
- }
-
- public Uri ProjectUrl {
- get { return package.ProjectUrl;}
- }
-
- public bool RequireLicenseAcceptance {
- get { return package.RequireLicenseAcceptance; }
- }
-
- public string Description {
- get { return package.Description; }
- }
-
- public string Summary {
- get { return package.Summary; }
- }
-
- public string Language {
- get { return package.Language; }
- }
-
- public string Tags {
- get { return package.Tags; }
- }
-
- public IEnumerable<FrameworkAssemblyReference> FrameworkAssemblies {
- get { return package.FrameworkAssemblies; }
- }
-
- public IEnumerable<PackageDependency> Dependencies {
- get { return package.GetCompatiblePackageDependencies(null); }
- }
-
- public Uri ReportAbuseUrl {
- get { return package.ReportAbuseUrl; }
- }
-
- public int DownloadCount {
- get { return package.DownloadCount; }
- }
-
- public DateTime? LastUpdated {
- get { return GetLastUpdated(); }
- }
-
- DateTime? GetLastUpdated()
- {
- DateTimeOffset? lastUpdated = GetDataServicePackageLastUpdated();
- if (lastUpdated.HasValue) {
- return lastUpdated.Value.DateTime;
- }
- return null;
- }
-
- protected virtual DateTimeOffset? GetDataServicePackageLastUpdated()
- {
- var dataServicePackage = package as DataServicePackage;
- if (dataServicePackage != null) {
- return dataServicePackage.LastUpdated;
- }
- return null;
- }
-
- public IEnumerable<IPackageFile> GetFiles()
- {
- return package.GetFiles();
- }
-
- public Stream GetStream()
- {
- return package.GetStream();
- }
-
- public bool HasDependencies {
- get {
- if (!hasDependencies.HasValue) {
- IEnumerator<PackageDependency> enumerator = Dependencies.GetEnumerator();
- hasDependencies = enumerator.MoveNext();
- }
- return hasDependencies.Value;
- }
- }
-
- public bool IsLatestVersion {
- get { return package.IsLatestVersion; }
- }
-
- public Nullable<DateTimeOffset> Published {
- get { return package.Published; }
- }
-
- public string ReleaseNotes {
- get { return package.ReleaseNotes; }
- }
-
- public string Copyright {
- get { return package.Copyright; }
- }
-
- public bool IsAbsoluteLatestVersion {
- get { return package.IsAbsoluteLatestVersion; }
- }
-
- public bool Listed {
- get { return package.Listed; }
- }
-
- public IEnumerable<PackageDependencySet> DependencySets {
- get { return package.DependencySets; }
- }
-
- public IEnumerable<FrameworkName> GetSupportedFrameworks()
- {
- return package.GetSupportedFrameworks();
- }
-
- public override string ToString()
- {
- return package.ToString();
- }
-
- public ICollection<PackageReferenceSet> PackageAssemblyReferences {
- get { return package.PackageAssemblyReferences; }
- }
-
- public Version MinClientVersion {
- get { return package.MinClientVersion; }
- }
-
- public Uri GalleryUrl {
- get {
- var dataServicePackage = package as DataServicePackage;
- if (dataServicePackage != null) {
- return dataServicePackage.GalleryDetailsUrl;
- }
- return null;
- }
- }
-
- public bool DevelopmentDependency {
- get { return package.DevelopmentDependency; }
- }
-
- public bool IsValid {
- get {
- var zipPackage = package as OptimizedZipPackage;
- if (zipPackage != null) {
- return zipPackage.IsValid;
- }
- return true;
- }
- }
-
- public void ExtractContents (IFileSystem fileSystem, string extractPath)
- {
- package.ExtractContents (fileSystem, extractPath);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageLicenseViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageLicenseViewModel.cs index 81bc2c340c..ef14ef2354 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageLicenseViewModel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageLicenseViewModel.cs @@ -27,49 +27,28 @@ //
using System;
-using System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.Core;
-using NuGet;
namespace MonoDevelop.PackageManagement
{
internal class PackageLicenseViewModel : ViewModelBase<PackageLicenseViewModel>
{
- IPackage package;
+ NuGetPackageLicense packageLicense;
- public PackageLicenseViewModel(IPackage package)
+ public PackageLicenseViewModel (NuGetPackageLicense packageLicense)
{
- this.package = package;
+ this.packageLicense = packageLicense;
}
public string Id {
- get { return package.Id; }
- }
-
- public string Summary {
- get { return package.SummaryOrDescription(); }
+ get { return packageLicense.PackageId; }
}
public Uri LicenseUrl {
- get { return package.LicenseUrl; }
+ get { return packageLicense.LicenseUrl; }
}
- internal string GetAuthors ()
- {
- List<string> authors = package.Authors.ToList ();
-
- string authorStartText = null;
- if (authors.Count > 1) {
- authorStartText = GettextCatalog.GetString ("Authors:");
- } else {
- authorStartText = GettextCatalog.GetString ("Author:");
- }
-
- return String.Format (
- "{0} {1}",
- authorStartText,
- String.Join (", ", authors));
+ public string Author {
+ get { return packageLicense.PackageAuthor; }
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementCompilerMessageView.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementCompilerMessageView.cs deleted file mode 100644 index 0cc26c372f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementCompilerMessageView.cs +++ /dev/null @@ -1,51 +0,0 @@ -//
-// PackageManagementCompilerMessageView.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal class PackageManagementCompilerMessageView : ICompilerMessageView
- {
- public IMessageViewCategory Create(string categoryName, string categoryDisplayName)
- {
-// MessageViewCategory view = null;
-// MessageViewCategory.Create(ref view, categoryName, categoryDisplayName);
- return new PackageManagementMessageViewCategory();
- }
-
- public IMessageViewCategory GetExisting(string categoryName)
- {
-// MessageViewCategory view = CompilerMessageView.Instance.GetCategory(categoryName);
-// if (view != null) {
- return new PackageManagementMessageViewCategory();
-// }
-// return null;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementCredentialService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementCredentialService.cs new file mode 100644 index 0000000000..c5ae2eff3c --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementCredentialService.cs @@ -0,0 +1,93 @@ +// +// PackageManagementCredentialService.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc. (http://xamarin.com) +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// +// 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 System.Collections.Generic; +using MonoDevelop.Core; +using NuGet.Credentials; + +namespace MonoDevelop.PackageManagement +{ + internal class PackageManagementCredentialService + { + public void Initialize () + { + try { + InitializeDefaultCredentialProvider (); + } catch (Exception ex) { + LoggingService.LogError ("Failed to initialize PackageManagementCredentialService.", ex); + } + } + + void InitializeDefaultCredentialProvider () + { + var credentialService = new CredentialService ( + GetCredentialProviders (), + OnError, + nonInteractive: false); + + NuGet.HttpClient.DefaultCredentialProvider = new CredentialServiceAdapter (credentialService); + + HttpHandlerResourceV3Extensions.InitializeHttpHandlerResourceV3 (credentialService); + } + + void OnError (string message) + { + PackageManagementServices.PackageManagementEvents.OnPackageOperationMessageLogged (NuGet.MessageLevel.Error, message); + } + + IEnumerable<ICredentialProvider> GetCredentialProviders () + { + var credentialProviders = new List<ICredentialProvider>(); + + var adapter = new CredentialProviderAdapter (CreateSettingsCredentialProvider ()); + credentialProviders.Add (adapter); + credentialProviders.Add (new MonoDevelopCredentialProvider ()); + + return credentialProviders; + } + + static NuGet.SettingsCredentialProvider CreateSettingsCredentialProvider () + { + NuGet.ISettings settings = LoadSettings (); + var packageSourceProvider = new NuGet.PackageSourceProvider (settings); + return new NuGet.SettingsCredentialProvider (NuGet.NullCredentialProvider.Instance, packageSourceProvider); + } + + static NuGet.ISettings LoadSettings () + { + try { + return NuGet.Settings.LoadDefaultSettings (null, null, null); + } catch (Exception ex) { + LoggingService.LogError ("Unable to load NuGet.Config.", ex); + } + return NuGet.NullSettings.Instance; + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEnumerableExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEnumerableExtensions.cs deleted file mode 100644 index 302eca8e84..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEnumerableExtensions.cs +++ /dev/null @@ -1,55 +0,0 @@ -//
-// PackageManagementEnumerableExtensions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal static class PackageManagementEnumerableExtensions
- {
- public static IEnumerable<TSource> DistinctLast<TSource>(this IEnumerable<TSource> source, IEqualityComparer<TSource> comparer)
- {
- TSource previousItem = default(TSource);
-
- foreach (TSource currentItem in source) {
- if (previousItem != null) {
- if (!comparer.Equals(previousItem, currentItem)) {
- yield return previousItem;
- }
- }
- previousItem = currentItem;
- }
-
- if (previousItem != null) {
- yield return previousItem;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReferenceFile.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventArgs.cs index 1b6d6352de..8ce59a1cf7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectPackageReferenceFile.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventArgs.cs @@ -1,10 +1,10 @@ //
-// ProjectPackageReferenceFile.cs
+// PackageManagementEventArgs.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -25,39 +25,49 @@ // THE SOFTWARE.
using System;
-using System.Linq;
-using MonoDevelop.Projects;
-using NuGet;
-using MonoDevelop.PackageManagement;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+using NuGet.Versioning;
namespace MonoDevelop.PackageManagement
{
- internal class ProjectPackageReferenceFile : PackageReferenceFile
+ internal class PackageManagementEventArgs : EventArgs
{
- public ProjectPackageReferenceFile (DotNetProject project)
- : base(project.GetPackagesConfigFilePath ())
+ public PackageManagementEventArgs (
+ IDotNetProject project,
+ PackageEventArgs e)
+ : this (project, e.Identity, e.InstallPath)
+ {
+ PackageFilePath = GetPackageFilePath (e);
+ }
+
+ public PackageManagementEventArgs (
+ IDotNetProject project,
+ PackageIdentity package,
+ string installPath)
{
Project = project;
+ Package = package;
+ InstallPath = installPath;
}
- public DotNetProject Project { get; private set; }
+ public IDotNetProject Project { get; private set; }
+ public PackageIdentity Package { get; private set; }
+ public string InstallPath { get; private set; }
+ public string PackageFilePath { get; private set; }
- public bool AnyMissingPackages ()
- {
- var packagesPath = new SolutionPackageRepositoryPath (Project);
- var fileSystem = new PhysicalFileSystem (packagesPath.PackageRepositoryPath);
- foreach (PackageReference packageReference in GetPackageReferences ()) {
- if (!packageReference.IsPackageInstalled (fileSystem)) {
- return true;
- }
- }
- return false;
+ public string Id {
+ get { return Package.Id; }
+ }
+
+ public NuGetVersion Version {
+ get { return Package.Version; }
}
- public bool AnyPackagesToBeReinstalled ()
+ static string GetPackageFilePath (PackageEventArgs e)
{
- return GetPackageReferences ()
- .Any (packageReference => packageReference.RequireReinstallation);
+ var folderNuGetProject = e.Project as FolderNuGetProject;
+ return folderNuGetProject?.GetInstalledPackageFilePath (e.Identity);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs index f060f0f8ab..8a38a5bbdb 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEvents.cs @@ -27,11 +27,9 @@ //
using System;
-using System.Collections.Generic;
using MonoDevelop.Core;
-using NuGet;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Projects;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -64,46 +62,9 @@ namespace MonoDevelop.PackageManagement }
}
- public event EventHandler<AcceptLicensesEventArgs> AcceptLicenses;
-
- public bool OnAcceptLicenses(IEnumerable<IPackage> packages)
- {
- if (AcceptLicenses != null) {
- var eventArgs = new AcceptLicensesEventArgs(packages);
- AcceptLicenses(this, eventArgs);
- return eventArgs.IsAccepted;
- }
- return true;
- }
-
- public event EventHandler<ParentPackageOperationEventArgs> ParentPackageInstalled;
-
- public void OnParentPackageInstalled(IPackage package, IPackageManagementProject project)
- {
- if (ParentPackageInstalled != null) {
- ParentPackageInstalled(this, new ParentPackageOperationEventArgs(package, project));
- }
- }
-
- public void OnParentPackageInstalled (IPackage package, IPackageManagementProject project, IEnumerable<PackageOperation> operations)
- {
- if (ParentPackageInstalled != null) {
- ParentPackageInstalled (this, new ParentPackageOperationEventArgs(package, project, operations));
- }
- }
-
- public event EventHandler<ParentPackageOperationEventArgs> ParentPackageUninstalled;
-
- public void OnParentPackageUninstalled(IPackage package, IPackageManagementProject project)
- {
- if (ParentPackageUninstalled != null) {
- ParentPackageUninstalled(this, new ParentPackageOperationEventArgs(package, project));
- }
- }
-
public event EventHandler<PackageOperationMessageLoggedEventArgs> PackageOperationMessageLogged;
- public void OnPackageOperationMessageLogged(MessageLevel level, string message, params object[] args)
+ public void OnPackageOperationMessageLogged(NuGet.MessageLevel level, string message, params object[] args)
{
if (PackageOperationMessageLogged != null) {
var eventArgs = new PackageOperationMessageLoggedEventArgs(level, message, args);
@@ -111,37 +72,16 @@ namespace MonoDevelop.PackageManagement }
}
- public event EventHandler<SelectProjectsEventArgs> SelectProjects;
-
- public bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> projects)
- {
- if (SelectProjects != null) {
- var eventArgs = new SelectProjectsEventArgs(projects);
- SelectProjects(this, eventArgs);
- return eventArgs.IsAccepted;
- }
- return true;
- }
-
public event EventHandler<ResolveFileConflictEventArgs> ResolveFileConflict;
- public FileConflictResolution OnResolveFileConflict(string message)
+ public FileConflictAction OnResolveFileConflict(string message)
{
if (ResolveFileConflict != null) {
var eventArgs = new ResolveFileConflictEventArgs(message);
ResolveFileConflict(this, eventArgs);
return eventArgs.Resolution;
}
- return FileConflictResolution.IgnoreAll;
- }
-
- public event EventHandler<ParentPackagesOperationEventArgs> ParentPackagesUpdated;
-
- public void OnParentPackagesUpdated(IEnumerable<IPackage> packages)
- {
- if (ParentPackagesUpdated != null) {
- ParentPackagesUpdated(this, new ParentPackagesOperationEventArgs(packages));
- }
+ return FileConflictAction.IgnoreAll;
}
public event EventHandler PackagesRestored;
@@ -183,15 +123,6 @@ namespace MonoDevelop.PackageManagement return true;
}
- public event EventHandler<PackageRestoredEventArgs> PackageRestored;
-
- public void OnPackageRestored (IPackage package)
- {
- if (PackageRestored != null) {
- PackageRestored (this, new PackageRestoredEventArgs (package));
- }
- }
-
public event EventHandler<DotNetProjectReferenceEventArgs> ReferenceRemoving;
public void OnReferenceRemoving (ProjectReference reference)
@@ -218,5 +149,33 @@ namespace MonoDevelop.PackageManagement ImportRemoved (this, new DotNetProjectImportEventArgs (project, import));
}
}
+
+ public event EventHandler<PackageManagementEventArgs> PackageInstalled;
+
+ public void OnPackageInstalled (IDotNetProject project, NuGet.ProjectManagement.PackageEventArgs e)
+ {
+ PackageInstalled?.Invoke (this, new PackageManagementEventArgs (project, e));
+ }
+
+ public event EventHandler<PackageManagementEventArgs> PackageUninstalling;
+
+ public void OnPackageUninstalling (IDotNetProject project, NuGet.ProjectManagement.PackageEventArgs e)
+ {
+ PackageUninstalling?.Invoke (this, new PackageManagementEventArgs (project, e));
+ }
+
+ public event EventHandler<PackageManagementEventArgs> PackageUninstalled;
+
+ public void OnPackageUninstalled (IDotNetProject project, NuGet.ProjectManagement.PackageEventArgs e)
+ {
+ PackageUninstalled?.Invoke (this, new PackageManagementEventArgs (project, e));
+ }
+
+ public event EventHandler<DotNetProjectEventArgs> NoUpdateFound;
+
+ public void OnNoUpdateFound (IDotNetProject project)
+ {
+ NoUpdateFound?.Invoke (this, new DotNetProjectEventArgs (project));
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs index 4676b26668..5df1ac77db 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementEventsMonitor.cs @@ -27,11 +27,10 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using MonoDevelop.PackageManagement;
+using System.Threading.Tasks;
using MonoDevelop.Core;
-using MonoDevelop.Ide;
using NuGet;
-using MonoDevelop.Ide.TypeSystem;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -39,45 +38,43 @@ namespace MonoDevelop.PackageManagement {
ProgressMonitor progressMonitor;
IPackageManagementEvents packageManagementEvents;
- IProgressProvider progressProvider;
- FileConflictResolution lastFileConflictResolution;
+ FileConflictAction lastFileConflictResolution;
IFileConflictResolver fileConflictResolver = new FileConflictResolver ();
- string currentProgressOperation;
List<FileEventArgs> fileChangedEvents = new List<FileEventArgs> ();
- List<IPackageManagementProject> projectsRequiringTypeSystemRefresh = new List<IPackageManagementProject> ();
ISolution solutionContainingProjectBuildersToDispose;
+ TaskCompletionSource<bool> taskCompletionSource;
+
+ public PackageManagementEventsMonitor (
+ ProgressMonitor progressMonitor,
+ IPackageManagementEvents packageManagementEvents)
+ : this (progressMonitor, packageManagementEvents, null)
+ {
+ }
public PackageManagementEventsMonitor (
ProgressMonitor progressMonitor,
IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
+ TaskCompletionSource<bool> taskCompletionSource)
{
this.progressMonitor = progressMonitor;
this.packageManagementEvents = packageManagementEvents;
- this.progressProvider = progressProvider;
+ this.taskCompletionSource = taskCompletionSource;
packageManagementEvents.PackageOperationMessageLogged += PackageOperationMessageLogged;
packageManagementEvents.ResolveFileConflict += ResolveFileConflict;
- packageManagementEvents.AcceptLicenses += AcceptLicenses;
packageManagementEvents.FileChanged += FileChanged;
- packageManagementEvents.ParentPackageInstalled += PackageInstalled;
packageManagementEvents.ImportRemoved += ImportRemoved;
- progressProvider.ProgressAvailable += ProgressAvailable;
}
public void Dispose ()
{
- progressProvider.ProgressAvailable -= ProgressAvailable;
packageManagementEvents.ImportRemoved -= ImportRemoved;
- packageManagementEvents.ParentPackageInstalled -= PackageInstalled;
packageManagementEvents.FileChanged -= FileChanged;
- packageManagementEvents.AcceptLicenses -= AcceptLicenses;
packageManagementEvents.ResolveFileConflict -= ResolveFileConflict;
packageManagementEvents.PackageOperationMessageLogged -= PackageOperationMessageLogged;
NotifyFilesChanged ();
UnloadMSBuildHost ();
- RefreshTypeSystem ();
}
void ResolveFileConflict(object sender, ResolveFileConflictEventArgs e)
@@ -95,8 +92,8 @@ namespace MonoDevelop.PackageManagement bool UserPreviouslySelectedOverwriteAllOrIgnoreAll()
{
return
- (lastFileConflictResolution == FileConflictResolution.IgnoreAll) ||
- (lastFileConflictResolution == FileConflictResolution.OverwriteAll);
+ (lastFileConflictResolution == FileConflictAction.IgnoreAll) ||
+ (lastFileConflictResolution == FileConflictAction.OverwriteAll);
}
protected virtual void GuiSyncDispatch (Action action)
@@ -106,7 +103,7 @@ namespace MonoDevelop.PackageManagement void PackageOperationMessageLogged (object sender, PackageOperationMessageLoggedEventArgs e)
{
- if (e.Message.Level == MessageLevel.Warning) {
+ if (e.Message.Level == NuGet.MessageLevel.Warning) {
ReportWarning (e.Message.ToString ());
} else {
LogMessage (e.Message.ToString ());
@@ -135,37 +132,10 @@ namespace MonoDevelop.PackageManagement } else {
progressMonitor.ReportSuccess (progressMessage.Success);
}
- }
- void AcceptLicenses (object sender, AcceptLicensesEventArgs e)
- {
- foreach (IPackage package in e.Packages) {
- ReportLicenseAgreementWarning (package);
+ if (taskCompletionSource != null) {
+ taskCompletionSource.TrySetResult (true);
}
- e.IsAccepted = true;
- }
-
- void ReportLicenseAgreementWarning (IPackage package)
- {
- string message = GettextCatalog.GetString (
- "The {0} package has a license agreement which is available at {1}{2}" +
- "Please review this license agreement and remove the package if you do not accept the agreement.{2}" +
- "Check the package for additional dependencies which may also have license agreements.{2}" +
- "Using this package and any dependencies constitutes your acceptance of these license agreements.",
- package.Id,
- package.LicenseUrl,
- Environment.NewLine);
-
- ReportWarning (message);
- }
-
- void ProgressAvailable (object sender, ProgressEventArgs e)
- {
- if (currentProgressOperation == e.Operation)
- return;
-
- currentProgressOperation = e.Operation;
- progressMonitor.Log.WriteLine (e.Operation);
}
void FileChanged (object sender, FileEventArgs e)
@@ -193,49 +163,29 @@ namespace MonoDevelop.PackageManagement public void ReportError (ProgressMonitorStatusMessage progressMessage, Exception ex)
{
LoggingService.LogError (progressMessage.Error, ex);
- progressMonitor.Log.WriteLine (ex.Message);
+ progressMonitor.Log.WriteLine (GetErrorMessageForPackageConsole (ex));
progressMonitor.ReportError (progressMessage.Error, null);
ShowPackageConsole (progressMonitor);
packageManagementEvents.OnPackageOperationError (ex);
- }
-
- protected virtual void ShowPackageConsole (ProgressMonitor progressMonitor)
- {
- progressMonitor.ShowPackageConsole ();
- }
- void RefreshTypeSystem ()
- {
- foreach (IPackageManagementProject project in projectsRequiringTypeSystemRefresh) {
- ReconnectAssemblyReferences (project);
+ if (taskCompletionSource != null) {
+ taskCompletionSource.TrySetException (ExceptionUtility.Unwrap (ex));
}
}
- protected virtual void ReconnectAssemblyReferences (IPackageManagementProject project)
+ static string GetErrorMessageForPackageConsole (Exception ex)
{
- // TODO : Roslyn port ?
-// var projectWrapper = TypeSystemService.GetProjectContentWrapper (project.DotNetProject);
-// if (projectWrapper != null) {
-// projectWrapper.ReconnectAssemblyReferences ();
-// }
- }
-
- void PackageInstalled (object sender, ParentPackageOperationEventArgs e)
- {
- if (ShouldRefreshTypeSystemForProject (e)) {
- projectsRequiringTypeSystemRefresh.Add (e.Project);
+ var aggregateEx = ex as AggregateException;
+ if (aggregateEx != null) {
+ var message = new AggregateExceptionErrorMessage (aggregateEx);
+ return message.ToString ();
}
+ return ex.Message;
}
- bool ShouldRefreshTypeSystemForProject (ParentPackageOperationEventArgs e)
- {
- return e.Operations.Any (operation => IsInstallingMSBuildFiles (operation));
- }
-
- bool IsInstallingMSBuildFiles (PackageOperation operation)
+ protected virtual void ShowPackageConsole (ProgressMonitor progressMonitor)
{
- return (operation.Action == PackageAction.Install) &&
- operation.Package.GetBuildFiles ().Any ();
+ progressMonitor.ShowPackageConsole ();
}
void ImportRemoved (object sender, DotNetProjectImportEventArgs e)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementInstrumentationService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementInstrumentationService.cs new file mode 100644 index 0000000000..1af72ffa6f --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementInstrumentationService.cs @@ -0,0 +1,90 @@ +// +// PackageManagementInstrumentationService.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using MonoDevelop.Core; +using MonoDevelop.Core.Instrumentation; +using NuGet; +using NuGet.PackageManagement; +using NuGet.Packaging.Core; + +namespace MonoDevelop.PackageManagement +{ + internal class PackageManagementInstrumentationService + { + static Counter InstallPackageCounter = InstrumentationService.CreateCounter ("Package Installed", "Package Management", id: "PackageManagement.Package.Installed"); + static Counter UninstallPackageCounter = InstrumentationService.CreateCounter ("Package Uninstalled", "Package Management", id: "PackageManagement.Package.Uninstalled"); + + public virtual void IncrementInstallPackageCounter (IDictionary<string, string> metadata) + { + InstallPackageCounter.Inc (1, null, metadata); + } + + public virtual void IncrementUninstallPackageCounter (IDictionary<string, string> metadata) + { + UninstallPackageCounter.Inc (1, null, metadata); + } + + public void InstrumentPackageAction (IPackageAction action) + { + try { + var provider = action as INuGetProjectActionsProvider; + if (provider != null) { + InstrumentPackageActions (provider.GetNuGetProjectActions ()); + } + } catch (Exception ex) { + LoggingService.LogError ("Instrumentation Failure in PackageManagement", ex); + } + } + + void InstrumentPackageActions (IEnumerable<NuGetProjectAction> actions) + { + foreach (NuGetProjectAction action in actions) { + var metadata = new Dictionary<string, string> (); + metadata["PackageId"] = action.PackageIdentity.Id; + if (action.PackageIdentity.HasVersion) { + metadata["Package"] = GetFullPackageInfo (action.PackageIdentity); + } + + switch (action.NuGetProjectActionType) { + case NuGetProjectActionType.Install: + IncrementInstallPackageCounter (metadata); + break; + case NuGetProjectActionType.Uninstall: + IncrementUninstallPackageCounter (metadata); + break; + } + } + } + + static string GetFullPackageInfo (PackageIdentity packageIdentity) + { + return string.Format ("{0} v{1}", packageIdentity.Id, packageIdentity.Version); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementLogger.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementLogger.cs index 688188d843..198f2d591d 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementLogger.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementLogger.cs @@ -26,12 +26,11 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
using NuGet;
namespace MonoDevelop.PackageManagement
{
- internal class PackageManagementLogger : ILogger
+ internal class PackageManagementLogger : NuGet.ILogger, NuGet.Logging.ILogger
{
IPackageManagementEvents packageManagementEvents;
@@ -47,7 +46,42 @@ namespace MonoDevelop.PackageManagement public FileConflictResolution ResolveFileConflict(string message)
{
- return packageManagementEvents.OnResolveFileConflict(message);
+ return FileConflictResolution.Ignore;
+ }
+
+ public void LogDebug (string data)
+ {
+ Log (MessageLevel.Debug, data);
+ }
+
+ public void LogError (string data)
+ {
+ Log (MessageLevel.Error, data);
+ }
+
+ public void LogInformation (string data)
+ {
+ Log (MessageLevel.Info, data);
+ }
+
+ public void LogVerbose (string data)
+ {
+ Log (MessageLevel.Debug, data);
+ }
+
+ public void LogWarning (string data)
+ {
+ Log (MessageLevel.Warning, data);
+ }
+
+ public void LogMinimal (string data)
+ {
+ LogInformation (data);
+ }
+
+ public void LogSummary (string data)
+ {
+ LogDebug (data);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMSBuildExtension.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMSBuildExtension.cs index 2d7ea6dca8..aa8ae6b427 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMSBuildExtension.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMSBuildExtension.cs @@ -35,6 +35,7 @@ namespace MonoDevelop.PackageManagement {
public static EnsureNuGetPackageBuildImportsTargetUpdater Updater;
public static NuGetPackageNewImportsHandler NewImportsHandler;
+ public static NuGetPackageForcedImportsRemover ForcedImportsRemover;
protected override void OnWriteProject (ProgressMonitor monitor, MSBuildProject msproject)
{
@@ -44,6 +45,11 @@ namespace MonoDevelop.PackageManagement public void UpdateProject (MSBuildProject msproject)
{
+ NuGetPackageForcedImportsRemover importsRemover = ForcedImportsRemover;
+ if (importsRemover != null) {
+ importsRemover.UpdateProject (msproject);
+ }
+
EnsureNuGetPackageBuildImportsTargetUpdater currentUpdater = Updater;
if (currentUpdater != null) {
currentUpdater.UpdateProject (msproject);
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMessageViewCategory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMessageViewCategory.cs deleted file mode 100644 index 8665006a0d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementMessageViewCategory.cs +++ /dev/null @@ -1,52 +0,0 @@ -//
-// PackageManagementMessageViewCategory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal 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();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptions.cs index 6965afb94a..8490e7f721 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptions.cs @@ -26,51 +26,26 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-
using MonoDevelop.Core;
-using MonoDevelop.PackageManagement;
-using NuGet;
namespace MonoDevelop.PackageManagement
{
internal class PackageManagementOptions
{
- const string PackageDirectoryPropertyName = "PackagesDirectory";
- const string RecentPackagesPropertyName = "RecentPackages";
const string AutomaticPackageRestoreOnOpeningSolutionPropertyName = "AutomaticPackageRestoreOnOpeningSolution";
const string CheckUpdatedPackagesOnOpeningSolutionPropertyName = "CheckUpdatedPackagesOnOpeningSolution";
- RegisteredPackageSourceSettings registeredPackageSourceSettings;
Properties properties;
- List<RecentPackageInfo> recentPackages;
- PackageRestoreConsent packageRestoreConsent;
-
- public PackageManagementOptions (
- Properties properties,
- ISettingsProvider settingsProvider)
- {
- this.properties = properties;
- registeredPackageSourceSettings = new RegisteredPackageSourceSettings (settingsProvider);
- packageRestoreConsent = new PackageRestoreConsent (settingsProvider.LoadSettings());
- }
public PackageManagementOptions (Properties properties)
- : this (properties, new SettingsProvider ())
{
+ this.properties = properties;
}
public PackageManagementOptions()
: this(PropertyService.Get("PackageManagementSettings", new Properties()))
{
}
-
- public bool IsPackageRestoreEnabled {
- get { return packageRestoreConsent.IsGrantedInSettings; }
- set { packageRestoreConsent.IsGrantedInSettings = value; }
- }
public bool IsAutomaticPackageRestoreOnOpeningSolutionEnabled {
get { return properties.Get(AutomaticPackageRestoreOnOpeningSolutionPropertyName, true); }
@@ -81,39 +56,5 @@ namespace MonoDevelop.PackageManagement get { return properties.Get(CheckUpdatedPackagesOnOpeningSolutionPropertyName, true); }
set { properties.Set(CheckUpdatedPackagesOnOpeningSolutionPropertyName, value); }
}
-
- public RegisteredPackageSources PackageSources {
- get { return registeredPackageSourceSettings.PackageSources; }
- }
-
- public string PackagesDirectory {
- get { return properties.Get(PackageDirectoryPropertyName, "packages"); }
- set { properties.Set(PackageDirectoryPropertyName, value); }
- }
-
- public PackageSource ActivePackageSource {
- get { return registeredPackageSourceSettings.ActivePackageSource; }
- set { registeredPackageSourceSettings.ActivePackageSource = value; }
- }
-
- public IList<RecentPackageInfo> RecentPackages {
- get {
- if (recentPackages == null) {
- ReadRecentPackages();
- }
- return recentPackages;
- }
- }
-
- void ReadRecentPackages()
- {
- var defaultRecentPackages = new List<RecentPackageInfo>();
- recentPackages = properties.Get<List<RecentPackageInfo>>(RecentPackagesPropertyName, defaultRecentPackages);
- }
-
- public string GetCustomPackagesDirectory ()
- {
- return registeredPackageSourceSettings.Settings.GetRepositoryPath ();
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptionsViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptionsViewModel.cs index 125fd06ca8..3315f69ee5 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptionsViewModel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOptionsViewModel.cs @@ -26,90 +26,27 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using System.Linq;
-
namespace MonoDevelop.PackageManagement
{
internal class PackageManagementOptionsViewModel : ViewModelBase<PackageManagementOptionsViewModel>
{
PackageManagementOptions options;
- IRecentPackageRepository recentPackageRepository;
- IMachinePackageCache machinePackageCache;
- IProcess process;
-
- public PackageManagementOptionsViewModel(IRecentPackageRepository recentPackageRepository)
- : this(PackageManagementServices.Options, recentPackageRepository, new MachinePackageCache(), new Process())
+
+ public PackageManagementOptionsViewModel ()
+ : this (PackageManagementServices.Options)
{
}
-
- public PackageManagementOptionsViewModel(
- PackageManagementOptions options,
- IRecentPackageRepository recentPackageRepository,
- IMachinePackageCache machinePackageCache,
- IProcess process)
+
+ public PackageManagementOptionsViewModel (PackageManagementOptions options)
{
this.options = options;
- this.recentPackageRepository = recentPackageRepository;
- this.machinePackageCache = machinePackageCache;
- this.process = process;
-
- this.HasNoRecentPackages = !RecentPackageRepositoryHasPackages();
- this.HasNoCachedPackages = !MachinePackageCacheHasPackages();
this.IsAutomaticPackageRestoreOnOpeningSolutionEnabled = options.IsAutomaticPackageRestoreOnOpeningSolutionEnabled;
this.IsCheckForPackageUpdatesOnOpeningSolutionEnabled = options.IsCheckForPackageUpdatesOnOpeningSolutionEnabled;
-
- CreateCommands();
}
-
- public bool HasNoRecentPackages { get; private set; }
- public bool HasNoCachedPackages { get; private set; }
+
public bool IsAutomaticPackageRestoreOnOpeningSolutionEnabled { get; set; }
public bool IsCheckForPackageUpdatesOnOpeningSolutionEnabled { get; set; }
-
- bool MachinePackageCacheHasPackages()
- {
- return machinePackageCache.GetPackages().Any();
- }
-
- bool RecentPackageRepositoryHasPackages()
- {
- return recentPackageRepository.HasRecentPackages;
- }
-
- void CreateCommands()
- {
- ClearRecentPackagesCommand =
- new DelegateCommand(param => ClearRecentPackages(), param => !HasNoRecentPackages);
- ClearCachedPackagesCommand =
- new DelegateCommand(param => ClearCachedPackages(), param => !HasNoCachedPackages);
- BrowseCachedPackagesCommand =
- new DelegateCommand(param => BrowseCachedPackages(), param => !HasNoCachedPackages);
- }
-
- public ICommand ClearRecentPackagesCommand { get; private set; }
- public ICommand ClearCachedPackagesCommand { get; private set; }
- public ICommand BrowseCachedPackagesCommand { get; private set; }
-
- public void ClearRecentPackages()
- {
- recentPackageRepository.Clear();
- HasNoRecentPackages = true;
- OnPropertyChanged(viewModel => viewModel.HasNoRecentPackages);
- }
-
- public void ClearCachedPackages()
- {
- machinePackageCache.Clear();
- HasNoCachedPackages = true;
- OnPropertyChanged(viewModel => viewModel.HasNoCachedPackages);
- }
-
- public void BrowseCachedPackages()
- {
- process.Start(machinePackageCache.Source);
- }
-
+
public void SaveOptions()
{
options.IsAutomaticPackageRestoreOnOpeningSolutionEnabled = IsAutomaticPackageRestoreOnOpeningSolutionEnabled;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOutputMessagesView.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOutputMessagesView.cs deleted file mode 100644 index 9a8be1795d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementOutputMessagesView.cs +++ /dev/null @@ -1,77 +0,0 @@ -//
-// PackageManagementOutputMessagesView.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementOutputMessagesView : IPackageManagementOutputMessagesView
- {
- public static readonly string CategoryName = "PackageManagement";
-
- IMessageViewCategory messageViewCategory;
-
- public PackageManagementOutputMessagesView(IPackageManagementEvents packageManagementEvents)
- : this(new PackageManagementCompilerMessageView(), packageManagementEvents)
- {
- }
-
- public PackageManagementOutputMessagesView(
- ICompilerMessageView compilerMessageView,
- IPackageManagementEvents packageManagementEvents)
- {
- CreatePackageManagementMessageCategoryIfNoneExists(compilerMessageView);
- packageManagementEvents.PackageOperationMessageLogged += PackageOperationMessageLogged;
- }
-
- void CreatePackageManagementMessageCategoryIfNoneExists(ICompilerMessageView compilerMessageView)
- {
- messageViewCategory = compilerMessageView.GetExisting(CategoryName);
- if (messageViewCategory == null) {
- CreatePackageManagementMessageCategory(compilerMessageView);
- }
- }
-
- void CreatePackageManagementMessageCategory(ICompilerMessageView compilerMessageView)
- {
- messageViewCategory = compilerMessageView.Create(CategoryName, "Packages");
- }
-
- void PackageOperationMessageLogged(object sender, PackageOperationMessageLoggedEventArgs e)
- {
- string formattedMessage = e.Message.ToString();
- messageViewCategory.AppendLine(formattedMessage);
- }
-
- public void Clear()
- {
- messageViewCategory.Clear();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReference.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReference.cs index 08cd591c28..f4a9d04b21 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReference.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReference.cs @@ -24,8 +24,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-
namespace MonoDevelop.PackageManagement
{
public class PackageManagementPackageReference
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReferenceExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReferenceExtensions.cs new file mode 100644 index 0000000000..88d966fb2c --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPackageReferenceExtensions.cs @@ -0,0 +1,43 @@ +//
+// PackageManagementPackageReferenceExtensions.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 NuGet.Versioning;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal static class PackageManagementPackageReferenceExtensions
+ {
+ public static NuGetVersion GetNuGetVersion (this PackageManagementPackageReference packageReference)
+ {
+ if (!String.IsNullOrEmpty (packageReference.Version)) {
+ return new NuGetVersion (packageReference.Version);
+ }
+ return null;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitor.cs index 1bda3c5992..4e684e5b41 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitor.cs @@ -24,14 +24,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
-using System.IO;
using System.Linq;
using MonoDevelop.Core;
using MonoDevelop.Core.Execution;
using System.Threading;
-using MonoDevelop.Core.ProgressMonitoring;
namespace MonoDevelop.PackageManagement
{
@@ -117,6 +114,7 @@ namespace MonoDevelop.PackageManagement void OnCancelRequested ()
{
+ consoleMonitor.Log.WriteLine (GettextCatalog.GetString ("Cancelling operation..."));
CancellationTokenSource.Cancel ();
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitorFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitorFactory.cs index 4289e0278d..7df7d0a250 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitorFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressMonitorFactory.cs @@ -47,7 +47,8 @@ namespace MonoDevelop.PackageManagement false,
false,
false,
- pad);
+ pad,
+ true);
return new PackageManagementProgressMonitor (consoleMonitor, statusMonitor);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs deleted file mode 100644 index ce0833db17..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProgressProvider.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -// PackageManagementProgressProvider.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 MonoDevelop.PackageManagement;
-using NuGet;
-using MonoDevelop.Ide;
-using MonoDevelop.Core; - -namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementProgressProvider : IProgressProvider
- {
- Action<Action> guiDispatcher;
-
- public PackageManagementProgressProvider (IPackageRepositoryFactoryEvents repositoryFactoryEvents)
- : this (repositoryFactoryEvents, h => Runtime.RunInMainThread (h))
- {
- }
-
- public PackageManagementProgressProvider (
- IPackageRepositoryFactoryEvents repositoryFactoryEvents,
- Action<Action> guiDispatcher)
- {
- repositoryFactoryEvents.RepositoryCreated += RepositoryCreated;
- this.guiDispatcher = guiDispatcher;
- }
-
- void RepositoryCreated (object sender, PackageRepositoryFactoryEventArgs e)
- {
- var progressProvider = e.Repository as IProgressProvider;
- if (progressProvider != null) {
- progressProvider.ProgressAvailable += OnProgressAvailable;
- }
- }
-
- public event EventHandler<ProgressEventArgs> ProgressAvailable;
-
- void OnProgressAvailable (object sender, ProgressEventArgs e)
- {
- guiDispatcher (() => {
- if (ProgressAvailable != null) {
- ProgressAvailable (sender, e);
- }
- });
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProject.cs deleted file mode 100644 index 4b5c6c8eeb..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProject.cs +++ /dev/null @@ -1,267 +0,0 @@ -//
-// PackageManagementProject.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012-2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-
-using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementProject : IPackageManagementProject
- {
- IMonoDevelopPackageManager packageManager;
- IMonoDevelopProjectManager projectManager;
- IPackageManagementEvents packageManagementEvents;
- IDotNetProject project;
- ProjectTargetFramework targetFramework;
-
- public PackageManagementProject (
- IPackageRepository sourceRepository,
- IDotNetProject project,
- IPackageManagementEvents packageManagementEvents,
- IPackageManagerFactory packageManagerFactory)
- {
- SourceRepository = sourceRepository;
- this.project = project;
- this.packageManagementEvents = packageManagementEvents;
-
- packageManager = packageManagerFactory.CreatePackageManager (sourceRepository, project);
- projectManager = packageManager.ProjectManager;
- }
-
- public string Name {
- get { return project.Name; }
- }
-
- public DotNetProject DotNetProject {
- get { return project.DotNetProject; }
- }
-
- public IDotNetProject Project {
- get { return project; }
- }
-
- public FrameworkName TargetFramework {
- get { return GetTargetFramework(); }
- }
-
- FrameworkName GetTargetFramework()
- {
- if (targetFramework == null) {
- targetFramework = new ProjectTargetFramework(project);
- }
- return targetFramework.TargetFrameworkName;
- }
-
- public IPackageRepository SourceRepository { get; private set; }
-
- public ILogger Logger {
- get { return packageManager.Logger; }
- set {
- packageManager.Logger = value;
- packageManager.FileSystem.Logger = value;
-
- projectManager.Logger = value;
- projectManager.Project.Logger = value;
-
- ConfigureLoggerForSourceRepository ();
- }
- }
-
- void ConfigureLoggerForSourceRepository ()
- {
- var aggregateRepository = SourceRepository as AggregateRepository;
- if (aggregateRepository != null) {
- aggregateRepository.Logger = Logger;
- }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageInstalled {
- add { packageManager.PackageInstalled += value; }
- remove { packageManager.PackageInstalled -= value; }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageUninstalled {
- add { packageManager.PackageUninstalled += value; }
- remove { packageManager.PackageUninstalled -= value; }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageReferenceAdded {
- add { projectManager.PackageReferenceAdded += value; }
- remove { projectManager.PackageReferenceAdded -= value; }
- }
-
- public event EventHandler<PackageOperationEventArgs> PackageReferenceRemoved {
- add { projectManager.PackageReferenceRemoved += value; }
- remove { projectManager.PackageReferenceRemoved -= value; }
- }
-
- public bool IsPackageInstalled(IPackage package)
- {
- return projectManager.IsInstalled(package);
- }
-
- public bool IsPackageInstalled(string packageId)
- {
- return projectManager.IsInstalled(packageId);
- }
-
- public IQueryable<IPackage> GetPackages()
- {
- return projectManager.LocalRepository.GetPackages();
- }
-
- public IEnumerable<PackageOperation> GetInstallPackageOperations(IPackage package, InstallPackageAction installAction)
- {
- return packageManager.GetInstallPackageOperations(package, installAction);
- }
-
- public void InstallPackage(IPackage package, InstallPackageAction installAction)
- {
- packageManager.InstallPackage(package, installAction);
- }
-
- public void UninstallPackage(IPackage package, UninstallPackageAction uninstallAction)
- {
- packageManager.UninstallPackage(package, uninstallAction);
- }
-
- public void UpdatePackage(IPackage package, UpdatePackageAction updateAction)
- {
- packageManager.UpdatePackage(package, updateAction);
- }
-
- public InstallPackageAction CreateInstallPackageAction()
- {
- return new InstallPackageAction(this, packageManagementEvents);
- }
-
- public UninstallPackageAction CreateUninstallPackageAction()
- {
- return new UninstallPackageAction(this, packageManagementEvents);
- }
-
- public UpdatePackageAction CreateUpdatePackageAction()
- {
- return new UpdatePackageAction(this, packageManagementEvents);
- }
-
- public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder()
- {
- var packageSorter = new PackageSorter(null);
- return packageSorter
- .GetPackagesByDependencyOrder(projectManager.LocalRepository)
- .Reverse();
- }
-
- public void UpdatePackages(UpdatePackagesAction updateAction)
- {
- packageManager.UpdatePackages(updateAction);
- }
-
- public UpdatePackagesAction CreateUpdatePackagesAction()
- {
- return new UpdatePackagesAction(this, packageManagementEvents);
- }
-
- public ReinstallPackageAction CreateReinstallPackageAction ()
- {
- return new ReinstallPackageAction (this, packageManagementEvents);
- }
-
- public IEnumerable<PackageOperation> GetUpdatePackagesOperations(
- IEnumerable<IPackage> packages,
- IUpdatePackageSettings settings)
- {
- return packageManager.GetUpdatePackageOperations(packages, settings);
- }
-
- public ReinstallPackageOperations GetReinstallPackageOperations (IEnumerable<IPackage> packages)
- {
- return packageManager.GetReinstallPackageOperations (packages);
- }
-
- public void RunPackageOperations(IEnumerable<PackageOperation> operations)
- {
- packageManager.RunPackageOperations(operations);
- }
-
- public bool HasOlderPackageInstalled(IPackage package)
- {
- return projectManager.HasOlderPackageInstalled(package);
- }
-
- public void UpdatePackageReference(IPackage package, IUpdatePackageSettings settings)
- {
- packageManager.UpdatePackageReference(package, settings);
- }
-
- public void AddPackageReference (IPackage package)
- {
- bool allowPrerelease = !package.IsReleaseVersion ();
- bool ignoreDependencies = true;
- packageManager.AddPackageReference (package, ignoreDependencies, allowPrerelease);
- }
-
- public IPackage FindPackage(string packageId)
- {
- return projectManager.LocalRepository.FindPackage (packageId);
- }
-
- public IEnumerable<PackageReference> GetPackageReferences ()
- {
- return projectManager.GetPackageReferences ();
- }
-
- public bool AnyUnrestoredPackages ()
- {
- return GetPackageReferences ()
- .Any (packageReference => !IsPackageInstalled (packageReference));
- }
-
- bool IsPackageInstalled (PackageReference packageReference)
- {
- return projectManager.LocalRepository.Exists (packageReference.Id, packageReference.Version);
- }
-
- public IPackageConstraintProvider ConstraintProvider {
- get {
- var constraintProvider = projectManager.LocalRepository as IPackageConstraintProvider;
- if (constraintProvider != null) {
- return constraintProvider;
- }
- return NullConstraintProvider.Instance;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectFactory.cs deleted file mode 100644 index 94d4efbd09..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectFactory.cs +++ /dev/null @@ -1,52 +0,0 @@ -//
-// PackageManagementProjectFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementProjectFactory : IPackageManagementProjectFactory
- {
- MonoDevelopPackageManagerFactory factory = new MonoDevelopPackageManagerFactory();
- IPackageManagementEvents packageManagementEvents;
-
- public PackageManagementProjectFactory(IPackageManagementEvents packageManagementEvents)
- {
- this.packageManagementEvents = packageManagementEvents;
- }
-
- public IPackageManagementProject CreateProject (
- IPackageRepository sourceRepository,
- IDotNetProject project)
- {
- return new PackageManagementProject (sourceRepository, project, packageManagementEvents, factory);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs index 9f418a756b..34f0187f6b 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectOperations.cs @@ -1,96 +1,150 @@ -// -// PackageManagementProjectOperations.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
-using MonoDevelop.Projects;
-using NuGet;
+//
+// PackageManagementProjectOperations.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 System.Collections.Generic; +using System.Linq; +using System.Threading;
+using System.Threading.Tasks;
using MonoDevelop.Core; +using MonoDevelop.Projects; +using NuGet.Configuration; +using NuGet.PackageManagement;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+using NuGet.Versioning; namespace MonoDevelop.PackageManagement
{
internal class PackageManagementProjectOperations : IPackageManagementProjectOperations
{
- IPackageManagementSolution solution;
- IRegisteredPackageRepositories registeredPackageRepositories;
BackgroundPackageActionRunner backgroundActionRunner;
public PackageManagementProjectOperations (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
BackgroundPackageActionRunner backgroundActionRunner,
IPackageManagementEvents packageManagementEvents)
{
- this.solution = solution;
- this.registeredPackageRepositories = registeredPackageRepositories;
this.backgroundActionRunner = backgroundActionRunner;
- packageManagementEvents.ParentPackageInstalled += PackageInstalled;
- packageManagementEvents.ParentPackageUninstalled += PackageUninstalled;
+ packageManagementEvents.PackageInstalled += PackageInstalled;
+ packageManagementEvents.PackageUninstalled += PackageUninstalled;
}
public event EventHandler<PackageManagementPackageReferenceEventArgs> PackageReferenceAdded;
public event EventHandler<PackageManagementPackageReferenceEventArgs> PackageReferenceRemoved;
+ + public void InstallPackages ( + string packageSourceUrl, + Project project, + IEnumerable<PackageManagementPackageReference> packages) + { + InstallPackages (packageSourceUrl, project, packages, licensesAccepted: false); + } public void InstallPackages (
string packageSourceUrl,
Project project,
+ IEnumerable<PackageManagementPackageReference> packages, + bool licensesAccepted)
+ {
+ var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider ();
+ var repository = repositoryProvider.CreateRepository (new PackageSource (packageSourceUrl));
+
+ InstallPackages (new [] { repository }, project, packages, licensesAccepted);
+ }
+
+ public void InstallPackages (
+ Project project,
IEnumerable<PackageManagementPackageReference> packages)
{
- List<IPackageAction> actions = null;
+ var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider ();
+ var repositories = repositoryProvider.GetRepositories ().ToList ();
+ InstallPackages (repositories, project, packages, licensesAccepted: false);
+ }
+
+ void InstallPackages (
+ IEnumerable<SourceRepository> repositories,
+ Project project,
+ IEnumerable<PackageManagementPackageReference> packages,
+ bool licensesAccepted)
+ {
+ var actions = CreateInstallActions (repositories, project, packages, licensesAccepted).ToList ();
+ ProgressMonitorStatusMessage progressMessage = GetProgressMonitorStatusMessages (actions);
+ backgroundActionRunner.Run (progressMessage, actions);
+ }
+
+ IEnumerable<INuGetPackageAction> CreateInstallActions (
+ IEnumerable<SourceRepository> repositories,
+ Project project,
+ IEnumerable<PackageManagementPackageReference> packages,
+ bool licensesAccepted)
+ {
+ List<INuGetPackageAction> actions = null;
Runtime.RunInMainThread (() => {
- IPackageRepository repository = CreatePackageRepository (packageSourceUrl);
- IPackageManagementProject packageManagementProject = solution.GetProject (repository, new DotNetProjectProxy ((DotNetProject)project));
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution);
+ var dotNetProject = new DotNetProjectProxy ((DotNetProject)project);
+ var context = new NuGetProjectContext ();
+
actions = packages.Select (packageReference => {
- InstallPackageAction action = packageManagementProject.CreateInstallPackageAction ();
+ var action = new InstallNuGetPackageAction (
+ repositories,
+ solutionManager,
+ dotNetProject,
+ context);
action.PackageId = packageReference.Id;
- action.PackageVersion = new SemanticVersion (packageReference.Version); - action.LicensesMustBeAccepted = false;
- return (IPackageAction)action;
+ action.Version = packageReference.GetNuGetVersion ();
+ action.LicensesMustBeAccepted = !licensesAccepted;
+ return (INuGetPackageAction)action;
}).ToList ();
}).Wait ();
- ProgressMonitorStatusMessage progressMessage = GetProgressMonitorStatusMessages (actions);
- backgroundActionRunner.Run (progressMessage, actions);
+ return actions;
}
-
- IPackageRepository CreatePackageRepository (string packageSourceUrl)
+ + public Task InstallPackagesAsync (
+ string packageSourceUrl,
+ Project project,
+ IEnumerable<PackageManagementPackageReference> packages)
{
- IPackageRepository repository = registeredPackageRepositories.CreateRepository (new PackageSource (packageSourceUrl));
- return new PriorityPackageRepository (MachineCache.Default, repository);
+ var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider ();
+ var repository = repositoryProvider.CreateRepository (new PackageSource (packageSourceUrl));
+ var repositories = new [] { repository };
+
+ var actions = CreateInstallActions (repositories, project, packages, licensesAccepted: false).ToList ();
+
+ ProgressMonitorStatusMessage progressMessage = GetProgressMonitorStatusMessages (actions);
+ return backgroundActionRunner.RunAsync (progressMessage, actions);
}
- ProgressMonitorStatusMessage GetProgressMonitorStatusMessages (List<IPackageAction> packageActions)
+ ProgressMonitorStatusMessage GetProgressMonitorStatusMessages (List<INuGetPackageAction> packageActions)
{
if (packageActions.Count == 1) {
- string packageId = packageActions.OfType<ProcessPackageAction> ().First ().PackageId;
+ string packageId = packageActions.OfType<INuGetPackageAction> ().First ().PackageId;
return ProgressMonitorStatusMessageFactory.CreateInstallingSinglePackageMessage (packageId);
}
return ProgressMonitorStatusMessageFactory.CreateInstallingMultiplePackagesMessage (packageActions.Count);
@@ -98,48 +152,94 @@ namespace MonoDevelop.PackageManagement public IEnumerable<PackageManagementPackageReference> GetInstalledPackages (Project project)
{
- return Runtime.RunInMainThread (() => {
- string url = RegisteredPackageSources.DefaultPackageSourceUrl;
- var repository = registeredPackageRepositories.CreateRepository (new PackageSource (url));
- IPackageManagementProject packageManagementProject = solution.GetProject (repository, new DotNetProjectProxy ((DotNetProject)project));
- - var packages = packageManagementProject
- .GetPackageReferences ()
- .Select (packageReference => new PackageManagementPackageReference (packageReference.Id, packageReference.Version.ToString ()))
- .ToList (); + try {
+ return Runtime.RunInMainThread (async () => {
+ if (!IsValidProject (project)) {
+ return Enumerable.Empty<PackageManagementPackageReference> ();
+ }
+
+ var dotNetProject = (DotNetProject)project;
+ var nugetProject = CreateNuGetProject (dotNetProject);
+
+ var packagesBeingInstalled = GetPackagesBeingInstalled (dotNetProject).ToList ();
+
+ var packages = await Task.Run (() => nugetProject.GetInstalledPackagesAsync (CancellationToken.None)).ConfigureAwait (false);
+
+ var packageReferences = packages
+ .Select (package => CreatePackageReference (package.PackageIdentity))
+ .ToList ();
+
+ packageReferences.AddRange (GetMissingPackagesBeingInstalled (packageReferences, packagesBeingInstalled));
+
+ return packageReferences;
+ }).Result;
+ } catch (Exception ex) {
+ LoggingService.LogError ("GetInstalledPackages error.", ex);
+ throw ExceptionUtility.Unwrap (ex);
+ }
+ }
+
+ static bool IsValidProject (Project project)
+ {
+ return project is DotNetProject &&
+ !String.IsNullOrEmpty (project.Name);
+ }
- packages.AddRange (GetMissingPackagesBeingInstalled (packages, (DotNetProject)project)); - return packages;
- }).Result;
- } + NuGetProject CreateNuGetProject (DotNetProject project)
+ {
+ if (project.ParentSolution != null) {
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (project.ParentSolution);
+ return solutionManager.GetNuGetProject (new DotNetProjectProxy (project));
+ }
+
+ return new MonoDevelopNuGetProjectFactory ().CreateNuGetProject (project);
+ }
IEnumerable<PackageManagementPackageReference> GetMissingPackagesBeingInstalled ( IEnumerable<PackageManagementPackageReference> existingPackages, - DotNetProject project) + IEnumerable<PackageManagementPackageReference> packagesBeingInstalled) { - return GetPackagesBeingInstalled (project) + return packagesBeingInstalled .Where (package => !existingPackages.Any (existingPackage => existingPackage.Id == package.Id)); } static IEnumerable<PackageManagementPackageReference> GetPackagesBeingInstalled (DotNetProject project) { return PackageManagementServices.BackgroundPackageActionRunner.PendingInstallActionsForProject (project) - .Select (installAction => new PackageManagementPackageReference ( - installAction.GetPackageId (), - installAction.GetPackageVersion ().ToString ())); + .Select (installAction => CreatePackageReference (installAction)); + }
+
+ static PackageManagementPackageReference CreatePackageReference (PackageIdentity package)
+ {
+ return new PackageManagementPackageReference (package.Id, package.Version.ToString ());
}
- void PackageUninstalled (object sender, ParentPackageOperationEventArgs e)
+ static PackageManagementPackageReference CreatePackageReference (IInstallNuGetPackageAction installAction)
+ {
+ return new PackageManagementPackageReference (
+ installAction.PackageId,
+ GetNuGetVersionString (installAction.Version));
+ }
+
+ static string GetNuGetVersionString (NuGetVersion version)
+ {
+ if (version != null)
+ return version.ToString ();
+
+ return null;
+ }
+ + void PackageUninstalled (object sender, PackageManagementEventArgs e)
{
OnPackageReferencedRemoved (e);
}
- void PackageInstalled (object sender, ParentPackageOperationEventArgs e)
+ void PackageInstalled (object sender, PackageManagementEventArgs e)
{
OnPackageReferenceAdded (e);
}
- void OnPackageReferencedRemoved (ParentPackageOperationEventArgs e)
+ void OnPackageReferencedRemoved (PackageManagementEventArgs e)
{
var handler = PackageReferenceRemoved;
if (handler != null) {
@@ -147,7 +247,7 @@ namespace MonoDevelop.PackageManagement }
}
- void OnPackageReferenceAdded (ParentPackageOperationEventArgs e)
+ void OnPackageReferenceAdded (PackageManagementEventArgs e)
{
var handler = PackageReferenceAdded;
if (handler != null) {
@@ -155,7 +255,7 @@ namespace MonoDevelop.PackageManagement }
}
- PackageManagementPackageReferenceEventArgs CreateEventArgs (ParentPackageOperationEventArgs e)
+ PackageManagementPackageReferenceEventArgs CreateEventArgs (PackageManagementEventArgs e)
{
return new PackageManagementPackageReferenceEventArgs (
e.Project.DotNetProject,
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectService.cs index 27b1348402..10b2f2ec33 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementProjectService.cs @@ -93,11 +93,6 @@ namespace MonoDevelop.PackageManagement }
return new IDotNetProject [0];
}
-
- public IProjectBrowserUpdater CreateProjectBrowserUpdater()
- {
- return new ThreadSafeProjectBrowserUpdater();
- }
public string GetDefaultCustomToolForFileName(ProjectFile projectItem)
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPropertyService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPropertyService.cs deleted file mode 100644 index 4f29cd7248..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementPropertyService.cs +++ /dev/null @@ -1,44 +0,0 @@ -//
-// PackageManagementPropertyService.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementPropertyService : IPropertyService
- {
- public string DataDirectory {
- get { return UserProfile.Current.ConfigDir; }
- }
-
- public string ConfigDirectory {
- get { return UserProfile.Current.ConfigDir; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSelectedProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSelectedProject.cs deleted file mode 100644 index 4d0b7656ad..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSelectedProject.cs +++ /dev/null @@ -1,72 +0,0 @@ -//
-// PackageManagementSelectedProject.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal class PackageManagementSelectedProject : IPackageManagementSelectedProject
- {
- public PackageManagementSelectedProject(IPackageManagementProject project)
- : this(project, selected: false)
- {
- }
-
- public PackageManagementSelectedProject(
- IPackageManagementProject project,
- bool selected)
- : this(project, selected, enabled: true)
- {
- }
-
- public PackageManagementSelectedProject (
- IPackageManagementProject project,
- bool selected,
- bool enabled)
- : this (project.Name, selected, enabled)
- {
- this.Project = project;
- }
-
- public PackageManagementSelectedProject (
- string name,
- bool selected,
- bool enabled)
- {
- this.Name = name;
- this.IsSelected = selected;
- this.IsEnabled = enabled;
- }
-
- public IPackageManagementProject Project { get; private set; }
- public string Name { get; private set; }
-
- public bool IsSelected { get; set; }
- public bool IsEnabled { get; set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSelectedProjects.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSelectedProjects.cs deleted file mode 100644 index a99fcd5fd5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSelectedProjects.cs +++ /dev/null @@ -1,201 +0,0 @@ -//
-// PackageManagementSelectedProjects.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.Versioning;
-
-using MonoDevelop.Projects;
-using NuGet;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementSelectedProjects
- {
- bool? singleProjectSelected;
- IDotNetProject singleDotNetProjectSelected;
-
- public PackageManagementSelectedProjects(IPackageManagementSolution solution)
- {
- this.Solution = solution;
- GetHasSingleProjectSelected();
- }
-
- public IPackageManagementSolution Solution { get; private set; }
-
- public IEnumerable<IPackageManagementSelectedProject> GetProjects(IPackageFromRepository package)
- {
- if (HasSingleProjectSelected()) {
- yield return GetSingleProjectSelected(package);
- } else {
- foreach (IDotNetProject project in GetOpenProjects ()) {
- yield return CreateSelectedProject (project, package);
- }
- }
- }
-
- public bool HasSingleProjectSelected()
- {
- if (!singleProjectSelected.HasValue) {
- GetHasSingleProjectSelected();
- }
- return singleProjectSelected.Value;
- }
-
- void GetHasSingleProjectSelected()
- {
- singleDotNetProjectSelected = Solution.GetActiveDotNetProject();
- singleProjectSelected = singleDotNetProjectSelected != null;
- }
-
- IEnumerable<IDotNetProject> GetOpenProjects ()
- {
- return Solution.GetDotNetProjects();
- }
-
- IPackageManagementSelectedProject GetSingleProjectSelected(IPackageFromRepository package)
- {
- return CreateSelectedProject(singleDotNetProjectSelected, package);
- }
-
- IPackageManagementSelectedProject CreateSelectedProject(IDotNetProject dotNetProject, IPackageFromRepository package)
- {
- IPackageManagementProject project = Solution.GetProject(package.Repository, dotNetProject);
- return CreateSelectedProject(project, package);
- }
-
- IPackageManagementSelectedProject CreateSelectedProject(
- IPackageManagementProject project,
- IPackageFromRepository package)
- {
- bool enabled = IsProjectEnabled(project, package);
- bool selected = IsProjectSelected(project, package);
- return new PackageManagementSelectedProject(project, selected, enabled);
- }
-
- protected virtual bool IsProjectSelected(IPackageManagementProject project, IPackageFromRepository package)
- {
- return false;
- }
-
- protected virtual bool IsProjectEnabled(IPackageManagementProject project, IPackageFromRepository package)
- {
- return true;
- }
-
- public bool HasMultipleProjects()
- {
- if (HasSingleProjectSelected()) {
- return false;
- }
- return Solution.HasMultipleProjects();
- }
-
- public string SelectionName {
- get { return GetSelectionName(); }
- }
-
- string GetSelectionName()
- {
- if (HasSingleProjectSelected()) {
- return GetSingleProjectSelectedName();
- }
- return GetSolutionFileNameWithoutFullPath();
- }
-
- string GetSingleProjectSelectedName()
- {
- return singleDotNetProjectSelected.Name;
- }
-
- string GetSolutionFileNameWithoutFullPath()
- {
- return Path.GetFileName(Solution.FileName);
- }
-
- /// <summary>
- /// Returns true if the package is installed in the selected projects.
- /// </summary>
- public bool IsPackageInstalled(IPackageFromRepository package)
- {
- if (HasSingleProjectSelected()) {
- IPackageManagementProject project = GetSingleProjectSelected(package.Repository);
- return project.IsPackageInstalled(package);
- }
- return IsPackageInstalledInSolution(package);
- }
-
- public bool IsPackageInstalledInSolution(IPackage package)
- {
- return Solution.IsPackageInstalled(package);
- }
-
- public IQueryable<IPackage> GetPackagesInstalledInSolution()
- {
- return Solution.GetPackages();
- }
-
- public IQueryable<IPackage> GetInstalledPackages(IPackageRepository sourceRepository)
- {
- if (HasSingleProjectSelected()) {
- IPackageManagementProject project = GetSingleProjectSelected(sourceRepository);
- return project.GetPackages();
- }
- return GetPackagesInstalledInSolution();
- }
-
- public IPackageManagementProject GetSingleProjectSelected(IPackageRepository repository)
- {
- if (HasSingleProjectSelected()) {
- return Solution.GetProject(repository, singleDotNetProjectSelected);
- }
- return null;
- }
-
- public bool HasOlderPackageInstalled (IPackageFromRepository package)
- {
- if (HasSingleProjectSelected ()) {
- IPackageManagementProject project = GetSingleProjectSelected(package.Repository);
- return project.HasOlderPackageInstalled(package);
- }
- return false;
- }
-
- public FrameworkName GetTargetFramework ()
- {
- if (HasSingleProjectSelected ()) {
- return new ProjectTargetFramework (singleDotNetProjectSelected)
- .TargetFrameworkName;
- }
- return null;
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementServices.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementServices.cs index 80f1349706..8b8c89ac56 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementServices.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementServices.cs @@ -26,124 +26,65 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
-using NuGet;
-using MonoDevelop.Core;
-
namespace MonoDevelop.PackageManagement
{
public static class PackageManagementServices
{
static readonly PackageManagementOptions options;
- static readonly PackageManagementSolution solution;
- static readonly RegisteredPackageRepositories registeredPackageRepositories;
static readonly PackageManagementEvents packageManagementEvents = new PackageManagementEvents();
static readonly PackageManagementProjectService projectService = new PackageManagementProjectService();
- static readonly PackageManagementOutputMessagesView outputMessagesView;
- static readonly PackageActionRunner packageActionRunner;
- static readonly IPackageRepositoryCache projectTemplatePackageRepositoryCache;
- static readonly RegisteredProjectTemplatePackageSources projectTemplatePackageSources;
- static readonly PackageRepositoryCache packageRepositoryCache;
- static readonly UserAgentGeneratorForRepositoryRequests userAgentGenerator;
static readonly BackgroundPackageActionRunner backgroundPackageActionRunner;
static readonly IPackageManagementProgressMonitorFactory progressMonitorFactory;
- static readonly PackageManagementProgressProvider progressProvider;
static readonly ProjectTargetFrameworkMonitor projectTargetFrameworkMonitor;
static readonly PackageCompatibilityHandler packageCompatibilityHandler;
- static readonly UpdatedPackagesInSolution updatedPackagesInSolution;
+ static readonly UpdatedNuGetPackagesInWorkspace updatedPackagesInWorkspace;
static readonly PackageManagementProjectOperations projectOperations;
+ static readonly PackageManagementWorkspace workspace;
+ static readonly PackageManagementCredentialService credentialService;
+ static readonly AnalyzerPackageMonitor analyzerPackageMonitor;
+ static readonly MonoDevelopHttpUserAgent userAgent = new MonoDevelopHttpUserAgent ();
static PackageManagementServices()
{
options = new PackageManagementOptions();
- packageRepositoryCache = new PackageRepositoryCache (options);
- userAgentGenerator = new UserAgentGeneratorForRepositoryRequests ();
- userAgentGenerator.Register (packageRepositoryCache);
- progressProvider = new PackageManagementProgressProvider (packageRepositoryCache);
- registeredPackageRepositories = new RegisteredPackageRepositories(packageRepositoryCache, options);
- projectTemplatePackageSources = new RegisteredProjectTemplatePackageSources();
- projectTemplatePackageRepositoryCache = new ProjectTemplatePackageRepositoryCache(projectTemplatePackageSources);
-
- outputMessagesView = new PackageManagementOutputMessagesView(packageManagementEvents);
- solution = new PackageManagementSolution (registeredPackageRepositories, projectService, packageManagementEvents);
- packageActionRunner = new PackageActionRunner(packageManagementEvents);
progressMonitorFactory = new PackageManagementProgressMonitorFactory ();
- backgroundPackageActionRunner = new BackgroundPackageActionRunner (progressMonitorFactory, packageManagementEvents, progressProvider);
+ backgroundPackageActionRunner = new BackgroundPackageActionRunner (progressMonitorFactory, packageManagementEvents);
projectTargetFrameworkMonitor = new ProjectTargetFrameworkMonitor (projectService);
packageCompatibilityHandler = new PackageCompatibilityHandler ();
packageCompatibilityHandler.MonitorTargetFrameworkChanges (projectTargetFrameworkMonitor);
- updatedPackagesInSolution = new UpdatedPackagesInSolution (solution, registeredPackageRepositories, packageManagementEvents);
+ updatedPackagesInWorkspace = new UpdatedNuGetPackagesInWorkspace (packageManagementEvents);
+
+ projectOperations = new PackageManagementProjectOperations (backgroundPackageActionRunner, packageManagementEvents);
- projectOperations = new PackageManagementProjectOperations (solution, registeredPackageRepositories, backgroundPackageActionRunner, packageManagementEvents);
+ workspace = new PackageManagementWorkspace ();
+
+ credentialService = new PackageManagementCredentialService ();
+ credentialService.Initialize ();
- InitializeCredentialProvider();
PackageManagementBackgroundDispatcher.Initialize ();
- }
-
- internal static void InitializeCredentialProvider()
- {
- HttpClient.DefaultCredentialProvider = CreateSettingsCredentialProvider (new MonoDevelopCredentialProvider ());
- }
- static SettingsCredentialProvider CreateSettingsCredentialProvider (ICredentialProvider credentialProvider)
- {
- ISettings settings = LoadSettings ();
- var packageSourceProvider = new PackageSourceProvider (settings);
- return new SettingsCredentialProvider(credentialProvider, packageSourceProvider);
+ //analyzerPackageMonitor = new AnalyzerPackageMonitor ();
}
- static ISettings LoadSettings ()
+ internal static void InitializeCredentialService ()
{
- try {
- return Settings.LoadDefaultSettings (null, null, null);
- } catch (Exception ex) {
- LoggingService.LogError ("Unable to load NuGet.Config.", ex);
- }
- return NullSettings.Instance;
+ credentialService.Initialize ();
}
internal static PackageManagementOptions Options {
get { return options; }
}
- internal static IPackageManagementSolution Solution {
- get { return solution; }
- }
-
- internal static IRegisteredPackageRepositories RegisteredPackageRepositories {
- get { return registeredPackageRepositories; }
- }
-
- internal static IPackageRepositoryCache PackageRepositoryCache {
- get { return packageRepositoryCache; }
- }
-
internal static IPackageManagementEvents PackageManagementEvents {
get { return packageManagementEvents; }
}
- internal static IPackageManagementOutputMessagesView OutputMessagesView {
- get { return outputMessagesView; }
- }
-
internal static IPackageManagementProjectService ProjectService {
get { return projectService; }
}
-
- internal static IPackageActionRunner PackageActionRunner {
- get { return packageActionRunner; }
- }
-
- internal static IPackageRepositoryCache ProjectTemplatePackageRepositoryCache {
- get { return projectTemplatePackageRepositoryCache; }
- }
-
- internal static RegisteredPackageSources ProjectTemplatePackageSources {
- get { return projectTemplatePackageSources.PackageSources; }
- }
internal static IBackgroundPackageActionRunner BackgroundPackageActionRunner {
get { return backgroundPackageActionRunner; }
@@ -153,20 +94,16 @@ namespace MonoDevelop.PackageManagement get { return progressMonitorFactory; }
}
- internal static IRecentPackageRepository RecentPackageRepository {
- get { return packageRepositoryCache.RecentPackageRepository; }
- }
-
- internal static IProgressProvider ProgressProvider {
- get { return progressProvider; }
- }
-
- internal static IUpdatedPackagesInSolution UpdatedPackagesInSolution {
- get { return updatedPackagesInSolution; }
+ internal static IUpdatedNuGetPackagesInWorkspace UpdatedPackagesInWorkspace {
+ get { return updatedPackagesInWorkspace; }
}
public static IPackageManagementProjectOperations ProjectOperations {
get { return projectOperations; }
}
+
+ internal static PackageManagementWorkspace Workspace {
+ get { return workspace; }
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolution.cs deleted file mode 100644 index b5c5418f23..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolution.cs +++ /dev/null @@ -1,235 +0,0 @@ -//
-// PackageManagementSolution.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementSolution : IPackageManagementSolution
- {
- IRegisteredPackageRepositories registeredPackageRepositories;
- IPackageManagementProjectService projectService;
- IPackageManagementProjectFactory projectFactory;
- ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory;
-
- internal PackageManagementSolution (
- IPackageManagementProjectService projectService)
- : this (
- PackageManagementServices.RegisteredPackageRepositories,
- projectService,
- PackageManagementServices.PackageManagementEvents)
- {
- }
-
- public PackageManagementSolution(
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageManagementProjectService projectService,
- IPackageManagementEvents packageManagementEvents)
- : this(
- registeredPackageRepositories,
- projectService,
- new PackageManagementProjectFactory(packageManagementEvents),
- new SolutionPackageRepositoryFactory())
- {
- }
-
- public PackageManagementSolution(
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageManagementProjectService projectService,
- IPackageManagementProjectFactory projectFactory,
- ISolutionPackageRepositoryFactory solutionPackageRepositoryFactory)
- {
- this.registeredPackageRepositories = registeredPackageRepositories;
- this.projectFactory = projectFactory;
- this.projectService = projectService;
- this.solutionPackageRepositoryFactory = solutionPackageRepositoryFactory;
- }
-
- public string FileName {
- get { return OpenSolution.FileName; }
- }
-
- ISolution OpenSolution {
- get { return projectService.OpenSolution; }
- }
-
- public IPackageManagementProject GetActiveProject()
- {
- if (HasActiveProject()) {
- return GetActiveProject(registeredPackageRepositories.CreateAggregateRepository());
- }
- return null;
- }
-
- bool HasActiveProject()
- {
- return GetActiveDotNetProject() != null;
- }
-
- public IDotNetProject GetActiveDotNetProject ()
- {
- if (projectService.CurrentProject != null) {
- return projectService.CurrentProject as IDotNetProject;
- }
- return null;
- }
-
- IPackageRepository ActivePackageRepository {
- get { return registeredPackageRepositories.ActiveRepository; }
- }
-
- public IPackageManagementProject GetActiveProject(IPackageRepository sourceRepository)
- {
- IDotNetProject activeProject = GetActiveDotNetProject ();
- if (activeProject != null) {
- return CreateProject (sourceRepository, activeProject);
- }
- return null;
- }
-
- IPackageManagementProject CreateProject (IPackageRepository sourceRepository, IDotNetProject project)
- {
- if (!(sourceRepository is AggregateRepository)) {
- sourceRepository = CreateFallbackRepository (sourceRepository);
- }
- return projectFactory.CreateProject (sourceRepository, project);
- }
-
- IPackageRepository CreateFallbackRepository (IPackageRepository repository)
- {
- return new FallbackRepository (repository, registeredPackageRepositories.CreateAggregateRepository ());
- }
-
- IPackageRepository CreatePackageRepository(PackageSource source)
- {
- return registeredPackageRepositories.CreateRepository(source);
- }
-
- public IPackageManagementProject GetProject(PackageSource source, string projectName)
- {
- IDotNetProject project = GetDotNetProject (projectName);
- return CreateProject(source, project);
- }
-
- IDotNetProject GetDotNetProject (string name)
- {
- var openProjects = new OpenDotNetProjects(projectService);
- return openProjects.FindProject(name);
- }
-
- IPackageManagementProject CreateProject (PackageSource source, IDotNetProject project)
- {
- IPackageRepository sourceRepository = CreatePackageRepository(source);
- return CreateProject(sourceRepository, project);
- }
-
- public IPackageManagementProject GetProject(IPackageRepository sourceRepository, string projectName)
- {
- IDotNetProject project = GetDotNetProject (projectName);
- return CreateProject(sourceRepository, project);
- }
-
- public IPackageManagementProject GetProject (IPackageRepository sourceRepository, IDotNetProject project)
- {
- return CreateProject (sourceRepository, project);
- }
-
- public IPackageManagementProject GetProject (IDotNetProject project)
- {
- return CreateProject (registeredPackageRepositories.CreateAggregateRepository(), project);
- }
-
- public IEnumerable<IDotNetProject> GetDotNetProjects ()
- {
- return projectService.GetOpenProjects ();
- }
-
- public bool IsOpen {
- get { return OpenSolution != null; }
- }
-
- public bool HasMultipleProjects()
- {
- return projectService.GetOpenProjects().Count() > 1;
- }
-
- public bool IsPackageInstalled(IPackage package)
- {
- ISolutionPackageRepository repository = CreateSolutionPackageRepository();
- return repository.IsInstalled(package);
- }
-
- ISolutionPackageRepository CreateSolutionPackageRepository()
- {
- return solutionPackageRepositoryFactory.CreateSolutionPackageRepository (OpenSolution);
- }
-
- public IQueryable<IPackage> GetPackages()
- {
- ISolutionPackageRepository repository = CreateSolutionPackageRepository();
- List<IPackageManagementProject> projects = GetProjects(ActivePackageRepository).ToList();
- return repository
- .GetPackages()
- .Where(package => IsPackageInstalledInSolutionOrAnyProject(projects, package));
- }
-
- bool IsPackageInstalledInSolutionOrAnyProject(IList<IPackageManagementProject> projects, IPackage package)
- {
- if (projects.Any(project => project.IsPackageInstalled(package))) {
- return true;
- }
- return false;
- }
-
- public string GetInstallPath(IPackage package)
- {
- ISolutionPackageRepository repository = CreateSolutionPackageRepository();
- return repository.GetInstallPath(package);
- }
-
- public IEnumerable<IPackage> GetPackagesInReverseDependencyOrder()
- {
- ISolutionPackageRepository repository = CreateSolutionPackageRepository();
- return repository.GetPackagesByReverseDependencyOrder();
- }
-
- public IEnumerable<IPackageManagementProject> GetProjects(IPackageRepository sourceRepository)
- {
- foreach (IDotNetProject dotNetProject in GetDotNetProjects ()) {
- yield return CreateProject (sourceRepository, dotNetProject);
- }
- }
-
- public ISolutionPackageRepository GetRepository ()
- {
- return CreateSolutionPackageRepository ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolutionProjectService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolutionProjectService.cs index b0054728d5..2d7bd64136 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolutionProjectService.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementSolutionProjectService.cs @@ -53,15 +53,11 @@ namespace MonoDevelop.PackageManagement {
return solution.GetAllProjects ();
}
-
+ #pragma warning disable 67
public event EventHandler<ProjectReloadedEventArgs> ProjectReloaded;
public event EventHandler SolutionLoaded;
public event EventHandler SolutionUnloaded;
-
- public IProjectBrowserUpdater CreateProjectBrowserUpdater ()
- {
- throw new NotImplementedException ();
- }
+ #pragma warning restore 67
public string GetDefaultCustomToolForFileName (ProjectFile projectItem)
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementViewModels.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementViewModels.cs deleted file mode 100644 index 600165760b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementViewModels.cs +++ /dev/null @@ -1,119 +0,0 @@ -//
-// PackageManagementViewModels.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageManagementViewModels
- {
- ManagePackagesViewModel managePackagesViewModel;
- RegisteredPackageSourcesViewModel registeredPackageSourcesViewModel;
- PackageManagementOptionsViewModel packageManagementOptionsViewModel;
- IPackageManagementSolution solution;
- IRegisteredPackageRepositories registeredPackageRepositories;
-
- public ManagePackagesViewModel ManagePackagesViewModel {
- get {
- CreateManagePackagesViewModel();
- return managePackagesViewModel;
- }
- }
-
- void CreateManagePackagesViewModel()
- {
- CreateRegisteredPackageRepositories();
- CreateSolution();
- ThreadSafePackageManagementEvents packageManagementEvents = CreateThreadSafePackageManagementEvents();
- PackagesViewModels packagesViewModels = CreatePackagesViewModels(packageManagementEvents);
-
- managePackagesViewModel =
- new ManagePackagesViewModel(
- packagesViewModels,
- new ManagePackagesViewTitle(solution),
- packageManagementEvents);
- }
-
- void CreateRegisteredPackageRepositories()
- {
- if (registeredPackageRepositories == null) {
- registeredPackageRepositories = PackageManagementServices.RegisteredPackageRepositories;
- }
- }
-
- void CreateSolution()
- {
- if (solution == null) {
- solution = PackageManagementServices.Solution;
- }
- }
-
- ThreadSafePackageManagementEvents CreateThreadSafePackageManagementEvents()
- {
- return new ThreadSafePackageManagementEvents(
- PackageManagementServices.PackageManagementEvents);
- }
-
- PackagesViewModels CreatePackagesViewModels(IThreadSafePackageManagementEvents packageManagementEvents)
- {
- return new PackagesViewModels(
- solution,
- registeredPackageRepositories,
- packageManagementEvents,
- PackageManagementServices.PackageActionRunner,
- new PackageManagementTaskFactory());
- }
-
- public RegisteredPackageSourcesViewModel RegisteredPackageSourcesViewModel {
- get {
- if (registeredPackageSourcesViewModel == null) {
- registeredPackageSourcesViewModel = CreateRegisteredPackageSourcesViewModel();
- }
- return registeredPackageSourcesViewModel;
- }
- }
-
- RegisteredPackageSourcesViewModel CreateRegisteredPackageSourcesViewModel()
- {
- CreateRegisteredPackageRepositories();
- return new RegisteredPackageSourcesViewModel(registeredPackageRepositories);
- }
-
- public PackageManagementOptionsViewModel PackageManagementOptionsViewModel {
- get {
- if (packageManagementOptionsViewModel == null) {
- CreateRegisteredPackageRepositories();
- IRecentPackageRepository recentRepository = registeredPackageRepositories.RecentPackageRepository;
- packageManagementOptionsViewModel = new PackageManagementOptionsViewModel(recentRepository);
- }
- return packageManagementOptionsViewModel;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementWorkspace.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementWorkspace.cs new file mode 100644 index 0000000000..e9c56978b6 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageManagementWorkspace.cs @@ -0,0 +1,108 @@ +//
+// PackageManagementWorkspace.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using MonoDevelop.Core;
+using MonoDevelop.Ide;
+using MonoDevelop.Projects;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class PackageManagementWorkspace
+ {
+ List<MonoDevelopSolutionManager> solutionManagers = new List<MonoDevelopSolutionManager> ();
+
+ public PackageManagementWorkspace ()
+ {
+ IdeApp.Workspace.SolutionLoaded += SolutionLoaded;
+ IdeApp.Workspace.SolutionUnloaded += SolutionUnloaded;
+ }
+
+ void SolutionLoaded (object sender, SolutionEventArgs e)
+ {
+ try {
+ Runtime.RunInMainThread (() => {
+ AddSolution (e.Solution);
+ });
+ } catch (Exception ex) {
+ LoggingService.LogError ("Unable to create solution manager.", ex);
+ }
+ }
+ + void SolutionUnloaded (object sender, SolutionEventArgs e)
+ {
+ try {
+ Runtime.RunInMainThread (() => {
+ RemoveSolution (e.Solution);
+ });
+ } catch (Exception ex) {
+ LoggingService.LogError ("Unable to unload solution manager.", ex);
+ }
+ }
+ + void AddSolution (Solution solution)
+ {
+ var solutionManager = new MonoDevelopSolutionManager (solution);
+ solutionManagers.Add (solutionManager);
+ }
+
+ void RemoveSolution (Solution solution)
+ {
+ solutionManagers.RemoveAll (manager => manager.Solution == solution);
+ }
+
+ public IMonoDevelopSolutionManager GetSolutionManager (Solution solution)
+ {
+ Runtime.AssertMainThread ();
+
+ return GetSolutionManager (new SolutionProxy (solution));
+ }
+
+ public IMonoDevelopSolutionManager GetSolutionManager (ISolution solution)
+ {
+ Runtime.AssertMainThread ();
+
+ var solutionManager = solutionManagers.FirstOrDefault (manager => manager.Solution == solution.Solution);
+ if (solutionManager != null) {
+ return solutionManager;
+ }
+
+ return new MonoDevelopSolutionManager (solution);
+ }
+
+ public void ReloadSettings ()
+ {
+ Runtime.AssertMainThread ();
+
+ foreach (IMonoDevelopSolutionManager solutionManager in solutionManagers) {
+ solutionManager.ReloadSettings ();
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageOperationsResolverFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageOperationsResolverFactory.cs deleted file mode 100644 index 7615494c4b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageOperationsResolverFactory.cs +++ /dev/null @@ -1,64 +0,0 @@ -//
-// PackageOperationsResolverFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageOperationsResolverFactory : IPackageOperationResolverFactory
- {
- public IPackageOperationResolver CreateInstallPackageOperationResolver(
- IPackageRepository localRepository,
- IPackageRepository sourceRepository,
- ILogger logger,
- InstallPackageAction installAction)
- {
- return new InstallWalker(
- localRepository,
- sourceRepository,
- installAction.ProjectTargetFramework,
- logger,
- installAction.IgnoreDependencies,
- installAction.AllowPrereleaseVersions,
- DependencyVersion.Lowest);
- }
-
- public IPackageOperationResolver CreateUpdatePackageOperationResolver(IPackageRepository localRepository, IPackageRepository sourceRepository, ILogger logger, IUpdatePackageSettings settings)
- {
- return new InstallWalker(
- localRepository,
- sourceRepository,
- null,
- logger,
- !settings.UpdateDependencies,
- settings.AllowPrereleaseVersions,
- DependencyVersion.Lowest);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceExtensions.cs index c2fc1b11d8..a255c150f8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceExtensions.cs @@ -24,42 +24,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using NuGet;
+using NuGet.Packaging;
namespace MonoDevelop.PackageManagement
{
internal static class PackageReferenceExtensions
{
- public static bool IsPackageInstalled (this PackageReference packageReference, DotNetProject project)
+ public static bool IsFloating (this PackageReference packageReference)
{
- var packagesPath = new SolutionPackageRepositoryPath (project);
- var fileSystem = new PhysicalFileSystem (packagesPath.PackageRepositoryPath);
- return packageReference.IsPackageInstalled (fileSystem);
- }
-
- public static bool IsPackageInstalled (this PackageReference packageReference, PhysicalFileSystem fileSystem)
- {
- if (packageReference.Version == null) {
- return false;
- }
-
- var repository = new LocalPackageRepository (new DefaultPackagePathResolver (fileSystem), fileSystem);
- return repository
- .GetPackageLookupPaths (packageReference.Id, packageReference.Version)
- .Any ();
- }
-
- public static bool IsReleaseVersion (this PackageReference packageReference)
- {
- if (packageReference.Version == null) {
- return true;
- }
-
- return String.IsNullOrEmpty (packageReference.Version.SpecialVersion);
+ return packageReference.HasAllowedVersions && packageReference.AllowedVersions.IsFloating;
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceMonitor.cs deleted file mode 100644 index 732940d0df..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReferenceMonitor.cs +++ /dev/null @@ -1,71 +0,0 @@ -//
-// PackageReferenceMonitor.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageReferenceMonitor : IDisposable
- {
- IMonoDevelopProjectManager projectManager;
- IMonoDevelopPackageManager packageManager;
- List<IPackage> packagesRemoved = new List<IPackage>();
-
- public PackageReferenceMonitor (
- IMonoDevelopProjectManager projectManager,
- IMonoDevelopPackageManager packageManager)
- {
- this.projectManager = projectManager;
- this.packageManager = packageManager;
- projectManager.PackageReferenceRemoved += PackageReferenceRemoved;
- projectManager.PackageReferenceAdded += PackageReferenceAdded;
- }
-
- void PackageReferenceRemoved(object sender, PackageOperationEventArgs e)
- {
- packagesRemoved.Add(e.Package);
- }
-
- void PackageReferenceAdded (object sender, PackageOperationEventArgs e)
- {
- packageManager.InstallPackageIntoSolutionRepository (e.Package);
- }
-
- public void Dispose()
- {
- projectManager.PackageReferenceRemoved -= PackageReferenceRemoved;
- projectManager.PackageReferenceAdded -= PackageReferenceAdded;
- }
-
- public List<IPackage> PackagesRemoved {
- get { return packagesRemoved; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReinstaller.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReinstaller.cs index bff3dcbf99..9717ee1eaa 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReinstaller.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageReinstaller.cs @@ -31,21 +31,17 @@ namespace MonoDevelop.PackageManagement {
internal class PackageReinstaller
{
- IPackageManagementSolution solution;
IBackgroundPackageActionRunner runner;
public PackageReinstaller ()
: this (
- PackageManagementServices.Solution,
PackageManagementServices.BackgroundPackageActionRunner)
{
}
public PackageReinstaller (
- IPackageManagementSolution solution,
IBackgroundPackageActionRunner runner)
{
- this.solution = solution;
this.runner = runner;
}
@@ -58,10 +54,13 @@ namespace MonoDevelop.PackageManagement public void Run (PackageReferenceNode packageReferenceNode, ProgressMonitorStatusMessage progressMessage)
{
try {
- IPackageManagementProject project = solution.GetProject (packageReferenceNode.Project);
- ReinstallPackageAction action = project.CreateReinstallPackageAction ();
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (packageReferenceNode.Project.ParentSolution);
+
+ var action = new ReinstallNuGetPackageAction (
+ packageReferenceNode.Project,
+ solutionManager);
action.PackageId = packageReferenceNode.Id;
- action.PackageVersion = packageReferenceNode.Version;
+ action.Version = packageReferenceNode.Version;
runner.Run (progressMessage, action);
} catch (Exception ex) {
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryCache.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryCache.cs deleted file mode 100644 index 38c63a275a..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryCache.cs +++ /dev/null @@ -1,196 +0,0 @@ -//
-// PackageRepositoryCache.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012-2013 Matthew Ward
-//
-// 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 System.Collections.Concurrent;
-using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageRepositoryCache : IPackageRepositoryCache, IPackageRepositoryFactoryEvents
- {
- IMonoDevelopPackageRepositoryFactory factory;
- RegisteredPackageSources packageSources;
- PackageManagementOptions options;
- IList<RecentPackageInfo> recentPackages;
- IRecentPackageRepository recentPackageRepository;
- IPackageRepository machineCache;
- ConcurrentDictionary<string, IPackageRepository> repositories =
- new ConcurrentDictionary<string, IPackageRepository>();
-
- public PackageRepositoryCache (
- PackageManagementOptions options,
- IPackageRepository machineCache,
- IMonoDevelopPackageRepositoryFactory factory)
- {
- this.options = options;
- this.machineCache = machineCache;
- this.factory = factory;
- this.recentPackages = options.RecentPackages;
- }
-
- public PackageRepositoryCache (
- PackageManagementOptions options,
- IMonoDevelopPackageRepositoryFactory factory)
- : this (
- options,
- MachineCache.Default,
- factory)
- {
- }
-
- public PackageRepositoryCache (PackageManagementOptions options)
- : this(
- options,
- new MonoDevelopPackageRepositoryFactory ())
- {
- }
-
- public PackageRepositoryCache (
- RegisteredPackageSources packageSources,
- IList<RecentPackageInfo> recentPackages)
- {
- this.factory = new MonoDevelopPackageRepositoryFactory ();
- this.recentPackages = recentPackages;
- this.packageSources = packageSources;
- }
-
- public event EventHandler<PackageRepositoryFactoryEventArgs> RepositoryCreated;
-
- public IPackageRepository CreateRepository(string packageSource)
- {
- IPackageRepository repository = GetExistingRepository(packageSource);
- if (repository != null) {
- return repository;
- }
- return CreateNewCachedRepository(packageSource);
- }
-
- IPackageRepository GetExistingRepository(string packageSource)
- {
- IPackageRepository repository = null;
- if (repositories.TryGetValue(packageSource, out repository)) {
- return repository;
- }
- return null;
- }
-
- IPackageRepository CreateNewCachedRepository(string packageSource)
- {
- IPackageRepository repository = factory.CreateRepository(packageSource);
- repositories.TryAdd(packageSource, repository);
-
- OnPackageRepositoryCreated(repository);
-
- return repository;
- }
-
- void OnPackageRepositoryCreated(IPackageRepository repository)
- {
- if (RepositoryCreated != null) {
- RepositoryCreated(this, new PackageRepositoryFactoryEventArgs(repository));
- }
- }
-
- public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
- {
- return factory.CreateSharedRepository(pathResolver, fileSystem, configSettingsFileSystem);
- }
-
- public IPackageRepository CreateAggregateRepository()
- {
- IEnumerable<IPackageRepository> allRepositories = CreateAllEnabledRepositories();
- return CreateAggregateRepository(allRepositories);
- }
-
- IEnumerable<IPackageRepository> CreateAllEnabledRepositories()
- {
- foreach (PackageSource source in PackageSources.GetEnabledPackageSources ()) {
- yield return CreateRepositoryIgnoringFailures (source.Source);
- }
- }
-
- RegisteredPackageSources PackageSources {
- get {
- if (packageSources != null) {
- return packageSources;
- }
- return options.PackageSources;
- }
- }
-
- public IPackageRepository CreateAggregateRepository(IEnumerable<IPackageRepository> repositories)
- {
- return factory.CreateAggregateRepository(repositories);
- }
-
- public IRecentPackageRepository RecentPackageRepository {
- get {
- CreateRecentPackageRepository();
- return recentPackageRepository;
- }
- }
-
- void CreateRecentPackageRepository()
- {
- if (recentPackageRepository == null) {
- CreateRecentPackageRepository(recentPackages, NuGet.MachineCache.Default);
- }
- }
-
- public IRecentPackageRepository CreateRecentPackageRepository(
- IList<RecentPackageInfo> recentPackages,
- IPackageRepository aggregateRepository)
- {
- if (recentPackageRepository == null) {
- recentPackageRepository = factory.CreateRecentPackageRepository(recentPackages, aggregateRepository);
- }
- return recentPackageRepository;
- }
-
- public IPackageRepository CreateAggregateWithPriorityMachineCacheRepository ()
- {
- return new PriorityPackageRepository (machineCache, CreateAggregateRepository ());
- }
-
- IPackageRepository CreateRepositoryIgnoringFailures (string packageSource)
- {
- try {
- return CreateRepository (packageSource);
- } catch (Exception ex) {
- // Deliberately caching the failing package source so the
- // AggregateRepository only reports its failure once.
- var repository = new FailingPackageRepository (packageSource, ex);
- repositories.TryAdd(packageSource, repository);
- return repository;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryFactoryEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryFactoryEventArgs.cs deleted file mode 100644 index 995209b05f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryFactoryEventArgs.cs +++ /dev/null @@ -1,43 +0,0 @@ -//
-// PackageRepositoryFactoryEventArgs.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageRepositoryFactoryEventArgs : EventArgs
- {
- public PackageRepositoryFactoryEventArgs(IPackageRepository repository)
- {
- this.Repository = repository;
- }
-
- public IPackageRepository Repository { get; private set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryNodeExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryNodeExtensions.cs index 6a45aef031..fc9544a757 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryNodeExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRepositoryNodeExtensions.cs @@ -24,17 +24,19 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using Mono.Addins;
-using MonoDevelop.Core;
-using NuGet;
+using NuGet.Configuration;
using MonoDevelop.Ide.Templates;
namespace MonoDevelop.PackageManagement
{
static class PackageRepositoryNodeExtensions
{
- public static PackageSource GetPackageSource (this PackageRepositoryNode node)
+ public static NuGet.PackageSource GetPackageSource (this PackageRepositoryNode node)
+ {
+ return new NuGet.PackageSource (node.Source, node.Id);
+ }
+
+ public static PackageSource CreatePackageSource (this PackageRepositoryNode node)
{
return new PackageSource (node.Source, node.Id);
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreMonitor.cs new file mode 100644 index 0000000000..294ca0424d --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreMonitor.cs @@ -0,0 +1,85 @@ +//
+// PackageRestoreMonitor.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 MonoDevelop.Core;
+using NuGet.PackageManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class PackageRestoreMonitor : IDisposable
+ {
+ IPackageRestoreManager packageRestoreManager;
+ IPackageManagementEvents packageManagementEvents;
+
+ public PackageRestoreMonitor (IPackageRestoreManager packageRestoreManager)
+ : this (
+ packageRestoreManager,
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public PackageRestoreMonitor (
+ IPackageRestoreManager packageRestoreManager,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.packageRestoreManager = packageRestoreManager;
+ this.packageManagementEvents = packageManagementEvents;
+
+ packageRestoreManager.PackageRestoreFailedEvent += PackageRestoreFailed;
+ }
+
+ public bool RestoreFailed { get; private set; }
+
+ public void Dispose ()
+ {
+ packageRestoreManager.PackageRestoreFailedEvent -= PackageRestoreFailed;
+
+ if (RestoreFailed) {
+ throw new ApplicationException (GettextCatalog.GetString ("Package restore failed."));
+ }
+ }
+
+ void PackageRestoreFailed (object sender, PackageRestoreFailedEventArgs e)
+ {
+ RestoreFailed = true;
+
+ foreach (string projectName in e.ProjectNames) {
+ LogFailure (projectName, e.Exception);
+ }
+ }
+
+ void LogFailure (string projectName, Exception exception)
+ {
+ packageManagementEvents.OnPackageOperationMessageLogged (
+ NuGet.MessageLevel.Info,
+ GettextCatalog.GetString ("Package restore failed for project {0}: {1}"),
+ projectName,
+ exception.Message);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs deleted file mode 100644 index 3f090d518f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestoreRunner.cs +++ /dev/null @@ -1,176 +0,0 @@ -//
-// PackageRestoreRunner.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 System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using MonoDevelop.Ide.TypeSystem;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageRestoreRunner
- {
- IPackageManagementSolution solution;
- IPackageManagementProgressMonitorFactory progressMonitorFactory;
- IPackageManagementEvents packageManagementEvents;
- IProgressProvider progressProvider;
- IDotNetProject project;
-
- public PackageRestoreRunner()
- : this(
- PackageManagementServices.Solution,
- PackageManagementServices.ProgressMonitorFactory,
- PackageManagementServices.PackageManagementEvents,
- PackageManagementServices.ProgressProvider)
- {
- }
-
- internal PackageRestoreRunner (IPackageManagementSolution solution)
- : this (
- solution,
- PackageManagementServices.ProgressMonitorFactory,
- PackageManagementServices.PackageManagementEvents,
- PackageManagementServices.ProgressProvider)
- {
- }
-
- public PackageRestoreRunner(
- IPackageManagementSolution solution,
- IPackageManagementProgressMonitorFactory progressMonitorFactory,
- IPackageManagementEvents packageManagementEvents,
- IProgressProvider progressProvider)
- {
- this.solution = solution;
- this.progressMonitorFactory = progressMonitorFactory;
- this.packageManagementEvents = packageManagementEvents;
- this.progressProvider = progressProvider;
- }
-
- public void Run ()
- {
- Run (ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage ());
- }
-
- public void Run (IDotNetProject project, ProgressMonitorStatusMessage progressMessage)
- {
- this.project = project;
- Run (progressMessage);
- }
-
- public void Run (ProgressMonitorStatusMessage progressMessage)
- {
- using (ProgressMonitor progressMonitor = CreateProgressMonitor (progressMessage)) {
- using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor (progressMonitor)) {
- try {
- RestorePackages (progressMonitor, progressMessage);
- } catch (Exception ex) {
- LoggingService.LogError (progressMessage.Error, ex);
- progressMonitor.Log.WriteLine (ex.Message);
- progressMonitor.ReportError (progressMessage.Error, null);
- progressMonitor.ShowPackageConsole ();
- progressMonitor.Dispose ();
- RestoreFailed = true;
- }
- }
- }
- }
-
- public bool RestoreFailed { get; private set; }
-
- ProgressMonitor CreateProgressMonitor (ProgressMonitorStatusMessage progressMessage)
- {
- return progressMonitorFactory.CreateProgressMonitor (progressMessage.Status);
- }
-
- PackageManagementEventsMonitor CreateEventMonitor (ProgressMonitor monitor)
- {
- return new PackageManagementEventsMonitor (monitor, packageManagementEvents, progressProvider);
- }
-
- void RestorePackages (ProgressMonitor progressMonitor, ProgressMonitorStatusMessage progressMessage)
- {
- var msbuildTargetsMonitor = new MSBuildTargetsRestoredMonitor (packageManagementEvents);
- using (msbuildTargetsMonitor) {
- var action = new RestorePackagesAction (solution, packageManagementEvents);
- if (project != null) {
- action.Project = project;
- }
- action.Execute ();
- }
-
- RefreshProjectReferences (msbuildTargetsMonitor.AnyMSBuildTargetsRestored);
- ForceCreationOfSharedRepositoriesConfigFile ();
-
- progressMonitor.ReportSuccess (progressMessage.Success);
- packageManagementEvents.OnPackagesRestored ();
- }
-
- /// <summary>
- /// Creating package managers for all the projects will force the
- /// repositories.config file to be created.
- /// </summary>
- void ForceCreationOfSharedRepositoriesConfigFile ()
- {
- var repository = PackageManagementServices.RegisteredPackageRepositories.CreateAggregateRepository ();
- solution.GetProjects (repository).ToList ();
- }
-
- /// <summary>
- /// Refresh all projects even though we may have only restored packages for one project since
- /// the packages may be used in other projects.
- /// </summary>
- void RefreshProjectReferences (bool refreshMSBuildTargets)
- {
- Runtime.RunInMainThread (() => {
- foreach (IDotNetProject projectInSolution in solution.GetDotNetProjects ()) {
- if (refreshMSBuildTargets) {
- projectInSolution.RefreshProjectBuilder ();
- }
-
- projectInSolution.DotNetProject.RefreshReferenceStatus ();
-
- if (refreshMSBuildTargets) {
- ReconnectAssemblyReferences (projectInSolution.DotNetProject);
- }
- }
- });
- }
-
- void ReconnectAssemblyReferences (DotNetProject dotNetProject)
- {
- // TODO: Roslyn port ?
-// var projectWrapper = TypeSystemService.GetProjectContentWrapper (dotNetProject);
-// if (projectWrapper != null) {
-// projectWrapper.ReconnectAssemblyReferences ();
-// }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestorer.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestorer.cs deleted file mode 100644 index 1ea060c154..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageRestorer.cs +++ /dev/null @@ -1,101 +0,0 @@ -//
-// PackageRestorer.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 System.Linq;
-using MonoDevelop.Projects;
-using System.Collections.Generic;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageRestorer
- {
- List<ProjectPackageReferenceFile> packageReferenceFiles;
- IDotNetProject singleProject;
- IPackageManagementSolution solution;
-
- public PackageRestorer (IPackageManagementSolution solution)
- : this (solution, solution.GetDotNetProjects ().Select (p => p.DotNetProject))
- {
- }
-
- public PackageRestorer (IPackageManagementSolution solution, DotNetProject project)
- : this (solution, new [] { project })
- {
- singleProject = new DotNetProjectProxy (project);
- }
-
- public PackageRestorer (IPackageManagementSolution solution, IEnumerable<DotNetProject> projects)
- {
- this.solution = solution;
- packageReferenceFiles = FindAllPackageReferenceFiles (projects).ToList ();
- }
-
- IEnumerable<ProjectPackageReferenceFile> FindAllPackageReferenceFiles (IEnumerable<DotNetProject> projects)
- {
- return projects
- .Where (project => project.HasPackages ())
- .Select (project => new ProjectPackageReferenceFile (project));
- }
-
- public bool RestoreFailed { get; private set; }
-
- public void Restore ()
- {
- Restore (ProgressMonitorStatusMessageFactory.CreateRestoringPackagesInSolutionMessage ());
- }
-
- public void Restore (ProgressMonitorStatusMessage progressMessage)
- {
- try {
- if (AnyMissingPackages ()) {
- RestoreWithProgressMonitor (progressMessage);
- }
- } catch (Exception ex) {
- LoggingService.LogError ("Package restore failed", ex);
- RestoreFailed = true;
- }
- }
-
- bool AnyMissingPackages ()
- {
- return packageReferenceFiles.Any (file => file.AnyMissingPackages ());
- }
-
- void RestoreWithProgressMonitor (ProgressMonitorStatusMessage progressMessage)
- {
- var runner = new PackageRestoreRunner (solution);
- if (singleProject != null) {
- runner.Run (singleProject, progressMessage);
- } else {
- runner.Run (progressMessage);
- }
- RestoreFailed = runner.RestoreFailed;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchCriteria.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchCriteria.cs deleted file mode 100644 index cb1cb1afd3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchCriteria.cs +++ /dev/null @@ -1,93 +0,0 @@ -//
-// PackageSearchCriteria.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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageSearchCriteria
- {
- WildcardVersionSpec wildcardVersionSpec;
-
- public PackageSearchCriteria (string searchText)
- {
- SearchText = RemoveWhitespace (searchText);
- ParseSearchText (SearchText);
- }
-
- public string PackageId { get; private set; }
- public string SearchText { get; private set; }
-
- public bool IsPackageVersionSearch {
- get { return !String.IsNullOrEmpty (PackageId); }
- }
-
- public bool IsVersionMatch (SemanticVersion version)
- {
- if (wildcardVersionSpec == null)
- return true;
-
- return wildcardVersionSpec.Satisfies (version);
- }
-
- string RemoveWhitespace (string searchText)
- {
- if (String.IsNullOrWhiteSpace (searchText))
- return null;
-
- return searchText;
- }
-
- void ParseSearchText (string searchText)
- {
- if (searchText == null)
- return;
-
- string[] parts = searchText.Split (new [] {' '}, StringSplitOptions.RemoveEmptyEntries);
- if (parts.Length < 2)
- return;
-
- if (!IsVersionOption (parts [1]))
- return;
-
- PackageId = parts [0].Trim ();
-
- wildcardVersionSpec = new WildcardVersionSpec (GetVersion (parts [1]));
- }
-
- bool IsVersionOption (string option)
- {
- return option.StartsWith ("version:", StringComparison.OrdinalIgnoreCase);
- }
-
- string GetVersion (string option)
- {
- int index = option.IndexOf (':');
- return option.Substring (index + 1);
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchResultViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchResultViewModel.cs new file mode 100644 index 0000000000..9a6d0d9f06 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchResultViewModel.cs @@ -0,0 +1,448 @@ +//
+// PackageSearchResultViewModel.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using NuGet.Common;
+using NuGet.PackageManagement.UI;
+using NuGet.Packaging.Core;
+using NuGet.Protocol.Core.Types;
+using NuGet.Frameworks;
+using NuGet.Versioning;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class PackageSearchResultViewModel : ViewModelBase<PackageSearchResultViewModel>
+ {
+ AllPackagesViewModel parent;
+ PackageItemListViewModel viewModel;
+ PackageDetailControlModel packageDetailModel;
+ List<PackageDependencyMetadata> dependencies;
+ string summary;
+ bool isChecked;
+
+ public PackageSearchResultViewModel (
+ AllPackagesViewModel parent,
+ PackageItemListViewModel viewModel)
+ {
+ this.parent = parent;
+ this.viewModel = viewModel;
+
+ Versions = new ObservableCollection<NuGetVersion> ();
+ SelectedVersion = Version;
+ }
+
+ public AllPackagesViewModel Parent {
+ get { return parent; }
+ set { parent = value; }
+ }
+
+ public string Id {
+ get { return viewModel.Id; }
+ }
+
+ public NuGetVersion Version {
+ get { return viewModel.Version; }
+ }
+
+ public string Title {
+ get { return viewModel.Title; }
+ }
+
+ public string Name {
+ get {
+ if (String.IsNullOrEmpty (Title))
+ return Id;
+
+ return Title;
+ }
+ }
+
+ public bool IsChecked {
+ get { return isChecked; }
+ set {
+ if (value != isChecked) {
+ isChecked = value;
+ parent.OnPackageCheckedChanged (this);
+ }
+ }
+ }
+
+ public bool HasLicenseUrl {
+ get { return LicenseUrl != null; }
+ }
+
+ public Uri LicenseUrl {
+ get { return viewModel.LicenseUrl; }
+ }
+
+ public bool HasProjectUrl {
+ get { return ProjectUrl != null; }
+ }
+
+ public Uri ProjectUrl {
+ get { return viewModel.ProjectUrl; }
+ }
+
+ public bool HasGalleryUrl {
+ get { return GalleryUrl != null; }
+ }
+
+ public bool HasNoGalleryUrl {
+ get { return !HasGalleryUrl; }
+ }
+
+ public Uri GalleryUrl {
+ get { return null; }
+ //get { return viewModel.GalleryUrl; }
+ }
+
+ public Uri IconUrl {
+ get { return viewModel.IconUrl; }
+ }
+
+ public bool HasIconUrl {
+ get { return IconUrl != null; }
+ }
+
+ public string Author {
+ get { return viewModel.Author; }
+ }
+
+ public string Summary {
+ get {
+ if (summary == null) {
+ summary = StripNewLinesAndIndentation (GetSummaryOrDescription ());
+ }
+ return summary;
+ }
+ }
+
+ string GetSummaryOrDescription ()
+ {
+ if (String.IsNullOrEmpty (viewModel.Summary))
+ return viewModel.Description;
+ return viewModel.Summary;
+ }
+
+ string StripNewLinesAndIndentation (string text)
+ {
+ return PackageListViewTextFormatter.Format (text);
+ }
+
+ public string Description {
+ get { return viewModel.Description; }
+ }
+
+ public bool HasDownloadCount {
+ get { return viewModel.DownloadCount >= 0; }
+ }
+
+ public string GetNameMarkup ()
+ {
+ return GetBoldText (Name);
+ }
+
+ static string GetBoldText (string text)
+ {
+ return String.Format ("<b>{0}</b>", text);
+ }
+
+ public string GetDownloadCountOrVersionDisplayText ()
+ {
+ if (ShowVersionInsteadOfDownloadCount) {
+ return Version.ToString ();
+ }
+
+ return GetDownloadCountDisplayText ();
+ }
+
+ public string GetDownloadCountDisplayText ()
+ {
+ if (HasDownloadCount) {
+ return viewModel.DownloadCount.Value.ToString ("N0");
+ }
+ return String.Empty;
+ }
+
+ public bool ShowVersionInsteadOfDownloadCount { get; set; }
+
+ public DateTimeOffset? LastPublished {
+ get { return viewModel.Published; }
+ }
+
+ public bool HasLastPublished {
+ get { return viewModel.Published.HasValue; }
+ }
+
+ public string GetLastPublishedDisplayText()
+ {
+ if (HasLastPublished) {
+ return LastPublished.Value.Date.ToShortDateString ();
+ }
+ return String.Empty;
+ }
+
+ public NuGetVersion SelectedVersion { get; set; }
+ public ObservableCollection<NuGetVersion> Versions { get; private set; }
+
+ protected virtual Task ReadVersions (CancellationToken cancellationToken)
+ {
+ try {
+ packageDetailModel = new PackageDetailControlModel (parent.NuGetProject);
+ packageDetailModel.SelectedVersion = new DisplayVersion (SelectedVersion, null);
+ return ReadVersionsFromPackageDetailControlModel (cancellationToken).ContinueWith (
+ task => OnVersionsRead (task),
+ TaskScheduler.FromCurrentSynchronizationContext ());
+ } catch (Exception ex) {
+ LoggingService.LogError ("ReadVersions error.", ex);
+ }
+ return Task.FromResult (0);
+ }
+
+ Task ReadVersionsFromPackageDetailControlModel (CancellationToken cancellationToken)
+ {
+ if (!IsRecentPackage) {
+ return packageDetailModel.SetCurrentPackage (viewModel);
+ }
+
+ return ReadVersionsForRecentPackage (cancellationToken);
+ }
+
+ async Task ReadVersionsForRecentPackage (CancellationToken cancellationToken)
+ {
+ var identity = new PackageIdentity (viewModel.Id, viewModel.Version);
+ foreach (var sourceRepository in parent.SelectedPackageSource.GetSourceRepositories ()) {
+ try {
+ var metadata = await sourceRepository.GetPackageMetadataAsync (identity, parent.IncludePrerelease, cancellationToken);
+ if (metadata != null) {
+ var packageViewModel = CreatePackageItemListViewModel (metadata);
+ await packageDetailModel.SetCurrentPackage (packageViewModel);
+ return;
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError (
+ String.Format ("Unable to get metadata for {0} from source {1}.", identity, sourceRepository.PackageSource.Name),
+ ex);
+ }
+ }
+ }
+
+ PackageItemListViewModel CreatePackageItemListViewModel (IPackageSearchMetadata metadata)
+ {
+ return new PackageItemListViewModel {
+ Id = metadata.Identity.Id,
+ Version = metadata.Identity.Version,
+ IconUrl = metadata.IconUrl,
+ Author = metadata.Authors,
+ DownloadCount = metadata.DownloadCount,
+ Summary = metadata.Summary,
+ Description = metadata.Description,
+ Title = metadata.Title,
+ LicenseUrl = metadata.LicenseUrl,
+ ProjectUrl = metadata.ProjectUrl,
+ Published = metadata.Published,
+ Versions = AsyncLazy.New (() => metadata.GetVersionsAsync ())
+ };
+ }
+
+ void OnVersionsRead (Task task)
+ {
+ try {
+ if (task.IsFaulted) {
+ LoggingService.LogError ("Failed to read package versions.", task.Exception);
+ } else if (task.IsCanceled) {
+ // Ignore.
+ } else {
+ Versions.Clear ();
+ foreach (NuGetVersion version in packageDetailModel.AllPackageVersions.OrderByDescending (v => v.Version)) {
+ Versions.Add (version);
+ }
+ OnPropertyChanged (viewModel => viewModel.Versions);
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("Failed to read package versions.", ex);
+ }
+ }
+
+ public bool IsOlderPackageInstalled ()
+ {
+ return parent.IsOlderPackageInstalled (Id, SelectedVersion);
+ }
+
+ public override bool Equals (object obj)
+ {
+ var other = obj as PackageSearchResultViewModel;
+ if (other == null)
+ return false;
+ + return StringComparer.OrdinalIgnoreCase.Equals (Id, other.Id);
+ }
+
+ public override int GetHashCode ()
+ {
+ return Id.GetHashCode ();
+ } + + public void UpdateFromPreviouslyCheckedViewModel (PackageSearchResultViewModel packageViewModel) + { + IsChecked = packageViewModel.IsChecked; + SelectedVersion = packageViewModel.SelectedVersion; + if (SelectedVersion != Version) { + Versions.Add (Version); + Versions.Add (SelectedVersion); + } + }
+
+ public void LoadPackageMetadata (IPackageMetadataProvider metadataProvider, CancellationToken cancellationToken)
+ {
+ if (packageDetailModel != null) {
+ return;
+ }
+
+ if (IsRecentPackage) {
+ ReadVersions (cancellationToken).ContinueWith (
+ task => LoadPackageMetadataFromPackageDetailModel (metadataProvider, cancellationToken),
+ TaskScheduler.FromCurrentSynchronizationContext ());
+ } else {
+ ReadVersions (cancellationToken);
+ LoadPackageMetadataFromPackageDetailModel (metadataProvider, cancellationToken);
+ }
+ }
+ + void LoadPackageMetadataFromPackageDetailModel (IPackageMetadataProvider metadataProvider, CancellationToken cancellationToken)
+ {
+ try {
+ LoadPackageMetadataFromPackageDetailModelAsync (metadataProvider, cancellationToken);
+ } catch (Exception ex) {
+ LoggingService.LogError ("Error getting detailed package metadata.", ex);
+ }
+ }
+
+ protected virtual Task LoadPackageMetadataFromPackageDetailModelAsync (
+ IPackageMetadataProvider metadataProvider,
+ CancellationToken cancellationToken)
+ {
+ return packageDetailModel.LoadPackageMetadaAsync (metadataProvider, cancellationToken).ContinueWith (
+ task => OnPackageMetadataLoaded (task),
+ TaskScheduler.FromCurrentSynchronizationContext ());
+ }
+
+ void OnPackageMetadataLoaded (Task task)
+ {
+ try {
+ if (task.IsFaulted) {
+ LoggingService.LogError ("Failed to read package metadata.", task.Exception);
+ } else if (task.IsCanceled) {
+ // Ignore.
+ } else {
+ var metadata = packageDetailModel?.PackageMetadata;
+ if (metadata != null) {
+ viewModel.Published = metadata.Published;
+ dependencies = GetCompatibleDependencies ().ToList ();
+ OnPropertyChanged ("Dependencies");
+ }
+ }
+ } catch (Exception ex) {
+ LoggingService.LogError ("Failed to read package metadata.", ex);
+ }
+ }
+
+ public bool HasDependencies {
+ get { return CompatibleDependencies.Any (); }
+ }
+
+ public bool HasNoDependencies {
+ get { return !HasDependencies; }
+ }
+
+ public string GetPackageDependenciesDisplayText ()
+ {
+ var displayText = new StringBuilder ();
+ foreach (PackageDependencyMetadata dependency in CompatibleDependencies) {
+ displayText.AppendLine (dependency.ToString ());
+ }
+ return displayText.ToString ();
+ }
+
+ IEnumerable<PackageDependencyMetadata> CompatibleDependencies {
+ get { return dependencies ?? new List<PackageDependencyMetadata> (); }
+ }
+
+ IEnumerable<PackageDependencyMetadata> GetCompatibleDependencies ()
+ {
+ var metadata = packageDetailModel?.PackageMetadata;
+ if (metadata?.HasDependencies == true) {
+ var projectTargetFramework = new ProjectTargetFramework (parent.Project);
+ var targetFramework = NuGetFramework.Parse (projectTargetFramework.TargetFrameworkName.FullName);
+
+ foreach (var dependencySet in packageDetailModel.PackageMetadata.DependencySets) {
+ if (DefaultCompatibilityProvider.Instance.IsCompatible (targetFramework, dependencySet.TargetFramework)) {
+ return dependencySet.Dependencies;
+ }
+ }
+ }
+
+ return Enumerable.Empty<PackageDependencyMetadata> ();
+ }
+
+ public bool IsDependencyInformationAvailable {
+ get { return dependencies != null; }
+ }
+
+ public bool IsRecentPackage { get; set; }
+
+ public void ResetDetailedPackageMetadata ()
+ {
+ packageDetailModel = null;
+ } + + public void ResetForRedisplay (bool includePrereleaseVersions) + { + ResetDetailedPackageMetadata ();
+ IsChecked = false;
+ if (!includePrereleaseVersions) {
+ RemovePrereleaseVersions ();
+ } + } + + void RemovePrereleaseVersions () + { + var prereleaseVersions = Versions.Where (version => version.IsPrerelease).ToArray ();
+
+ foreach (NuGetVersion prereleaseVersion in prereleaseVersions) {
+ Versions.Remove (prereleaseVersion);
+ } + }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchResultViewModelComparer.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchResultViewModelComparer.cs new file mode 100644 index 0000000000..69bb202950 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSearchResultViewModelComparer.cs @@ -0,0 +1,47 @@ +// +// PackageSearchResultViewModelComparer.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; + +namespace MonoDevelop.PackageManagement +{ + class PackageSearchResultViewModelComparer : IEqualityComparer<PackageSearchResultViewModel> + { + public static readonly PackageSearchResultViewModelComparer Instance = + new PackageSearchResultViewModelComparer (); + + public bool Equals (PackageSearchResultViewModel x, PackageSearchResultViewModel y) + { + return x.Id.Equals (y.Id, StringComparison.OrdinalIgnoreCase); + } + + public int GetHashCode (PackageSearchResultViewModel obj) + { + return obj.Id.GetHashCode (); + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceExtensions.cs deleted file mode 100644 index dd169caa3f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceExtensions.cs +++ /dev/null @@ -1,41 +0,0 @@ -//
-// PackageSourceExtensions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal static class PackageSourceExtensions
- {
- public static bool IsAggregate(this PackageSource packageSource)
- {
- return packageSource.Source == RegisteredPackageSourceSettings.AggregatePackageSource.Source;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModel.cs index 815b0e7220..cd0b573e6d 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModel.cs @@ -27,32 +27,54 @@ //
using System;
-using NuGet;
+using NuGet.Configuration;
namespace MonoDevelop.PackageManagement
{
internal class PackageSourceViewModel : ViewModelBase<PackageSourceViewModel>
{
- RegisteredPackageSource packageSource;
+ PackageSource packageSource;
+
+ public PackageSourceViewModel ()
+ : this (new PackageSource (""))
+ {
+ }
public PackageSourceViewModel(PackageSource packageSource)
{
- this.packageSource = new RegisteredPackageSource(packageSource);
+ this.packageSource = packageSource.Clone ();
+
+ Name = packageSource.Name;
+ Password = packageSource.Password;
IsValid = true;
ValidationFailureMessage = "";
}
public PackageSource GetPackageSource()
{
- return packageSource.ToPackageSource();
+ // HACK: Workaround a NuGet 3.4.3 bug where it double encrypts the password when
+ // it saves the NuGet.Config file. The PasswordText should hold the encrypted string
+ // but instead we use the plain text password so it is only encrypted once.
+ // https://github.com/NuGet/Home/issues/2647
+
+ return new PackageSource (Source, Name, IsEnabled) {
+ UserName = UserName,
+ PasswordText = Password,
+ ProtocolVersion = packageSource.ProtocolVersion
+ };
+ }
+
+ public NuGet.PackageSource GetNuGet2PackageSource ()
+ {
+ return new NuGet.PackageSource (Source, Name, IsEnabled) {
+ UserName = UserName,
+ Password = Password
+ };
}
- public string Name {
- get { return packageSource.Name; }
- set { packageSource.Name = value; }
- }
+ public string Name { get; set; }
- public string SourceUrl {
+ public string Source {
get { return packageSource.Source; }
set { packageSource.Source = value; }
}
@@ -67,10 +89,7 @@ namespace MonoDevelop.PackageManagement set { packageSource.UserName = value; }
}
- public string Password {
- get { return packageSource.Password; }
- set { packageSource.Password = value; }
- }
+ public string Password { get; set; }
public bool HasPassword ()
{
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModelChecker.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModelChecker.cs index 90587defb4..0273425aa9 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModelChecker.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageSourceViewModelChecker.cs @@ -72,7 +72,7 @@ namespace MonoDevelop.PackageManagement PackageSourceViewModelCheckedEventArgs CheckPackageSourceUrl (PackageSourceViewModel packageSource)
{
- if (IsHttpPackageSource (packageSource.SourceUrl)) {
+ if (IsHttpPackageSource (packageSource.Source)) {
return CheckHttpPackageSource (packageSource);
}
return CheckFileSystemPackageSource (packageSource);
@@ -86,7 +86,7 @@ namespace MonoDevelop.PackageManagement if (response.StatusCode == HttpStatusCode.OK) {
return new PackageSourceViewModelCheckedEventArgs (packageSource);
} else {
- LoggingService.LogInfo ("Status code {0} returned from package source url '{1}'", response.StatusCode, packageSource.SourceUrl);
+ LoggingService.LogInfo ("Status code {0} returned from package source url '{1}'", response.StatusCode, packageSource.Source);
return new PackageSourceViewModelCheckedEventArgs (packageSource, GettextCatalog.GetString ("Unreachable"));
}
}
@@ -112,7 +112,7 @@ namespace MonoDevelop.PackageManagement /// </summary>
HttpClient CreateHttpClient(PackageSourceViewModel packageSource)
{
- var httpClient = new HttpClient (new Uri (packageSource.SourceUrl));
+ var httpClient = new HttpClient (new Uri (packageSource.Source));
bool resetCredentials = true;
httpClient.SendingRequest += (sender, e) => {
@@ -128,7 +128,7 @@ namespace MonoDevelop.PackageManagement PackageSourceViewModelCheckedEventArgs CheckFileSystemPackageSource (PackageSourceViewModel packageSource)
{
- var dir = packageSource.SourceUrl; + var dir = packageSource.Source; if (dir.StartsWith ("file://", StringComparison.OrdinalIgnoreCase)) { dir = new Uri (dir).LocalPath; } @@ -177,7 +177,7 @@ namespace MonoDevelop.PackageManagement void LogPackageSourceException (PackageSourceViewModel packageSource, Exception ex)
{
- LoggingService.LogInfo (String.Format ("Package source '{0}' returned exception.", packageSource.SourceUrl), ex);
+ LoggingService.LogInfo (String.Format ("Package source '{0}' returned exception.", packageSource.Source), ex);
}
void OnPackageSourceChecked (object sender, ITask<PackageSourceViewModelCheckedEventArgs> task)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModel.cs deleted file mode 100644 index f99b967fa7..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModel.cs +++ /dev/null @@ -1,622 +0,0 @@ -//
-// PackageViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Runtime.Versioning;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageViewModel : ViewModelBase<PackageViewModel>
- {
- DelegateCommand addPackageCommand;
- DelegateCommand removePackageCommand;
- DelegateCommand managePackageCommand;
-
- PackageManagementSelectedProjects selectedProjects;
- IPackageManagementEvents packageManagementEvents;
- IPackageFromRepository package;
- IEnumerable<PackageOperation> packageOperations = new PackageOperation[0];
- PackageViewModelOperationLogger logger;
- IPackageActionRunner actionRunner;
- IPackageViewModelParent parent;
- string summary;
- List<PackageDependency> dependencies;
- bool isChecked;
-
- public PackageViewModel(
- IPackageViewModelParent parent,
- IPackageFromRepository package,
- PackageManagementSelectedProjects selectedProjects,
- IPackageManagementEvents packageManagementEvents,
- IPackageActionRunner actionRunner,
- ILogger logger)
- {
- this.parent = parent;
- this.package = package;
- this.selectedProjects = selectedProjects;
- this.packageManagementEvents = packageManagementEvents;
- this.actionRunner = actionRunner;
- this.logger = CreateLogger(logger);
-
- CreateCommands();
- }
-
- public IPackageViewModelParent GetParent()
- {
- return parent;
- }
-
- protected virtual PackageViewModelOperationLogger CreateLogger(ILogger logger)
- {
- return new PackageViewModelOperationLogger(logger, package);
- }
-
- void CreateCommands()
- {
- addPackageCommand = new DelegateCommand(param => AddPackage());
- removePackageCommand = new DelegateCommand(param => RemovePackage());
- managePackageCommand = new DelegateCommand(param => ManagePackage());
- }
-
- public ICommand AddPackageCommand {
- get { return addPackageCommand; }
- }
-
- public ICommand RemovePackageCommand {
- get { return removePackageCommand; }
- }
-
- public ICommand ManagePackageCommand {
- get { return managePackageCommand; }
- }
-
- public IPackage GetPackage()
- {
- return package;
- }
-
- public bool HasLicenseUrl {
- get { return LicenseUrl != null; }
- }
-
- public Uri LicenseUrl {
- get { return package.LicenseUrl; }
- }
-
- public bool HasProjectUrl {
- get { return ProjectUrl != null; }
- }
-
- public Uri ProjectUrl {
- get { return package.ProjectUrl; }
- }
-
- public bool HasReportAbuseUrl {
- get { return ReportAbuseUrl != null; }
- }
-
- public Uri ReportAbuseUrl {
- get { return package.ReportAbuseUrl; }
- }
-
- public bool IsAdded {
- get { return IsPackageInstalled(); }
- }
-
- bool IsPackageInstalled()
- {
- return selectedProjects.IsPackageInstalled(package);
- }
-
- public IEnumerable<PackageDependency> Dependencies {
- get {
- if (dependencies == null) {
- FrameworkName targetFramework = selectedProjects.GetTargetFramework ();
- dependencies = package
- .GetCompatiblePackageDependencies (targetFramework)
- .ToList ();
- }
- return dependencies;
- }
- }
-
- public bool HasDependencies {
- get { return Dependencies.Any (); }
- }
-
- public bool HasNoDependencies {
- get { return !HasDependencies; }
- }
-
- public IEnumerable<string> Authors {
- get { return package.Authors; }
- }
-
- public bool HasDownloadCount {
- get { return package.DownloadCount >= 0; }
- }
-
- public string Id {
- get { return package.Id; }
- }
-
- public string Name {
- get { return package.GetName(); }
- }
-
- public bool HasGalleryUrl {
- get { return GalleryUrl != null; }
- }
-
- public bool HasNoGalleryUrl {
- get { return !HasGalleryUrl; }
- }
-
- public Uri GalleryUrl {
- get { return package.GalleryUrl; }
- }
-
- public Uri IconUrl {
- get { return package.IconUrl; }
- }
-
- public bool HasIconUrl {
- get { return IconUrl != null; }
- }
-
- public string Summary {
- get {
- if (summary == null) {
- summary = StripNewLinesAndIndentation (package.SummaryOrDescription ());
- }
- return summary;
- }
- }
-
- string StripNewLinesAndIndentation (string text)
- {
- return PackageListViewTextFormatter.Format (text);
- }
-
- public SemanticVersion Version {
- get { return package.Version; }
- }
-
- public int DownloadCount {
- get { return package.DownloadCount; }
- }
-
- public string Description {
- get { return package.Description; }
- }
-
- public DateTimeOffset? LastPublished {
- get { return package.Published; }
- }
-
- public bool HasLastPublished {
- get { return package.Published.HasValue; }
- }
-
- public void AddPackage()
- {
- ClearReportedMessages();
- logger.LogAddingPackage();
-
- using (IDisposable operation = StartInstallOperation(package)) {
- TryInstallingPackage();
- }
-
- logger.LogAfterPackageOperationCompletes();
- }
-
- protected virtual IDisposable StartInstallOperation(IPackageFromRepository package)
- {
- return package.StartInstallOperation();
- }
-
- void ClearReportedMessages()
- {
- packageManagementEvents.OnPackageOperationsStarting();
- }
-
- void GetPackageOperations()
- {
- IPackageManagementProject project = GetSingleProjectSelected();
- project.Logger = logger;
- InstallPackageAction installAction = project.CreateInstallPackageAction();
- installAction.AllowPrereleaseVersions = parent.IncludePrerelease;
- packageOperations = project.GetInstallPackageOperations(package, installAction);
- }
-
- IPackageManagementProject GetSingleProjectSelected()
- {
- return selectedProjects.GetSingleProjectSelected(package.Repository);
- }
-
- bool CanInstallPackage()
- {
- IEnumerable<IPackage> packages = GetPackagesRequiringLicenseAcceptance();
- if (packages.Any()) {
- return packageManagementEvents.OnAcceptLicenses(packages);
- }
- return true;
- }
-
- IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance()
- {
- IList<IPackage> packagesToBeInstalled = GetPackagesToBeInstalled();
- return GetPackagesRequiringLicenseAcceptance(packagesToBeInstalled);
- }
-
- IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance(IList<IPackage> packagesToBeInstalled)
- {
- return packagesToBeInstalled.Where(package => PackageRequiresLicenseAcceptance(package));
- }
-
- IList<IPackage> GetPackagesToBeInstalled()
- {
- List<IPackage> packages = new List<IPackage>();
- foreach (PackageOperation operation in packageOperations) {
- if (operation.Action == PackageAction.Install) {
- packages.Add(operation.Package);
- }
- }
- return packages;
- }
-
- bool PackageRequiresLicenseAcceptance(IPackage package)
- {
- return package.RequireLicenseAcceptance && !IsPackageInstalledInSolution(package);
- }
-
- bool IsPackageInstalledInSolution(IPackage package)
- {
- return selectedProjects.IsPackageInstalledInSolution(package);
- }
-
- void TryInstallingPackage()
- {
- try {
- GetPackageOperations();
- if (CanInstallPackage()) {
- InstallPackage();
- }
- } catch (Exception ex) {
- ReportError(ex);
- logger.LogError(ex);
- }
- }
-
- void InstallPackage()
- {
- InstallPackage(packageOperations);
- OnPropertyChanged(model => model.IsAdded);
- }
-
- void InstallPackage(IEnumerable<PackageOperation> packageOperations)
- {
- var action = CreateInstallPackageAction () as ProcessPackageOperationsAction;
- action.Operations = packageOperations;
- actionRunner.Run(action);
- }
-
- public IPackageAction CreateInstallPackageAction ()
- {
- IPackageManagementProject project = GetSingleProjectSelected ();
- ProcessPackageOperationsAction action = CreateInstallPackageAction (project);
- action.AllowPrereleaseVersions = parent.IncludePrerelease;
- action.Package = package;
- return action;
- }
-
- protected virtual ProcessPackageOperationsAction CreateInstallPackageAction(
- IPackageManagementProject project)
- {
- return project.CreateInstallPackageAction();
- }
-
- void ReportError(Exception ex)
- {
- packageManagementEvents.OnPackageOperationError(ex);
- }
-
- public void RemovePackage()
- {
- ClearReportedMessages();
- logger.LogRemovingPackage();
- TryUninstallingPackage();
- logger.LogAfterPackageOperationCompletes();
-
- OnPropertyChanged(model => model.IsAdded);
- }
-
- void LogRemovingPackage()
- {
- logger.LogRemovingPackage();
- }
-
- void TryUninstallingPackage()
- {
- try {
- IPackageManagementProject project = GetSingleProjectSelected();
- UninstallPackageAction action = project.CreateUninstallPackageAction();
- action.Package = package;
- actionRunner.Run(action);
- } catch (Exception ex) {
- ReportError(ex);
- logger.LogError(ex);
- }
- }
-
- public bool IsManaged {
- get {
- if (selectedProjects.HasMultipleProjects()) {
- return true;
- }
- return !selectedProjects.HasSingleProjectSelected();
- }
- }
-
- public void ManagePackage()
- {
- List<IPackageManagementSelectedProject> projects = GetSelectedProjectsForPackage();
- if (packageManagementEvents.OnSelectProjects(projects)) {
- ManagePackagesForSelectedProjects(projects);
- }
- }
-
- List<IPackageManagementSelectedProject> GetSelectedProjectsForPackage()
- {
- return selectedProjects.GetProjects(package).ToList();
- }
-
- public void ManagePackagesForSelectedProjects(IEnumerable<IPackageManagementSelectedProject> projects)
- {
- ManagePackagesForSelectedProjects(projects.ToList());
- }
-
- void ManagePackagesForSelectedProjects(IList<IPackageManagementSelectedProject> projects)
- {
- ClearReportedMessages();
- logger.LogManagingPackage();
-
- using (IDisposable operation = StartInstallOperation(package)) {
- TryInstallingPackagesForSelectedProjects(projects);
- }
-
- logger.LogAfterPackageOperationCompletes();
- OnPropertyChanged(model => model.IsAdded);
- }
-
- void TryInstallingPackagesForSelectedProjects(IList<IPackageManagementSelectedProject> projects)
- {
- try {
- if (AnyProjectsSelected(projects)) {
- InstallPackagesForSelectedProjects(projects);
- }
- } catch (Exception ex) {
- ReportError(ex);
- logger.LogError(ex);
- }
- }
-
- protected virtual bool AnyProjectsSelected(IList<IPackageManagementSelectedProject> projects)
- {
- return projects.Any(project => project.IsSelected);
- }
-
- void InstallPackagesForSelectedProjects(IList<IPackageManagementSelectedProject> projects)
- {
- if (CanInstallPackage(projects)) {
- IList<ProcessPackageAction> actions = GetProcessPackageActionsForSelectedProjects(projects);
- RunActionsIfAnyExist(actions);
- }
- }
-
- public virtual IList<ProcessPackageAction> GetProcessPackageActionsForSelectedProjects(
- IList<IPackageManagementSelectedProject> selectedProjects)
- {
- var actions = new List<ProcessPackageAction>();
- foreach (IPackageManagementSelectedProject selectedProject in selectedProjects) {
- if (selectedProject.IsSelected) {
- ProcessPackageAction action = CreateInstallPackageAction(selectedProject);
- action.AllowPrereleaseVersions = parent.IncludePrerelease;
- actions.Add(action);
- }
- }
- return actions;
- }
-
- bool CanInstallPackage(IList<IPackageManagementSelectedProject> projects)
- {
- IPackageManagementSelectedProject project = projects.FirstOrDefault();
- if (project != null) {
- return CanInstallPackage(project);
- }
- return false;
- }
-
- bool CanInstallPackage(IPackageManagementSelectedProject selectedProject)
- {
- IEnumerable<IPackage> licensedPackages = GetPackagesRequiringLicenseAcceptance(selectedProject);
- if (licensedPackages.Any()) {
- return packageManagementEvents.OnAcceptLicenses(licensedPackages);
- }
- return true;
- }
-
- protected ProcessPackageAction CreateInstallPackageAction(IPackageManagementSelectedProject selectedProject)
- {
- IPackageManagementProject project = selectedProject.Project;
- project.Logger = logger;
-
- ProcessPackageOperationsAction action = CreateInstallPackageAction(project);
- action.Package = package;
- return action;
- }
-
- protected ProcessPackageAction CreateUninstallPackageAction(IPackageManagementSelectedProject selectedProject)
- {
- IPackageManagementProject project = selectedProject.Project;
- project.Logger = logger;
-
- ProcessPackageAction action = project.CreateUninstallPackageAction();
- action.Package = package;
- return action;
- }
-
- void RunActionsIfAnyExist(IList<ProcessPackageAction> actions)
- {
- if (actions.Any()) {
- actionRunner.Run(actions);
- }
- }
-
- IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance(IPackageManagementSelectedProject selectedProject)
- {
- IPackageManagementProject project = selectedProject.Project;
- project.Logger = logger;
- InstallPackageAction installAction = project.CreateInstallPackageAction();
- installAction.AllowPrereleaseVersions = parent.IncludePrerelease;
- IEnumerable<PackageOperation> operations = project.GetInstallPackageOperations(package, installAction);
- return GetPackagesRequiringLicenseAcceptance(operations);
- }
-
- IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance(IEnumerable<PackageOperation> operations)
- {
- foreach (PackageOperation operation in operations) {
- if (PackageOperationRequiresLicenseAcceptance(operation)) {
- yield return operation.Package;
- }
- }
- }
-
- bool PackageOperationRequiresLicenseAcceptance(PackageOperation operation)
- {
- return
- (operation.Action == PackageAction.Install) &&
- operation.Package.RequireLicenseAcceptance &&
- !IsPackageInstalledInSolution(operation.Package);
- }
-
- static readonly string DisplayTextMarkupFormat = "<span weight='bold'>{0}</span>\n{1}";
-
- public string GetDisplayTextMarkup ()
- {
- return MarkupString.Format (DisplayTextMarkupFormat, Name, Summary);
- }
-
- public string GetAuthors()
- {
- return String.Join (", ", Authors);
- }
-
- public string GetLastPublishedDisplayText()
- {
- if (HasLastPublished) {
- return LastPublished.Value.Date.ToShortDateString ();
- }
- return String.Empty;
- }
-
- public string GetDownloadCountOrVersionDisplayText ()
- {
- if (ShowVersionInsteadOfDownloadCount) {
- return Version.ToString ();
- }
-
- return GetDownloadCountDisplayText ();
- }
-
- public string GetDownloadCountDisplayText ()
- {
- if (HasDownloadCount) {
- return DownloadCount.ToString ("N0");
- }
- return String.Empty;
- }
-
- public string GetPackageDependenciesDisplayText ()
- {
- var displayText = new StringBuilder ();
- foreach (PackageDependency dependency in Dependencies) {
- displayText.AppendLine (dependency.ToString ());
- }
- return displayText.ToString ();
- }
-
- public string GetNameMarkup ()
- {
- return GetBoldText (Name);
- }
-
- static string GetBoldText (string text)
- {
- return String.Format ("<b>{0}</b>", text);
- }
-
- public bool IsOlderPackageInstalled ()
- {
- return selectedProjects.HasOlderPackageInstalled (package);
- }
-
- public bool IsChecked {
- get { return isChecked; }
- set {
- if (value != isChecked) {
- isChecked = value;
- parent.OnPackageCheckedChanged (this);
- }
- }
- }
-
- public bool ShowVersionInsteadOfDownloadCount { get; set; }
-
- public override bool Equals (object obj)
- {
- var other = obj as PackageViewModel;
- if (other == null)
- return false;
-
- var packageName = new PackageName (package.Id, package.Version);
- var otherPackageName = new PackageName (other.package.Id, other.package.Version);
- return packageName.Equals (otherPackageName);
- }
-
- public override int GetHashCode ()
- {
- return package.ToString ().GetHashCode ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModelFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModelFactory.cs deleted file mode 100644 index cc88824b81..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModelFactory.cs +++ /dev/null @@ -1,73 +0,0 @@ -//
-// PackageViewModelFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageViewModelFactory : IPackageViewModelFactory
- {
- public PackageViewModelFactory(IPackageViewModelFactory packageViewModelFactory)
- : this(
- packageViewModelFactory.Solution,
- packageViewModelFactory.PackageManagementEvents,
- packageViewModelFactory.PackageActionRunner)
- {
- }
-
- public PackageViewModelFactory(
- IPackageManagementSolution solution,
- IPackageManagementEvents packageManagementEvents,
- IPackageActionRunner actionRunner)
- {
- this.Solution = solution;
- this.SelectedProjects = new PackageManagementSelectedProjects(solution);
- this.PackageManagementEvents = packageManagementEvents;
- this.PackageActionRunner = actionRunner;
- this.Logger = new PackageManagementLogger(packageManagementEvents);
- }
-
- public virtual PackageViewModel CreatePackageViewModel(IPackageViewModelParent parent, IPackageFromRepository package)
- {
- return new PackageViewModel(
- parent,
- package,
- SelectedProjects,
- PackageManagementEvents,
- PackageActionRunner,
- Logger);
- }
-
- public IPackageManagementSolution Solution { get; private set; }
- public PackageManagementSelectedProjects SelectedProjects { get; protected set; }
- public IPackageManagementEvents PackageManagementEvents { get; private set; }
- public ILogger Logger { get; private set; }
- public IPackageActionRunner PackageActionRunner { get; private set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModelOperationLogger.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModelOperationLogger.cs deleted file mode 100644 index 1eb6775043..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackageViewModelOperationLogger.cs +++ /dev/null @@ -1,125 +0,0 @@ -//
-// PackageViewModelOperationLogger.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackageViewModelOperationLogger : ILogger
- {
- ILogger logger;
- IPackage package;
-
- public PackageViewModelOperationLogger(ILogger logger, IPackage package)
- {
- this.logger = logger;
- this.package = package;
-
- GetMessageFormats();
- }
-
- void GetMessageFormats()
- {
- AddingPackageMessageFormat = GettextCatalog.GetString ("Installing...{0}");
- RemovingPackageMessageFormat = GettextCatalog.GetString ("Uninstalling...{0}");
- ManagingPackageMessageFormat = GettextCatalog.GetString ("Managing...{0}");
- }
-
- public string AddingPackageMessageFormat { get; set; }
- public string RemovingPackageMessageFormat { get; set; }
- public string ManagingPackageMessageFormat { get; set; }
-
- public void Log(MessageLevel level, string message, params object[] args)
- {
- logger.Log(level, message, args);
- }
-
- public void LogInformation(string message)
- {
- Log(MessageLevel.Info, message);
- }
-
- public void LogAfterPackageOperationCompletes()
- {
- LogEndMarkerLine();
- LogEmptyLine();
- }
-
- void LogEndMarkerLine()
- {
- string message = new String('=', 30);
- LogInformation(message);
- }
-
- void LogEmptyLine()
- {
- LogInformation(String.Empty);
- }
-
- public void LogAddingPackage()
- {
- string message = GetFormattedStartPackageOperationMessage(AddingPackageMessageFormat);
- LogInformation(message);
- }
-
- string GetFormattedStartPackageOperationMessage(string format)
- {
- string message = String.Format(format, package.ToString());
- return GetStartPackageOperationMessage(message);
- }
-
- string GetStartPackageOperationMessage(string message)
- {
- return String.Format("------- {0} -------", message);
- }
-
- public void LogRemovingPackage()
- {
- string message = GetFormattedStartPackageOperationMessage(RemovingPackageMessageFormat);
- LogInformation(message);
- }
-
- public void LogError(Exception ex)
- {
- LogInformation(ex.ToString());
- }
-
- public void LogManagingPackage()
- {
- string message = GetFormattedStartPackageOperationMessage(ManagingPackageMessageFormat);
- LogInformation(message);
- }
-
- public FileConflictResolution ResolveFileConflict(string message)
- {
- return logger.ResolveFileConflict(message);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesForSelectedPageResult.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesForSelectedPageResult.cs deleted file mode 100644 index 56d728a7d3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesForSelectedPageResult.cs +++ /dev/null @@ -1,54 +0,0 @@ -//
-// PackagesForSelectedPageResult.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackagesForSelectedPageResult
- {
- public PackagesForSelectedPageResult(IEnumerable<IPackage> packages, PackagesForSelectedPageQuery query)
- {
- this.Packages = packages;
- this.TotalPackagesOnPage = packages.Count();
- this.TotalPackages = query.TotalPackages;
- this.AllPackages = query.AllPackages;
- this.Query = query;
- }
-
- public PackagesForSelectedPageQuery Query { get; set; }
- public IEnumerable<IPackage> Packages { get; set; }
- public int TotalPackagesOnPage { get; set; }
- public int TotalPackages { get; set; }
- public IEnumerable<IPackage> AllPackages { get; set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesRequiringLicenseAcceptance.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesRequiringLicenseAcceptance.cs deleted file mode 100644 index 342f05ef09..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesRequiringLicenseAcceptance.cs +++ /dev/null @@ -1,77 +0,0 @@ -//
-// PackagesRequiringLicenseAcceptance.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class PackagesRequiringLicenseAcceptance
- {
- IPackageManagementProject project;
-
- public PackagesRequiringLicenseAcceptance (IPackageManagementProject project)
- {
- this.project = project;
- }
-
- public IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance (IEnumerable<IPackageAction> actions)
- {
- var packages = new List <IPackage> ();
- foreach (IPackageAction action in actions) {
- packages.AddRange (GetPackagesRequiringLicenseAcceptance (action));
- }
- return packages.Distinct<IPackage> (PackageEqualityComparer.IdAndVersion);
- }
-
- IEnumerable<IPackage> GetPackagesRequiringLicenseAcceptance (IPackageAction action)
- {
- var processPackageActions = action as ProcessPackageOperationsAction;
- if (processPackageActions == null) {
- return new IPackage [0];
- }
-
- return processPackageActions.GetInstallOperations ()
- .Select (operation => operation.Package)
- .Where (package => PackageRequiresLicenseAcceptance (package))
- .ToList ();
- }
-
- bool PackageRequiresLicenseAcceptance (IPackage package)
- {
- return package.RequireLicenseAcceptance && !IsPackageInstalled (package);
- }
-
- bool IsPackageInstalled(IPackage package)
- {
- return project.IsPackageInstalled (package);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs deleted file mode 100644 index 87115a0be2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModel.cs +++ /dev/null @@ -1,547 +0,0 @@ -//
-// PackagesViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Collections.Specialized;
-using System.Linq;
-using System.Text;
-
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal abstract class PackagesViewModel : ViewModelBase<PackagesViewModel>, IDisposable, IPackageViewModelParent
- {
- Pages pages = new Pages();
-
- IRegisteredPackageRepositories registeredPackageRepositories;
- IPackageViewModelFactory packageViewModelFactory;
- ITaskFactory taskFactory;
- IEnumerable<IPackage> allPackages;
- ITask<PackagesForSelectedPageResult> task;
- bool includePrerelease;
- PackagesForSelectedPageQuery packagesForSelectedPageQuery;
- bool ignorePackageCheckedChanged;
-
- public PackagesViewModel(
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageViewModelFactory packageViewModelFactory,
- ITaskFactory taskFactory)
- {
- this.registeredPackageRepositories = registeredPackageRepositories;
- this.packageViewModelFactory = packageViewModelFactory;
- this.taskFactory = taskFactory;
-
- PackageViewModels = new ObservableCollection<PackageViewModel>();
- CheckedPackageViewModels = new ObservableCollection <PackageViewModel> ();
- ErrorMessage = String.Empty;
- ClearPackagesOnPaging = true;
-
- CreateCommands();
- }
-
- void CreateCommands()
- {
- ShowNextPageCommand = new DelegateCommand(param => ShowNextPage());
- ShowPreviousPageCommand = new DelegateCommand(param => ShowPreviousPage());
- ShowPageCommand = new DelegateCommand(param => ExecuteShowPageCommand(param));
- SearchCommand = new DelegateCommand(param => Search());
- UpdateAllPackagesCommand = new DelegateCommand(param => UpdateAllPackages());
- }
-
- public ICommand ShowNextPageCommand { get; private set; }
- public ICommand ShowPreviousPageCommand { get; private set; }
- public ICommand ShowPageCommand { get; private set; }
- public ICommand SearchCommand { get; private set; }
- public ICommand UpdateAllPackagesCommand { get; private set; }
-
- public void Dispose()
- {
- OnDispose();
- CancelReadPackagesTask ();
- IsDisposed = true;
- }
-
- protected virtual void OnDispose()
- {
- }
-
- public bool IsDisposed { get; private set; }
-
- public bool HasError { get; private set; }
- public string ErrorMessage { get; private set; }
-
- public ObservableCollection<PackageViewModel> PackageViewModels { get; set; }
-
- public IRegisteredPackageRepositories RegisteredPackageRepositories {
- get { return registeredPackageRepositories; }
- }
-
- public bool IsReadingPackages { get; private set; }
-
- public void ReadPackages()
- {
- if (SelectedPackageSource == null) {
- return;
- }
-
- allPackages = null;
- pages.SelectedPageNumber = 1;
- IsLoadingNextPage = false;
- UpdateRepositoryBeforeReadPackagesTaskStarts();
- StartReadPackagesTask();
- }
-
- void StartReadPackagesTask(bool clearPackages = true)
- {
- IsReadingPackages = true;
- ClearError ();
- if (clearPackages) {
- ClearPackages ();
- }
- CancelReadPackagesTask();
- CreateReadPackagesTask();
- task.Start();
- }
-
- void ClearError ()
- {
- HasError = false;
- ErrorMessage = String.Empty;
- }
-
- protected virtual void UpdateRepositoryBeforeReadPackagesTaskStarts()
- {
- }
-
- void CancelReadPackagesTask()
- {
- if (task != null) {
- task.Cancel();
- }
- }
-
- void CreateReadPackagesTask()
- {
- var query = new PackagesForSelectedPageQuery (this, allPackages, SearchTerms);
- packagesForSelectedPageQuery = query;
-
- task = taskFactory.CreateTask(
- () => GetPackagesForSelectedPageResult(query),
- OnPackagesReadForSelectedPage);
- }
-
- PackagesForSelectedPageResult GetPackagesForSelectedPageResult(PackagesForSelectedPageQuery query)
- {
- IEnumerable<IPackage> packages = GetPackagesForSelectedPage(query);
- return new PackagesForSelectedPageResult(packages, query);
- }
-
- void OnPackagesReadForSelectedPage(ITask<PackagesForSelectedPageResult> task)
- {
- IsReadingPackages = false;
- IsLoadingNextPage = false;
- if (task.IsFaulted) {
- SaveError(task.Exception);
- } else if (task.IsCancelled || !IsCurrentQuery(task.Result)) {
- // Ignore.
- return;
- } else {
- SaveAnyWarnings ();
- UpdatePackagesForSelectedPage(task.Result);
- }
- base.OnPropertyChanged(null);
- }
-
- bool IsCurrentQuery(PackagesForSelectedPageResult result)
- {
- return packagesForSelectedPageQuery == result.Query;
- }
-
- void SaveError(AggregateException ex)
- {
- HasError = true;
- ErrorMessage = GetErrorMessage(ex);
- LoggingService.LogInfo("PackagesViewModel error", ex);
- }
-
- string GetErrorMessage(AggregateException ex)
- {
- var errorMessage = new AggregateExceptionErrorMessage(ex);
- return errorMessage.ToString();
- }
-
- void SaveAnyWarnings ()
- {
- string warning = GetWarningMessage ();
- if (!String.IsNullOrEmpty (warning)) {
- HasError = true;
- ErrorMessage = warning;
- }
- }
-
- protected virtual string GetWarningMessage ()
- {
- return String.Empty;
- }
-
- void UpdatePackagesForSelectedPage(PackagesForSelectedPageResult result)
- {
- pages.TotalItems = result.TotalPackages;
- pages.TotalItemsOnSelectedPage = result.TotalPackagesOnPage;
- TotalItems = result.TotalPackages;
- allPackages = result.AllPackages;
-
- UpdatePackageViewModels (PrioritizePackages (result), result.Query.SearchCriteria);
- }
-
- IEnumerable<IPackage> PrioritizePackages (PackagesForSelectedPageResult result)
- {
- return PrioritizePackages (result.Packages, result.Query.SearchCriteria);
- }
-
- protected virtual IEnumerable<IPackage> PrioritizePackages (IEnumerable<IPackage> packages, PackageSearchCriteria searchCriteria)
- {
- return packages;
- }
-
- IEnumerable<IPackage> GetPackagesForSelectedPage(PackagesForSelectedPageQuery query)
- {
- IEnumerable<IPackage> filteredPackages = GetFilteredPackagesBeforePagingResults(query);
- return GetPackagesForSelectedPage(filteredPackages, query);
- }
-
- IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults(PackagesForSelectedPageQuery query)
- {
- if (query.AllPackages == null) {
- IQueryable<IPackage> packages = GetPackagesFromPackageSource(query.SearchCriteria);
- query.TotalPackages = packages.Count();
- query.AllPackages = GetFilteredPackagesBeforePagingResults (packages, query.SearchCriteria);
- }
- return query.AllPackages;
- }
-
- /// <summary>
- /// Returns the queryable object that will be used to query the NuGet online feed.
- /// </summary>
- public IQueryable<IPackage> GetPackagesFromPackageSource()
- {
- return GetPackagesFromPackageSource(new PackageSearchCriteria (SearchTerms));
- }
-
- IQueryable<IPackage> GetPackagesFromPackageSource (PackageSearchCriteria search)
- {
- IQueryable<IPackage> packages = GetPackages (search);
- return OrderPackages (packages, search);
- }
-
- protected virtual IQueryable<IPackage> OrderPackages (IQueryable<IPackage> packages, PackageSearchCriteria search)
- {
- return packages
- .OrderBy(package => package.Id);
- }
-
- IEnumerable<IPackage> GetPackagesForSelectedPage(IEnumerable<IPackage> allPackages, PackagesForSelectedPageQuery query)
- {
- return allPackages
- .Skip(query.Skip)
- .Take(query.Take);
- }
-
- /// <summary>
- /// Returns all the packages.
- /// </summary>
- protected virtual IQueryable<IPackage> GetAllPackages()
- {
- return null;
- }
-
- /// <summary>
- /// Returns packages filtered by search criteria.
- /// </summary>
- protected virtual IQueryable<IPackage> GetPackages (PackageSearchCriteria search)
- {
- return null;
- }
-
- /// <summary>
- /// Allows filtering of the packages before paging the results. Call base class method
- /// to run default filtering.
- /// </summary>
- protected virtual IEnumerable<IPackage> GetFilteredPackagesBeforePagingResults (IQueryable<IPackage> allPackages, PackageSearchCriteria search)
- {
- IEnumerable<IPackage> bufferedPackages = GetBufferedPackages(allPackages);
- return bufferedPackages;
- }
-
- IEnumerable<IPackage> GetBufferedPackages(IQueryable<IPackage> allPackages)
- {
- return allPackages.AsBufferedEnumerable(30);
- }
-
- void UpdatePackageViewModels (IEnumerable<IPackage> packages, PackageSearchCriteria search)
- {
- IEnumerable<PackageViewModel> currentViewModels = ConvertToPackageViewModels (packages, search);
- UpdatePackageViewModels(currentViewModels);
- }
-
- void UpdatePackageViewModels(IEnumerable<PackageViewModel> newPackageViewModels)
- {
- if (ClearPackagesOnPaging) {
- ClearPackages ();
- }
- PackageViewModels.AddRange(newPackageViewModels);
- }
-
- void ClearPackages()
- {
- PackageViewModels.Clear();
- }
-
- public IEnumerable<PackageViewModel> ConvertToPackageViewModels (IEnumerable<IPackage> packages, PackageSearchCriteria search)
- {
- foreach (IPackage package in packages) {
- PackageViewModel packageViewModel = CreatePackageViewModel (package, search);
- CheckNewPackageViewModelIfPreviouslyChecked (packageViewModel);
- yield return packageViewModel;
- }
- }
-
- protected virtual PackageViewModel CreatePackageViewModel (IPackage package, PackageSearchCriteria search)
- {
- PackageFromRepository packageFromRepository = CreatePackageFromRepository (package);
- return packageViewModelFactory.CreatePackageViewModel(this, packageFromRepository);
- }
-
- PackageFromRepository CreatePackageFromRepository (IPackage package)
- {
- var packageFromRepository = package as PackageFromRepository;
- if (packageFromRepository != null) {
- return packageFromRepository;
- }
-
- var repository = registeredPackageRepositories.ActiveRepository;
- return new PackageFromRepository(package, repository);
- }
-
- public int SelectedPageNumber {
- get { return pages.SelectedPageNumber; }
- set {
- if (pages.SelectedPageNumber != value) {
- pages.SelectedPageNumber = value;
- IsLoadingNextPage = true;
- StartReadPackagesTask(ClearPackagesOnPaging);
- base.OnPropertyChanged(null);
- }
- }
- }
-
- public int PageSize {
- get { return pages.PageSize; }
- set { pages.PageSize = value; }
- }
-
- public int ItemsBeforeFirstPage {
- get { return pages.ItemsBeforeFirstPage; }
- }
-
- public bool IsPaged {
- get { return pages.IsPaged; }
- }
-
- public ObservableCollection<Page> Pages {
- get { return pages; }
- }
-
- public bool HasPreviousPage {
- get { return pages.HasPreviousPage; }
- }
-
- public bool HasNextPage {
- get { return pages.HasNextPage; }
- }
-
- public int MaximumSelectablePages {
- get { return pages.MaximumSelectablePages; }
- set { pages.MaximumSelectablePages = value; }
- }
-
- public int TotalItems { get; private set; }
-
- public void ShowNextPage()
- {
- SelectedPageNumber += 1;
- }
-
- public void ShowPreviousPage()
- {
- SelectedPageNumber -= 1;
- }
-
- void ExecuteShowPageCommand(object param)
- {
- int pageNumber = (int)param;
- ShowPage(pageNumber);
- }
-
- public void ShowPage(int pageNumber)
- {
- SelectedPageNumber = pageNumber;
- }
-
- public bool IsSearchable { get; set; }
-
- public string SearchTerms { get; set; }
-
- public void Search()
- {
- ReadPackages();
- OnPropertyChanged(null);
- }
-
- public bool ShowPackageSources { get; set; }
-
- public IEnumerable<PackageSource> PackageSources {
- get {
- if (registeredPackageRepositories.PackageSources.HasMultipleEnabledPackageSources) {
- yield return RegisteredPackageSourceSettings.AggregatePackageSource;
- }
- foreach (PackageSource packageSource in registeredPackageRepositories.PackageSources.GetEnabledPackageSources()) {
- yield return packageSource;
- }
- }
- }
-
- public PackageSource SelectedPackageSource {
- get { return registeredPackageRepositories.ActivePackageSource; }
- set {
- if (registeredPackageRepositories.ActivePackageSource != value) {
- registeredPackageRepositories.ActivePackageSource = value;
- ReadPackages();
- OnPropertyChanged(null);
- }
- }
- }
-
- public bool ShowUpdateAllPackages { get; set; }
-
- public bool IsUpdateAllPackagesEnabled {
- get {
- return ShowUpdateAllPackages && (TotalItems > 1);
- }
- }
-
- void UpdateAllPackages()
- {
- try {
- packageViewModelFactory.PackageManagementEvents.OnPackageOperationsStarting();
- TryUpdatingAllPackages();
- } catch (Exception ex) {
- ReportError(ex);
- LogError(ex);
- }
- }
-
- void LogError(Exception ex)
- {
- packageViewModelFactory
- .Logger
- .Log(MessageLevel.Error, ex.ToString());
- }
-
- void ReportError(Exception ex)
- {
- packageViewModelFactory
- .PackageManagementEvents
- .OnPackageOperationError(ex);
- }
-
- protected virtual void TryUpdatingAllPackages()
- {
- }
-
- protected IPackageActionRunner ActionRunner {
- get { return packageViewModelFactory.PackageActionRunner; }
- }
-
- public bool IncludePrerelease {
- get { return includePrerelease; }
- set {
- if (includePrerelease != value) {
- includePrerelease = value;
- ReadPackages();
- OnPropertyChanged(null);
- }
- }
- }
-
- public bool ShowPrerelease { get; set; }
- public bool ClearPackagesOnPaging { get; set; }
- public bool IsLoadingNextPage { get; private set; }
-
- public ObservableCollection<PackageViewModel> CheckedPackageViewModels { get; private set; }
-
- public void OnPackageCheckedChanged (PackageViewModel packageViewModel)
- {
- if (ignorePackageCheckedChanged)
- return;
-
- if (packageViewModel.IsChecked) {
- UncheckExistingCheckedPackageWithDifferentVersion (packageViewModel);
- CheckedPackageViewModels.Add (packageViewModel);
- } else {
- CheckedPackageViewModels.Remove (packageViewModel);
- }
- }
-
- void CheckNewPackageViewModelIfPreviouslyChecked (PackageViewModel packageViewModel)
- {
- ignorePackageCheckedChanged = true;
- try {
- packageViewModel.IsChecked = CheckedPackageViewModels.Contains (packageViewModel);
- } finally {
- ignorePackageCheckedChanged = false;
- }
- }
-
- void UncheckExistingCheckedPackageWithDifferentVersion (PackageViewModel packageViewModel)
- {
- PackageViewModel existingPackageViewModel = CheckedPackageViewModels
- .FirstOrDefault (item => item.Id == packageViewModel.Id);
-
- if (existingPackageViewModel != null) {
- CheckedPackageViewModels.Remove (existingPackageViewModel);
- existingPackageViewModel.IsChecked = false;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModels.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModels.cs deleted file mode 100644 index 78137341f1..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesViewModels.cs +++ /dev/null @@ -1,74 +0,0 @@ -//
-// PackagesViewModels.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal class PackagesViewModels : IDisposable
- {
- public PackagesViewModels(
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
- IThreadSafePackageManagementEvents packageManagementEvents,
- IPackageActionRunner actionRunner,
- ITaskFactory taskFactory)
- {
- var packageViewModelFactory = new PackageViewModelFactory(solution, packageManagementEvents, actionRunner);
- //var updatedPackageViewModelFactory = new UpdatedPackageViewModelFactory(packageViewModelFactory);
- //var installedPackageViewModelFactory = new InstalledPackageViewModelFactory(packageViewModelFactory);
-
- IRecentPackageRepository recentPackageRepository = PackageManagementServices.RecentPackageRepository;
- AvailablePackagesViewModel = new AvailablePackagesViewModel (solution, registeredPackageRepositories, recentPackageRepository, packageViewModelFactory, taskFactory);
- //InstalledPackagesViewModel = new InstalledPackagesViewModel(solution, packageManagementEvents, registeredPackageRepositories, installedPackageViewModelFactory, taskFactory);
- //UpdatedPackagesViewModel = new UpdatedPackagesViewModel(solution, registeredPackageRepositories, updatedPackageViewModelFactory, taskFactory);
- //RecentPackagesViewModel = new RecentPackagesViewModel(packageManagementEvents, registeredPackageRepositories, packageViewModelFactory, taskFactory);
- }
-
- public AvailablePackagesViewModel AvailablePackagesViewModel { get; private set; }
- public InstalledPackagesViewModel InstalledPackagesViewModel { get; private set; }
- public RecentPackagesViewModel RecentPackagesViewModel { get; private set; }
- public UpdatedPackagesViewModel UpdatedPackagesViewModel { get; private set; }
-
- public void ReadPackages()
- {
- AvailablePackagesViewModel.ReadPackages();
- //InstalledPackagesViewModel.ReadPackages();
- //UpdatedPackagesViewModel.ReadPackages();
- //RecentPackagesViewModel.ReadPackages();
- }
-
- public void Dispose()
- {
- AvailablePackagesViewModel.Dispose();
- //InstalledPackagesViewModel.Dispose();
- //RecentPackagesViewModel.Dispose();
- //UpdatedPackagesViewModel.Dispose();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Page.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Page.cs deleted file mode 100644 index 1ac0dad324..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Page.cs +++ /dev/null @@ -1,43 +0,0 @@ -//
-// Page.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal class Page
- {
- public int Number { get; set; }
- public bool IsSelected { get; set; }
-
- public override string ToString()
- {
- return String.Format("[Page] Number={0}, IsSelected={1}", Number, IsSelected);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Pages.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Pages.cs deleted file mode 100644 index aa531638e1..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Pages.cs +++ /dev/null @@ -1,180 +0,0 @@ -//
-// Pages.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.ObjectModel;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class Pages : ObservableCollection<Page>
- {
- public const int DefaultPageSize = 29;
- public const int DefaultMaximumSelectablePages = 5;
-
- int pageSize = DefaultPageSize;
- int selectedPageNumber = 1;
- int maximumSelectablePages = DefaultMaximumSelectablePages;
- int totalItems = 0;
- int itemsOnSelectedPage = 0;
-
- public int TotalItems {
- get { return totalItems; }
- set {
- if (totalItems != value) {
- totalItems = value;
- UpdatePages();
- }
- }
- }
-
- public int SelectedPageNumber {
- get { return selectedPageNumber; }
- set {
- if (selectedPageNumber != value) {
- selectedPageNumber = value;
- UpdatePages();
- }
- }
- }
-
- public int MaximumSelectablePages {
- get { return maximumSelectablePages; }
- set {
- if (maximumSelectablePages != value) {
- maximumSelectablePages = value;
- UpdatePages();
- }
- }
- }
-
- public int ItemsBeforeFirstPage {
- get {
- return (selectedPageNumber - 1) * pageSize;
- }
- }
-
- public bool IsPaged {
- get { return totalItems > pageSize; }
- }
-
- public bool HasPreviousPage {
- get { return IsPaged && !IsFirstPageSelected; }
- }
-
- bool IsFirstPageSelected {
- get { return selectedPageNumber == 1; }
- }
-
- public bool HasNextPage {
- get { return IsPaged && !IsLastPageSelected; }
- }
-
- bool IsLastPageSelected {
- get { return selectedPageNumber == TotalPages; }
- }
-
- public int TotalPages {
- get { return (totalItems + pageSize - 1) / pageSize; }
- }
-
- public int PageSize {
- get { return pageSize; }
- set {
- if (pageSize != value) {
- pageSize = value;
- UpdatePages();
- }
- }
- }
-
- void UpdatePages()
- {
- Clear();
-
- int startPage = GetStartPage();
- for (int pageNumber = startPage; pageNumber <= TotalPages; ++pageNumber) {
- if (Count >= maximumSelectablePages) {
- break;
- }
- Page page = CreatePage(pageNumber);
- Add(page);
- }
- }
-
- int GetStartPage()
- {
- // Less pages than can be selected?
- int totalPages = TotalPages;
- if (totalPages <= maximumSelectablePages) {
- return 1;
- }
-
- // First choice for start page.
- int startPage = selectedPageNumber - (maximumSelectablePages / 2);
- if (startPage <= 0) {
- return 1;
- }
-
- // Do we have enough pages?
- int totalPagesBasedOnStartPage = totalPages - startPage + 1;
- if (totalPagesBasedOnStartPage >= maximumSelectablePages) {
- return startPage;
- }
-
- // Ensure we have enough pages.
- startPage -= maximumSelectablePages - totalPagesBasedOnStartPage;
- if (startPage > 0) {
- return startPage;
- }
- return 1;
- }
-
- Page CreatePage(int pageNumber)
- {
- var page = new Page();
- page.Number = pageNumber;
- page.IsSelected = IsSelectedPage(pageNumber);
- return page;
- }
-
- bool IsSelectedPage(int pageNumber)
- {
- return pageNumber == selectedPageNumber;
- }
-
- public int TotalItemsOnSelectedPage {
- get { return itemsOnSelectedPage; }
- set {
- itemsOnSelectedPage = value;
- if (itemsOnSelectedPage < pageSize) {
- TotalItems = (selectedPageNumber - 1) * pageSize + itemsOnSelectedPage;
- }
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ParentPackageOperationEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ParentPackageOperationEventArgs.cs deleted file mode 100644 index f48019dfd5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ParentPackageOperationEventArgs.cs +++ /dev/null @@ -1,56 +0,0 @@ -//
-// ParentPackageOperationEventArgs.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ParentPackageOperationEventArgs : EventArgs
- {
- public ParentPackageOperationEventArgs(IPackage package, IPackageManagementProject project)
- : this (package, project, new PackageOperation [0])
- {
- }
-
- public ParentPackageOperationEventArgs (
- IPackage package,
- IPackageManagementProject project,
- IEnumerable<PackageOperation> operations)
- {
- Package = package;
- Project = project;
- Operations = operations;
- }
-
- public IPackage Package { get; private set; }
- public IPackageManagementProject Project { get; private set; }
- public IEnumerable<PackageOperation> Operations { get; private set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ParentPackagesOperationEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ParentPackagesOperationEventArgs.cs deleted file mode 100644 index 2fc09a470e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ParentPackagesOperationEventArgs.cs +++ /dev/null @@ -1,44 +0,0 @@ -//
-// ParentPackagesOperationEventArgs.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ParentPackagesOperationEventArgs : EventArgs
- {
- public ParentPackagesOperationEventArgs(IEnumerable<IPackage> packages)
- {
- this.Packages = packages;
- }
-
- public IEnumerable<IPackage> Packages { get; private set; }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Process.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Process.cs deleted file mode 100644 index 767986eb36..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/Process.cs +++ /dev/null @@ -1,40 +0,0 @@ -//
-// Process.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal class Process : IProcess
- {
- public void Start(string fileName)
- {
- System.Diagnostics.Process.Start(fileName);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs deleted file mode 100644 index 776bea11d1..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageAction.cs +++ /dev/null @@ -1,274 +0,0 @@ -//
-// ProcessPackageActions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Versioning;
-using MonoDevelop.Core;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal abstract class ProcessPackageAction : IPackageAction
- {
- IPackageManagementEvents packageManagementEvents;
- bool hasBeforeExecuteBeenRun;
-
- public ProcessPackageAction(
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- {
- this.Project = project;
- this.packageManagementEvents = packageManagementEvents;
- }
-
- public IPackageManagementProject Project { get; set; }
- public ILogger Logger { get; set; }
- public IPackage Package { get; set; }
- public SemanticVersion PackageVersion { get; set; }
- public string PackageId { get; set; }
- //public IPackageScriptRunner PackageScriptRunner { get; set; }
- public bool AllowPrereleaseVersions { get; set; }
-
- public FrameworkName ProjectTargetFramework {
- get { return Project.TargetFramework; }
- }
-
- public virtual bool HasPackageScriptsToRun()
- {
- return false;
- }
-
- protected void OnParentPackageUninstalled()
- {
- packageManagementEvents.OnParentPackageUninstalled(Package, Project);
- }
-
- public void Execute()
- {
- BeforeExecute();
- CheckForPowerShellScripts ();
- CheckLicenses ();
- //if (PackageScriptRunner != null) {
- // ExecuteWithScriptRunner();
- //} else {
- ExecuteCore();
- //}
- LogEmptyLineForFinishedAction ();
- }
-
- protected virtual void BeforeExecute()
- {
- if (hasBeforeExecuteBeenRun)
- return;
-
- GetLoggerIfMissing();
- ConfigureProjectLogger();
- LogStartingMessage ();
- GetPackageIfMissing();
-
- hasBeforeExecuteBeenRun = true;
- }
-
- void LogStartingMessage ()
- {
- if (ShouldLogStartingMessage ()) {
- Logger.Log (MessageLevel.Info, GetStartingMessage ());
- }
- }
-
- protected virtual bool ShouldLogStartingMessage ()
- {
- return true;
- }
-
- string GetStartingMessage ()
- {
- return String.Format (
- GettextCatalog.GetString (StartingMessageFormat),
- GetPackageId ());
- }
-
- protected abstract string StartingMessageFormat { get; }
-
- void LogEmptyLineForFinishedAction ()
- {
- if (!ShouldLogEmptyLineForFinishedAction ())
- return;
-
- Logger.Log (MessageLevel.Info, String.Empty);
- }
-
- protected virtual bool ShouldLogEmptyLineForFinishedAction ()
- {
- return true;
- }
-
- void CheckForPowerShellScripts ()
- {
- if (HasPackageScriptsToRun ()) {
- ReportPowerShellScriptWarning ();
- }
- }
-
- void ReportPowerShellScriptWarning ()
- {
- string message = GettextCatalog.GetString ("WARNING: {0} Package contains PowerShell scripts which will not be run.", GetPackageId ());
- packageManagementEvents.OnPackageOperationMessageLogged (MessageLevel.Info, message);
- }
-
- protected virtual void CheckLicenses ()
- {
- if (!AcceptLicenses ()) {
- string message = GettextCatalog.GetString ("Licenses not accepted.");
- throw new ApplicationException (message);
- }
- }
-
- bool AcceptLicenses ()
- {
- var packagesWithLicenses = new PackagesRequiringLicenseAcceptance (Project);
- var actions = new IPackageAction [] { this };
- List<IPackage> packages = packagesWithLicenses.GetPackagesRequiringLicenseAcceptance (actions).ToList ();
- if (packages.Any ()) {
- return OnAcceptLicenses (packages);
- }
-
- return true;
- } - - void ExecuteWithScriptRunner()
- {
-// using (RunPackageScriptsAction runScriptsAction = CreateRunPackageScriptsAction()) {
-// ExecuteCore();
-// }
- }
-//
-// RunPackageScriptsAction CreateRunPackageScriptsAction()
-// {
-// return CreateRunPackageScriptsAction(PackageScriptRunner, Project);
-// }
-//
-// protected virtual RunPackageScriptsAction CreateRunPackageScriptsAction(
-// IPackageScriptRunner scriptRunner,
-// IPackageManagementProject project)
-// {
-// return new RunPackageScriptsAction(scriptRunner, project);
-// }
-
- protected virtual void ExecuteCore()
- {
- }
-
- void GetLoggerIfMissing()
- {
- if (Logger == null) {
- Logger = new PackageManagementLogger(packageManagementEvents);
- }
- }
-
- void ConfigureProjectLogger()
- {
- Project.Logger = Logger;
- }
-
- void GetPackageIfMissing()
- {
- if (Package == null) {
- FindPackage();
- }
- if (Package == null) {
- ThrowPackageNotFoundError(PackageId);
- }
- }
-
- void FindPackage()
- {
- Package = Project
- .SourceRepository
- .FindPackage (
- PackageId,
- PackageVersion,
- Project.ConstraintProvider,
- AllowPrereleaseVersions,
- allowUnlisted: false);
- }
-
- void ThrowPackageNotFoundError(string packageId)
- {
- string message = GettextCatalog.GetString ("Unable to find package '{0}'.", packageId);
- throw new ApplicationException(message);
- }
-
- protected bool PackageIdExistsInProject()
- {
- string id = GetPackageId();
- return Project.IsPackageInstalled(id);
- }
-
- public string GetPackageId ()
- {
- if (Package != null) {
- return Package.Id;
- }
- return PackageId;
- }
-
- public SemanticVersion GetPackageVersion ()
- {
- if (Package != null) {
- return Package.Version;
- }
- return PackageVersion;
- }
-
- protected virtual IOpenPackageReadMeMonitor CreateOpenPackageReadMeMonitor (string packageId)
- {
- return new OpenPackageReadMeMonitor (packageId, Project, packageManagementEvents);
- }
-
- protected IDisposable CreateFileMonitor (IFileRemover fileRemover)
- {
- return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
- packageManagementEvents,
- fileRemover);
- }
-
- protected LocalCopyReferenceMaintainer CreateLocalCopyReferenceMaintainer ()
- {
- return new LocalCopyReferenceMaintainer (packageManagementEvents);
- }
-
- protected virtual bool OnAcceptLicenses (IEnumerable<IPackage> packages) - { - return packageManagementEvents.OnAcceptLicenses (packages); - }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs deleted file mode 100644 index 8c28780674..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProcessPackageOperationsAction.cs +++ /dev/null @@ -1,106 +0,0 @@ -//
-// ProcessPackageOperationsAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal abstract class ProcessPackageOperationsAction : ProcessPackageAction
- {
- IPackageManagementEvents packageManagementEvents;
- ILicenseAcceptanceService licenseAcceptanceService;
-
- protected ProcessPackageOperationsAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- ILicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents)
- {
- this.packageManagementEvents = packageManagementEvents;
- this.licenseAcceptanceService = licenseAcceptanceService;
- }
-
- public ProcessPackageOperationsAction(
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- : this (project, packageManagementEvents, new LicenseAcceptanceService ())
- {
- }
-
- public IEnumerable<PackageOperation> Operations { get; set; }
-
- public bool LicensesMustBeAccepted { get; set; }
-
- public override bool HasPackageScriptsToRun()
- {
- BeforeExecute();
- var files = new PackageFilesForOperations(Operations);
- return files.HasAnyPackageScripts();
- }
-
- protected override void BeforeExecute()
- {
- base.BeforeExecute();
- GetPackageOperationsIfMissing();
- }
-
- void GetPackageOperationsIfMissing()
- {
- if (Operations == null) {
- Operations = GetPackageOperations();
- }
- }
-
- protected virtual IEnumerable<PackageOperation> GetPackageOperations()
- {
- return null;
- }
-
- public IEnumerable<PackageOperation> GetInstallOperations ()
- {
- BeforeExecute ();
- return Operations.Where (operation => operation.Action == PackageAction.Install);
- }
-
- protected void OnParentPackageInstalled ()
- {
- packageManagementEvents.OnParentPackageInstalled (Package, Project, Operations);
- }
-
- protected override bool OnAcceptLicenses (IEnumerable<IPackage> packages) - {
- if (LicensesMustBeAccepted) {
- return licenseAcceptanceService.AcceptLicenses (packages);
- } else { - return base.OnAcceptLicenses (packages);
- } - }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs index c88e8e9659..30b664fd46 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProgressMonitorStatusMessageFactory.cs @@ -71,7 +71,7 @@ namespace MonoDevelop.PackageManagement );
}
- public static ProgressMonitorStatusMessage CreateUpdatingPackagesInSolutionMessage (IEnumerable<IPackageManagementProject> projects)
+ public static ProgressMonitorStatusMessage CreateUpdatingPackagesInSolutionMessage (IEnumerable<IDotNetProject> projects)
{
ProgressMonitorStatusMessage message = CreateUpdatingPackagesInSolutionMessage ();
return new UpdatePackagesProgressMonitorStatusMessage (
@@ -81,19 +81,19 @@ namespace MonoDevelop.PackageManagement message);
}
- public static ProgressMonitorStatusMessage CreateUpdatingPackagesInProjectMessage (int count)
+ public static ProgressMonitorStatusMessage CreateUpdatingPackagesInProjectMessage ()
{
return new ProgressMonitorStatusMessage (
- GettextCatalog.GetString ("Updating {0} packages in project...", count),
- GettextCatalog.GetString ("{0} packages successfully updated.", count),
+ GettextCatalog.GetString ("Updating packages in project..."),
+ GettextCatalog.GetString ("Packages successfully updated."),
GettextCatalog.GetString ("Could not update packages."),
- GettextCatalog.GetString ("{0} packages updated with warnings.", count)
+ GettextCatalog.GetString ("Packages updated with warnings.")
);
}
- public static ProgressMonitorStatusMessage CreateUpdatingPackagesInProjectMessage (int count, IPackageManagementProject project)
+ public static ProgressMonitorStatusMessage CreateUpdatingPackagesInProjectMessage (IDotNetProject project)
{
- ProgressMonitorStatusMessage message = CreateUpdatingPackagesInProjectMessage (count);
+ ProgressMonitorStatusMessage message = CreateUpdatingPackagesInProjectMessage ();
return new UpdatePackagesProgressMonitorStatusMessage (
project,
GettextCatalog.GetString ("Packages are up to date."),
@@ -101,16 +101,6 @@ namespace MonoDevelop.PackageManagement message);
}
- public static ProgressMonitorStatusMessage CreateUpdatingPackagesInProjectMessage ()
- {
- return new ProgressMonitorStatusMessage (
- GettextCatalog.GetString ("Updating packages in project..."),
- GettextCatalog.GetString ("Packages successfully updated."),
- GettextCatalog.GetString ("Could not update packages."),
- GettextCatalog.GetString ("Packages updated with warnings.")
- );
- }
-
public static ProgressMonitorStatusMessage CreateUpdatingSinglePackageMessage (string packageId)
{
return new ProgressMonitorStatusMessage (
@@ -121,7 +111,7 @@ namespace MonoDevelop.PackageManagement );
}
- public static ProgressMonitorStatusMessage CreateUpdatingSinglePackageMessage (string packageId, IPackageManagementProject project)
+ public static ProgressMonitorStatusMessage CreateUpdatingSinglePackageMessage (string packageId, IDotNetProject project)
{
ProgressMonitorStatusMessage message = CreateUpdatingSinglePackageMessage (packageId);
return new UpdatePackagesProgressMonitorStatusMessage (
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectBrowserUpdater.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectBrowserUpdater.cs deleted file mode 100644 index f68491881d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectBrowserUpdater.cs +++ /dev/null @@ -1,68 +0,0 @@ -//
-// ProjectBrowserUpdater.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal class ProjectBrowserUpdater : IProjectBrowserUpdater
- {
-// ProjectBrowserControl projectBrowser;
-//
-// public ProjectBrowserUpdater()
-// : this(ProjectBrowserPad.Instance.ProjectBrowserControl)
-// {
-// }
-//
-// public ProjectBrowserUpdater(ProjectBrowserControl projectBrowser)
-// {
-// this.projectBrowser = projectBrowser;
-// ProjectService.ProjectItemAdded += ProjectItemAdded;
-// }
-//
-// protected virtual void ProjectItemAdded(object sender, ProjectItemEventArgs e)
-// {
-// if (e.ProjectItem is FileProjectItem) {
-// AddFileProjectItemToProjectBrowser(e);
-// }
-// }
-//
-// void AddFileProjectItemToProjectBrowser(ProjectItemEventArgs e)
-// {
-// var visitor = new UpdateProjectBrowserFileNodesVisitor(e);
-// foreach (AbstractProjectBrowserTreeNode node in projectBrowser.TreeView.Nodes) {
-// node.AcceptVisitor(visitor, null);
-// }
-// }
-
- public void Dispose()
- {
- // ProjectService.ProjectItemAdded -= ProjectItemAdded;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectReferenceExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectReferenceExtensions.cs index be249f306f..d40e847b4d 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectReferenceExtensions.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectReferenceExtensions.cs @@ -25,32 +25,47 @@ // THE SOFTWARE.
using System;
-using MonoDevelop.PackageManagement;
using MonoDevelop.Core;
using MonoDevelop.Projects;
using System.IO;
+using NuGet.PackageManagement;
namespace MonoDevelop.PackageManagement
{
internal static class ProjectReferenceExtensions
{
+ public static bool IsReferenceFromPackage (this ProjectReference projectReference, FilePath packagesFolderPath)
+ {
+ if (!projectReference.IsAssemblyReference ())
+ return false;
+
+ var project = projectReference.OwnerProject as DotNetProject;
+ if (project == null)
+ return false;
+
+ var assemblyFilePath = new FilePath (projectReference.GetFullAssemblyPath ());
+ if (assemblyFilePath.IsNullOrEmpty)
+ return false;
+
+ return assemblyFilePath.IsChildPathOf (packagesFolderPath);
+ }
+
public static bool IsReferenceFromPackage (this ProjectReference projectReference)
{
if (!projectReference.IsAssemblyReference ())
return false;
var project = projectReference.OwnerProject as DotNetProject;
- if ((project == null) || !project.HasPackages ())
+ if (project == null)
return false;
var assemblyFilePath = new FilePath (projectReference.GetFullAssemblyPath ());
if (assemblyFilePath.IsNullOrEmpty)
return false;
- var packagesPath = new SolutionPackageRepositoryPath (project);
- var packagesFilePath = new FilePath (packagesPath.PackageRepositoryPath);
+ FilePath packagesFolderPath = project.GetPackagesFolderPath ();
- return assemblyFilePath.IsChildPathOf (packagesFilePath);
+ return assemblyFilePath.IsChildPathOf (packagesFolderPath);
}
static bool IsAssemblyReference (this ProjectReference reference)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTargetFrameworkMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTargetFrameworkMonitor.cs index b0b65b5c94..532147bbb0 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTargetFrameworkMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTargetFrameworkMonitor.cs @@ -26,20 +26,16 @@ using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
using System.Linq;
namespace MonoDevelop.PackageManagement
{
internal class ProjectTargetFrameworkMonitor
{
- IPackageManagementProjectService projectService;
List<MonitoredSolution> monitoredSolutions = new List<MonitoredSolution> ();
public ProjectTargetFrameworkMonitor (IPackageManagementProjectService projectService)
{
- this.projectService = projectService;
-
projectService.SolutionLoaded += SolutionLoaded;
projectService.SolutionUnloaded += SolutionUnloaded;
projectService.ProjectReloaded += ProjectReloaded;
@@ -63,6 +59,7 @@ namespace MonoDevelop.PackageManagement foreach (IDotNetProject project in monitoredSolution.Projects) {
project.Modified -= ProjectModified;
+ project.Saved -= ProjectSaved;
}
monitoredSolution.Projects.Clear ();
@@ -112,10 +109,18 @@ namespace MonoDevelop.PackageManagement void ProjectModified (object sender, ProjectModifiedEventArgs e)
{
if (e.IsTargetFramework ()) {
- OnProjectTargetFrameworkChanged (e.Project);
+ e.Project.Saved += ProjectSaved;
}
- }
+ } + void ProjectSaved (object sender, EventArgs e) + {
+ var project = (IDotNetProject)sender;
+ project.Saved -= ProjectSaved;
+ + OnProjectTargetFrameworkChanged (project); + }
+ void ProjectReloaded (object sender, ProjectReloadedEventArgs e)
{
if (HasTargetFrameworkChanged (e.NewProject, e.OldProject)) {
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateNuGetPackageInstaller.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateNuGetPackageInstaller.cs index 889a88d3bb..5c28754133 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateNuGetPackageInstaller.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateNuGetPackageInstaller.cs @@ -24,37 +24,27 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using MonoDevelop.Ide.Templates;
-using MonoDevelop.Projects;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide;
-using NuGet;
using System.Linq;
+using MonoDevelop.Ide.Templates;
+using MonoDevelop.Projects;
+using NuGet.Protocol.Core.Types;
+using NuGet.Versioning;
namespace MonoDevelop.PackageManagement
{
internal class ProjectTemplateNuGetPackageInstaller : ProjectTemplatePackageInstaller
{
- IPackageManagementSolution packageManagementSolution;
- IPackageRepositoryCache packageRepositoryCache;
IBackgroundPackageActionRunner backgroundPackageActionRunner;
public ProjectTemplateNuGetPackageInstaller ()
- : this(
- PackageManagementServices.Solution,
- PackageManagementServices.ProjectTemplatePackageRepositoryCache,
- PackageManagementServices.BackgroundPackageActionRunner)
+ : this(PackageManagementServices.BackgroundPackageActionRunner)
{
}
public ProjectTemplateNuGetPackageInstaller (
- IPackageManagementSolution solution,
- IPackageRepositoryCache packageRepositoryCache,
IBackgroundPackageActionRunner backgroundPackageActionRunner)
{
- this.packageManagementSolution = solution;
- this.packageRepositoryCache = packageRepositoryCache;
this.backgroundPackageActionRunner = backgroundPackageActionRunner;
}
@@ -72,49 +62,77 @@ namespace MonoDevelop.PackageManagement {
List<IPackageAction> actions = CreateInstallPackageActions (solution, packageReferencesForCreatedProjects);
if (actions.Any () && PackageManagementServices.Options.IsCheckForPackageUpdatesOnOpeningSolutionEnabled) {
- actions.Add (new CheckForUpdatedPackagesAction ());
+ actions.Add (new CheckForUpdatedPackagesAction (solution));
}
return actions;
}
List<IPackageAction> CreateInstallPackageActions (Solution solution, IList<PackageReferencesForCreatedProject> packageReferencesForCreatedProjects)
{
+ var repositoryProvider = new ProjectTemplateSourceRepositoryProvider ();
+
var installPackageActions = new List<IPackageAction> ();
foreach (PackageReferencesForCreatedProject packageReferences in packageReferencesForCreatedProjects) {
var project = solution.GetAllProjects ().FirstOrDefault (p => p.Name == packageReferences.ProjectName) as DotNetProject;
if (project != null) {
- installPackageActions.AddRange (CreateInstallPackageActions (project, packageReferences));
+ installPackageActions.AddRange (CreateInstallPackageActions (project, packageReferences, repositoryProvider));
}
}
return installPackageActions;
}
- IEnumerable<InstallPackageAction> CreateInstallPackageActions (DotNetProject dotNetProject, PackageReferencesForCreatedProject projectPackageReferences)
+ IEnumerable<InstallNuGetPackageAction> CreateInstallPackageActions (
+ DotNetProject dotNetProject,
+ PackageReferencesForCreatedProject projectPackageReferences,
+ ProjectTemplateSourceRepositoryProvider repositoryProvider)
{
- IPackageManagementProject project = CreatePackageManagementProject (dotNetProject);
foreach (ProjectTemplatePackageReference packageReference in projectPackageReferences.PackageReferences) {
- InstallPackageAction action = project.CreateInstallPackageAction ();
+ var action = CreateInstallNuGetPackageAction (dotNetProject, repositoryProvider, packageReference);
action.PackageId = packageReference.Id;
- action.PackageVersion = GetPackageVersion (packageReference);
+ action.Version = GetPackageVersion (packageReference);
yield return action;
}
}
- SemanticVersion GetPackageVersion (ProjectTemplatePackageReference packageReference)
+ InstallNuGetPackageAction CreateInstallNuGetPackageAction (
+ DotNetProject dotNetProject,
+ ProjectTemplateSourceRepositoryProvider repositoryProvider,
+ ProjectTemplatePackageReference packageReference)
{
- if (!string.IsNullOrEmpty (packageReference.Version)) {
- return new SemanticVersion (packageReference.Version);
+ var primaryRepositories = repositoryProvider.GetRepositories (packageReference.IsLocalPackage);
+ var secondaryRepositories = GetSecondaryRepositories (primaryRepositories, packageReference.IsLocalPackage);
+
+ return new InstallNuGetPackageAction (
+ primaryRepositories,
+ secondaryRepositories,
+ PackageManagementServices.Workspace.GetSolutionManager (dotNetProject.ParentSolution),
+ new DotNetProjectProxy (dotNetProject),
+ new NuGetProjectContext ());
+ }
+
+ /// <summary>
+ /// If the package is a local package then we prevent NuGet from using online package sources
+ /// defined in the NuGet.Config file by using the returning the primaryRepositories.
+ /// Returning null allows all enabled package sources to be used when resolving dependencies.
+ /// </summary>
+ static IEnumerable<SourceRepository> GetSecondaryRepositories (
+ IEnumerable<SourceRepository> primaryRepositories, bool local)
+ {
+ if (local) {
+ return primaryRepositories;
}
return null;
}
-
- IPackageManagementProject CreatePackageManagementProject (DotNetProject project)
+ + NuGetVersion GetPackageVersion (ProjectTemplatePackageReference packageReference)
{
- var dotNetProject = new DotNetProjectProxy (project);
- return packageManagementSolution.GetProject (packageRepositoryCache.CreateAggregateWithPriorityMachineCacheRepository (), dotNetProject);
+ if (!string.IsNullOrEmpty (packageReference.Version)) {
+ return new NuGetVersion (packageReference.Version);
+ }
+ return null;
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplatePackageRepositoryCache.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplatePackageRepositoryCache.cs deleted file mode 100644 index ddd6790436..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplatePackageRepositoryCache.cs +++ /dev/null @@ -1,95 +0,0 @@ -//
-// ProjectTemplatePackageRepositoryCache.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- /// <summary>
- /// Supports a configurable set of package repositories for project templates that can be
- /// different to the registered package repositories used with the Add Package Reference dialog.
- /// </summary>
- internal class ProjectTemplatePackageRepositoryCache : IPackageRepositoryCache
- {
- IPackageRepositoryCache packageRepositoryCache;
- RegisteredProjectTemplatePackageSources registeredPackageSources;
-
- /// <summary>
- /// Creates a new instance of the ProjectTemplatePackageRepositoryCache.
- /// </summary>
- public ProjectTemplatePackageRepositoryCache(RegisteredProjectTemplatePackageSources registeredPackageSources)
- {
- this.packageRepositoryCache = new PackageRepositoryCache(registeredPackageSources.PackageSources, new List<RecentPackageInfo>());
- this.registeredPackageSources = registeredPackageSources;
- }
-
- public IRecentPackageRepository RecentPackageRepository {
- get { throw new NotImplementedException(); }
- }
-
- public IPackageRepository CreateAggregateRepository()
- {
- IEnumerable<IPackageRepository> repositories = GetRegisteredPackageRepositories();
- return CreateAggregateRepository(repositories);
- }
-
- IEnumerable<IPackageRepository> GetRegisteredPackageRepositories()
- {
- foreach (PackageSource packageSource in registeredPackageSources.PackageSources) {
- yield return CreateRepository(packageSource.Source);
- }
- }
-
- public ISharedPackageRepository CreateSharedRepository(IPackagePathResolver pathResolver, IFileSystem fileSystem, IFileSystem configSettingsFileSystem)
- {
- throw new NotImplementedException();
- }
-
- public IRecentPackageRepository CreateRecentPackageRepository(IList<RecentPackageInfo> recentPackages, IPackageRepository aggregateRepository)
- {
- throw new NotImplementedException();
- }
-
- public IPackageRepository CreateAggregateRepository(IEnumerable<IPackageRepository> repositories)
- {
- return packageRepositoryCache.CreateAggregateRepository(repositories);
- }
-
- public IPackageRepository CreateRepository(string packageSource)
- {
- return packageRepositoryCache.CreateRepository(packageSource);
- }
-
- public IPackageRepository CreateAggregateWithPriorityMachineCacheRepository ()
- {
- return new PriorityPackageRepository (MachineCache.Default, CreateAggregateRepository ());
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplatePackageSettingsFileName.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplatePackageSettingsFileName.cs deleted file mode 100644 index 3a28f98b5f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplatePackageSettingsFileName.cs +++ /dev/null @@ -1,47 +0,0 @@ -//
-// ProjectTemplatePackageSettingsFileName.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.IO;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ProjectTemplatePackagesSettingsFileName
- {
- string directory;
-
- public ProjectTemplatePackagesSettingsFileName(IPropertyService propertyService)
- {
- directory = Path.Combine(propertyService.ConfigDirectory, "templates");
- }
-
- public string Directory {
- get { return directory; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateSourceRepositoryProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateSourceRepositoryProvider.cs new file mode 100644 index 0000000000..4ffef9fbf8 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ProjectTemplateSourceRepositoryProvider.cs @@ -0,0 +1,85 @@ +//
+// ProjectTemplateSourceRepositoryProvider.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Collections.Generic;
+using System.Linq;
+using Mono.Addins;
+using MonoDevelop.Ide.Templates;
+using NuGet.Configuration;
+using NuGet.Protocol.Core.Types;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class ProjectTemplateSourceRepositoryProvider
+ {
+ ISourceRepositoryProvider provider;
+ List<SourceRepository> projectTemplateRepositories;
+ SourceRepository nugetSourceRepository;
+
+ public ProjectTemplateSourceRepositoryProvider ()
+ {
+ provider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider ();
+ var packageSource = new PackageSource (NuGetConstants.V3FeedUrl);
+ nugetSourceRepository = provider.CreateRepository (packageSource);
+ }
+
+ public IEnumerable<SourceRepository> GetRepositories (bool local = false)
+ {
+ foreach (SourceRepository sourceRepository in GetProjectTemplateRepositories ()) {
+ if (!local || sourceRepository.PackageSource.IsLocal) {
+ yield return sourceRepository;
+ }
+ }
+
+ if (!local) {
+ yield return nugetSourceRepository;
+ }
+ }
+
+ IEnumerable<SourceRepository> GetProjectTemplateRepositories ()
+ {
+ if (projectTemplateRepositories == null) {
+ projectTemplateRepositories = GetProjectTemplatePackageSources ()
+ .Select (packageSource => provider.CreateRepository (packageSource))
+ .ToList ();
+ }
+
+ return projectTemplateRepositories;
+ }
+
+ IEnumerable<PackageSource> GetProjectTemplatePackageSources ()
+ {
+ var packageSources = new List<PackageSource> ();
+
+ foreach (PackageRepositoryNode node in AddinManager.GetExtensionNodes ("/MonoDevelop/Ide/ProjectTemplatePackageRepositories")) {
+ packageSources.Add (node.CreatePackageSource ());
+ }
+
+ return packageSources;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentNuGetPackagesRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentNuGetPackagesRepository.cs new file mode 100644 index 0000000000..05d7c1b8a3 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentNuGetPackagesRepository.cs @@ -0,0 +1,111 @@ +// +// RecentNuGetPackagesRepository.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Linq; + +namespace MonoDevelop.PackageManagement +{ + internal class RecentNuGetPackagesRepository + { + public const int DefaultMaximumPackagesCount = 20; + + int maximumPackagesCount = DefaultMaximumPackagesCount; + + List<RecentPackage> packages = new List<RecentPackage> (); + + public int MaximumPackagesCount { + get { return maximumPackagesCount; } + set { maximumPackagesCount = value; } + } + + public IEnumerable<PackageSearchResultViewModel> GetPackages (string source) + { + return packages + .Where (package => String.Equals (package.Source, source, StringComparison.OrdinalIgnoreCase)) + .Select (package => package.PackageViewModel); + } + + public void AddPackage (PackageSearchResultViewModel viewModel, string source) + { + var package = new RecentPackage (viewModel, source); + viewModel.IsRecentPackage = true; + RemovePackageIfAlreadyAdded (package); + AddPackageAtBeginning (package); + RemoveLastPackageIfCurrentPackageCountExceedsMaximum (); + } + + void RemovePackageIfAlreadyAdded (RecentPackage package) + { + int index = FindPackage (package); + if (index >= 0) { + packages.RemoveAt (index); + } + } + + int FindPackage (RecentPackage package) + { + return packages.FindIndex (p => IsMatch (p, package)); + } + + bool IsMatch (RecentPackage x, RecentPackage y) + { + return PackageSearchResultViewModelComparer.Instance.Equals (x.PackageViewModel, y.PackageViewModel); + } + + void AddPackageAtBeginning (RecentPackage package) + { + package.PackageViewModel.Parent = null; + packages.Insert (0, package); + } + + void RemoveLastPackageIfCurrentPackageCountExceedsMaximum() + { + if (packages.Count > maximumPackagesCount) { + RemoveLastPackage (); + } + } + + void RemoveLastPackage () + { + packages.RemoveAt (packages.Count - 1); + } + + class RecentPackage + { + public RecentPackage (PackageSearchResultViewModel viewModel, string source) + { + PackageViewModel = viewModel; + Source = source; + } + + public PackageSearchResultViewModel PackageViewModel { get; set; } + public string Source { get; set; } + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageInfo.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageInfo.cs index 4698c8f37f..f9da178fe3 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageInfo.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageInfo.cs @@ -31,6 +31,7 @@ using NuGet; namespace MonoDevelop.PackageManagement
{
+ [Obsolete]
public class RecentPackageInfo
{
SemanticVersion version;
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageRepository.cs deleted file mode 100644 index e833dc3504..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackageRepository.cs +++ /dev/null @@ -1,201 +0,0 @@ -//
-// RecentPackageRepository.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RecentPackageRepository : IRecentPackageRepository
- {
- public const int DefaultMaximumPackagesCount = 20;
-
- List<IPackage> packages = new List<IPackage>();
- int maximumPackagesCount = DefaultMaximumPackagesCount;
- IList<RecentPackageInfo> savedRecentPackages;
- IPackageRepository aggregateRepository;
-
- public RecentPackageRepository(
- IList<RecentPackageInfo> recentPackages,
- IPackageRepository aggregateRepository)
- {
- this.savedRecentPackages = recentPackages;
- this.aggregateRepository = aggregateRepository;
-
- //UpdatePackages ();
- }
-
- public string Source {
- get { return "RecentPackages"; }
- }
-
- public void AddPackage(IPackage package)
- {
- RemovePackageIfAlreadyAdded(package);
- AddPackageAtBeginning(package);
- RemoveLastPackageIfCurrentPackageCountExceedsMaximum();
- //UpdateRecentPackagesInOptions();
- }
-
- void RemovePackageIfAlreadyAdded(IPackage package)
- {
- int index = FindPackage(package);
- if (index >= 0) {
- packages.RemoveAt(index);
- }
- }
-
- int FindPackage(IPackage package)
- {
- return packages.FindIndex(p => PackageEqualityComparer.IdAndVersion.Equals(package, p));
- }
-
- void AddPackageAtBeginning(IPackage package)
- {
- packages.Insert(0, package);
- }
-
- void RemoveLastPackageIfCurrentPackageCountExceedsMaximum()
- {
- if (packages.Count > maximumPackagesCount) {
- RemoveLastPackage();
- }
- }
-
- void RemoveLastPackage()
- {
- packages.RemoveAt(packages.Count - 1);
- }
-
- void UpdateRecentPackagesInOptions()
- {
- savedRecentPackages.Clear();
- savedRecentPackages.AddRange(GetRecentPackagesInfo());
- }
-
- List<RecentPackageInfo> GetRecentPackagesInfo()
- {
- List<RecentPackageInfo> allRecentPackages = new List<RecentPackageInfo>();
- foreach (IPackage package in packages) {
- var recentPackageInfo = new RecentPackageInfo(package);
- allRecentPackages.Add(recentPackageInfo);
- }
- return allRecentPackages;
- }
-
- public void RemovePackage(IPackage package)
- {
- }
-
- public IQueryable<IPackage> GetPackages()
- {
- //UpdatePackages();
- RemoveInvalidPackages ();
- return packages.AsQueryable();
- }
-
- void UpdatePackages()
- {
- if (!HasRecentPackagesBeenRead() && HasRecentPackages) {
- IEnumerable<IPackage> recentPackages = GetRecentPackages();
- packages.AddRange(recentPackages);
- }
- }
-
- void RemoveInvalidPackages ()
- {
- packages.RemoveAll (package => !IsValidPackage (package));
- }
-
- static bool IsValidPackage (IPackage package)
- {
- var packageFromRepository = package as IPackageFromRepository;
- return (packageFromRepository != null) && packageFromRepository.IsValid;
- }
-
- bool HasRecentPackagesBeenRead()
- {
- return packages.Count > 0;
- }
-
- public bool HasRecentPackages {
- get { return savedRecentPackages.Count > 0; }
- }
-
- IEnumerable<IPackage> GetRecentPackages()
- {
- IEnumerable<IPackage> recentPackages = GetRecentPackagesFilteredById();
- return GetRecentPackagesFilteredByVersion(recentPackages);
- }
-
- IEnumerable<IPackage> GetRecentPackagesFilteredById()
- {
- IEnumerable<string> recentPackageIds = GetRecentPackageIds();
- return aggregateRepository.FindPackages(recentPackageIds);
- }
-
- IEnumerable<string> GetRecentPackageIds()
- {
- foreach (RecentPackageInfo recentPackageInfo in savedRecentPackages) {
- yield return recentPackageInfo.Id;
- }
- }
-
- IEnumerable<IPackage> GetRecentPackagesFilteredByVersion(IEnumerable<IPackage> recentPackages)
- {
- List<IPackage> filteredRecentPackages = new List<IPackage>();
- foreach (IPackage recentPackage in recentPackages) {
- foreach (RecentPackageInfo savedRecentPackageInfo in savedRecentPackages) {
- if (savedRecentPackageInfo.IsMatch(recentPackage)) {
- filteredRecentPackages.Add(recentPackage);
- }
- }
- }
- return filteredRecentPackages;
- }
-
- public int MaximumPackagesCount {
- get { return maximumPackagesCount; }
- set { maximumPackagesCount = value; }
- }
-
- public void Clear()
- {
- packages.Clear();
- UpdateRecentPackagesInOptions();
- }
-
- public bool SupportsPrereleasePackages {
- get { return false; }
- }
-
- public PackageSaveModes PackageSaveMode { get; set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackagesViewModel.cs deleted file mode 100644 index 352640d48a..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RecentPackagesViewModel.cs +++ /dev/null @@ -1,76 +0,0 @@ -//
-// RecentPackagesViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RecentPackagesViewModel : PackagesViewModel
- {
- IPackageManagementEvents packageManagementEvents;
- IPackageRepository recentPackageRepository;
-
- public RecentPackagesViewModel(
- IPackageManagementEvents packageManagementEvents,
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageViewModelFactory packageViewModelFactory,
- ITaskFactory taskFactory)
- : base(registeredPackageRepositories, packageViewModelFactory, taskFactory)
- {
- this.packageManagementEvents = packageManagementEvents;
-
- recentPackageRepository = registeredPackageRepositories.RecentPackageRepository;
-
- packageManagementEvents.ParentPackageInstalled += ParentPackageInstalled;
- packageManagementEvents.ParentPackageUninstalled += ParentPackageUninstalled;
- }
-
- void ParentPackageInstalled(object sender, EventArgs e)
- {
- ReadPackages();
- }
-
- void ParentPackageUninstalled(object sender, EventArgs e)
- {
- ReadPackages();
- }
-
- protected override void OnDispose()
- {
- packageManagementEvents.ParentPackageInstalled -= ParentPackageInstalled;
- packageManagementEvents.ParentPackageUninstalled -= ParentPackageUninstalled;
- }
-
- protected override IQueryable<IPackage> GetAllPackages()
- {
- return recentPackageRepository.GetPackages();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReducedPackageOperations.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReducedPackageOperations.cs deleted file mode 100644 index 3834b2070b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReducedPackageOperations.cs +++ /dev/null @@ -1,77 +0,0 @@ -//
-// ReducedPackageOperations.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ReducedPackageOperations
- {
- IPackageOperationResolver resolver;
- IList<PackageOperation> operations;
- IEnumerable<IPackage> packages;
-
- public ReducedPackageOperations(IPackageOperationResolver resolver, IEnumerable<IPackage> packages)
- {
- this.resolver = resolver;
- this.packages = packages;
- this.operations = new List<PackageOperation>();
- }
-
- public IEnumerable<PackageOperation> Operations {
- get { return operations; }
- }
-
- public void Reduce()
- {
- foreach (IPackage package in packages) {
- if (!InstallOperationExists(package)) {
- operations.AddRange(resolver.ResolveOperations(package));
- }
- }
-
- operations = operations.Reduce();
- }
-
- bool InstallOperationExists(IPackage package)
- {
- var installOperation = new PackageOperation(package, PackageAction.Install);
- return operations.Any(operation => IsMatch(installOperation, operation));
- }
-
- bool IsMatch(PackageOperation x, PackageOperation y)
- {
- return (x.Package.Id == y.Package.Id) &&
- (x.Package.Version == y.Package.Version) &&
- (x.Action == y.Action);
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageRepositories.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageRepositories.cs deleted file mode 100644 index 2740d41ace..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageRepositories.cs +++ /dev/null @@ -1,167 +0,0 @@ -//
-// RegisteredPackageRepositories.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RegisteredPackageRepositories : IRegisteredPackageRepositories
- {
- IPackageRepositoryCache repositoryCache;
- PackageManagementOptions options;
- PackageSource activePackageSource;
- IPackageRepository activePackageRepository;
-
- public RegisteredPackageRepositories(
- IPackageRepositoryCache repositoryCache,
- PackageManagementOptions options)
- {
- this.repositoryCache = repositoryCache;
- this.options = options;
- }
-
- public IRecentPackageRepository RecentPackageRepository {
- get { return repositoryCache.RecentPackageRepository; }
- }
-
- public IPackageRepository CreateRepository(PackageSource source)
- {
- return repositoryCache.CreateRepository(source.Source);
- }
-
- public IPackageRepository CreateAggregateRepository()
- {
- return repositoryCache.CreateAggregateRepository();
- }
-
- public RegisteredPackageSources PackageSources {
- get { return options.PackageSources; }
- }
-
- public bool HasMultiplePackageSources {
- get { return PackageSources.HasMultipleEnabledPackageSources; }
- }
-
- public PackageSource ActivePackageSource {
- get {
- activePackageSource = options.ActivePackageSource;
- if (activePackageSource == null) {
- List<PackageSource> enabledPackageSources =
- options.PackageSources.GetEnabledPackageSources ().ToList ();
- if (enabledPackageSources.Any ()) {
- ActivePackageSource = enabledPackageSources [0];
- }
- }
- return activePackageSource;
- }
- set {
- if (activePackageSource != value) {
- activePackageSource = value;
- options.ActivePackageSource = value;
- activePackageRepository = null;
- }
- }
- }
-
- public IPackageRepository ActiveRepository {
- get {
- if (activePackageRepository == null) {
- CreateActiveRepository();
- }
- return activePackageRepository;
- }
- }
-
- void CreateActiveRepository()
- {
- if (ActivePackageSource == null)
- return;
-
- if (ActivePackageSource.IsAggregate()) {
- activePackageRepository = CreateAggregateRepository();
- } else {
- activePackageRepository = repositoryCache.CreateRepository(ActivePackageSource.Source);
- }
- }
-
- public void UpdatePackageSources (IEnumerable<PackageSource> updatedPackageSources)
- {
- List<PackageSource> packageSourcesBackup = PackageSources.ToList ();
-
- try {
- PackageSources.Clear ();
- foreach (PackageSource updatedPackageSource in updatedPackageSources) {
- PackageSources.Add (updatedPackageSource);
- }
-
- UpdateActivePackageSource ();
- UpdateActivePackageRepository ();
- } catch (Exception) {
- PackageSources.AddRange (packageSourcesBackup);
- UpdateActivePackageSource ();
-
- throw;
- }
- }
-
- void UpdateActivePackageSource ()
- {
- if (activePackageSource == null)
- return;
-
- if (activePackageSource.IsAggregate ()) {
- if (!HasMultiplePackageSources) {
- ActivePackageSource = null;
- }
- } else {
- PackageSource matchedPackageSource = PackageSources
- .GetEnabledPackageSources ()
- .FirstOrDefault (packageSource => packageSource.Equals (activePackageSource));
-
- if (matchedPackageSource == null) {
- ActivePackageSource = null;
- }
- }
- }
-
- void UpdateActivePackageRepository ()
- {
- if (activePackageSource == null)
- return;
-
- if (activePackageSource.IsAggregate ()) {
- // Force recreation of AggregateRepository to reset any
- // failing package repositories.
- activePackageRepository = null;
- }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSource.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSource.cs deleted file mode 100644 index cb4bf0f3b7..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSource.cs +++ /dev/null @@ -1,63 +0,0 @@ -//
-// RegisteredPackageSource.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RegisteredPackageSource
- {
- public string Source { get; set; }
- public string Name { get; set; }
- public bool IsEnabled { get; set; }
- public string UserName { get; set; }
- public string Password { get; set; }
-
- public RegisteredPackageSource()
- {
- }
-
- public RegisteredPackageSource(PackageSource packageSource)
- {
- Source = packageSource.Source;
- Name = packageSource.Name;
- IsEnabled = packageSource.IsEnabled;
- UserName = packageSource.UserName;
- Password = packageSource.Password;
- }
-
- public PackageSource ToPackageSource()
- {
- return new PackageSource (Source, Name, IsEnabled) {
- UserName = UserName,
- Password = Password
- };
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourceSettings.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourceSettings.cs deleted file mode 100644 index d8f5c23b98..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourceSettings.cs +++ /dev/null @@ -1,222 +0,0 @@ -//
-// RegisteredPackageSourceSettings.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Linq;
-using System.Security.Cryptography;
-
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RegisteredPackageSourceSettings
- {
- public static readonly string PackageSourcesSectionName = "packageSources";
- public static readonly string ActivePackageSourceSectionName = "activePackageSource";
- public static readonly string DisabledPackageSourceSectionName = "disabledPackageSources";
-
- public static readonly PackageSource AggregatePackageSource =
- new PackageSource("(Aggregate source)", "All");
-
- ISettings settings;
- ISettingsProvider settingsProvider;
- IPackageSourceProvider packageSourceProvider;
- PackageSource defaultPackageSource;
- RegisteredPackageSources packageSources;
- PackageSource activePackageSource;
-
- public RegisteredPackageSourceSettings (ISettingsProvider settingsProvider)
- : this(
- settingsProvider,
- RegisteredPackageSources.DefaultPackageSource)
- {
- }
-
- public RegisteredPackageSourceSettings (
- ISettingsProvider settingsProvider,
- PackageSource defaultPackageSource)
- {
- this.settingsProvider = settingsProvider;
- this.defaultPackageSource = defaultPackageSource;
-
- this.settings = settingsProvider.LoadSettings ();
- this.packageSourceProvider = CreatePackageSourceProvider (settings);
-
- ReadActivePackageSource();
- RegisterSolutionEvents ();
- }
-
- void RegisterSolutionEvents ()
- {
- settingsProvider.SettingsChanged += SettingsChanged;
- }
-
- IPackageSourceProvider CreatePackageSourceProvider (ISettings settings)
- {
- return new PackageSourceProvider (settings, new [] { RegisteredPackageSources.DefaultPackageSource });
- }
-
- void ReadActivePackageSource()
- {
- IList<SettingValue> packageSources = settings.GetValues(ActivePackageSourceSectionName, false);
- activePackageSource = PackageSourceConverter.ConvertFromFirstSetting(packageSources);
- }
-
- public RegisteredPackageSources PackageSources {
- get {
- if (packageSources == null) {
- TryReadPackageSources();
- }
- return packageSources;
- }
- }
-
- void TryReadPackageSources()
- {
- try {
- ReadPackageSources ();
- } catch (Exception ex) {
- ShowReadPackageSourcesError (ex);
-
- // Fallback to using the default package source only (nuget.org)
- // and treat NuGet.config as read-only.
- packageSourceProvider = CreatePackageSourceProvider (NullSettings.Instance);
- ReadPackageSources ();
- }
- }
-
- void ReadPackageSources()
- {
- IEnumerable<PackageSource> savedPackageSources = packageSourceProvider.LoadPackageSources ();
- packageSources = new RegisteredPackageSources(savedPackageSources, defaultPackageSource);
- packageSources.CollectionChanged += PackageSourcesChanged;
-
- if (!savedPackageSources.Any()) {
- UpdatePackageSourceSettingsWithChanges();
- }
- }
-
- static void ShowReadPackageSourcesError (Exception ex)
- {
- Ide.MessageService.ShowError (
- GettextCatalog.GetString ("Unable to read the NuGet.Config file"),
- String.Format (GetReadPackageSourcesErrorMessage (ex),
- BrandingService.ApplicationName,
- ex.Message),
- ex);
- }
-
- static string GetReadPackageSourcesErrorMessage (Exception ex)
- {
- if (ex is CryptographicException) {
- return GettextCatalog.GetString ("Unable to decrypt passwords stored in the NuGet.Config file. {0} will now fallback to using the Official NuGet Gallery and the NuGet.Config file will be treated as read-only.");
- }
-
- return GettextCatalog.GetString ("An error occurred when trying to read the NuGet.Config file. {0} will now fallback to using the Official NuGet Gallery and the NuGet.Config file will be treated as read-only.\n\n{1}");
- }
-
- void PackageSourcesChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- UpdatePackageSourceSettingsWithChanges();
- }
-
- void UpdatePackageSourceSettingsWithChanges()
- {
- packageSourceProvider.SavePackageSources (packageSources);
- }
-
- public PackageSource ActivePackageSource {
- get {
- if (activePackageSource != null) {
- if (activePackageSource.IsAggregate()) {
- return activePackageSource;
- }
- if (PackageSources.Contains(activePackageSource)) {
- return activePackageSource;
- }
- }
- return null;
- }
- set {
- activePackageSource = value;
-
- if (settings is NullSettings) {
- // NuGet failed to load settings so do not try to update them since this will fail.
- return;
- }
-
- if (activePackageSource == null) {
- RemoveActivePackageSourceSetting();
- } else {
- UpdateActivePackageSourceSetting();
- }
- }
- }
-
- void RemoveActivePackageSourceSetting()
- {
- settings.DeleteSection(ActivePackageSourceSectionName);
- }
-
- void UpdateActivePackageSourceSetting()
- {
- RemoveActivePackageSourceSetting();
-
- KeyValuePair<string, string> activePackageSourceSetting = PackageSourceConverter.ConvertToKeyValuePair(activePackageSource);
- SaveActivePackageSourceSetting(activePackageSourceSetting);
- }
-
- void SaveActivePackageSourceSetting(KeyValuePair<string, string> activePackageSource)
- {
- settings.SetValue(ActivePackageSourceSectionName, activePackageSource.Key, activePackageSource.Value);
- }
-
- void SettingsChanged (object sender, EventArgs e)
- {
- settings = settingsProvider.LoadSettings ();
- packageSourceProvider = CreatePackageSourceProvider (settings);
- ReadActivePackageSource ();
- ResetPackageSources ();
- }
-
- void ResetPackageSources ()
- {
- if (packageSources != null) {
- packageSources.CollectionChanged -= PackageSourcesChanged;
- packageSources = null;
- }
- }
-
- public ISettings Settings {
- get { return settings; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSources.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSources.cs deleted file mode 100644 index 7c7f7ce739..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSources.cs +++ /dev/null @@ -1,90 +0,0 @@ -//
-// RegisteredPackgaeSources.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RegisteredPackageSources : ObservableCollection<PackageSource>
- {
- public static readonly string DefaultPackageSourceUrl = "https://www.nuget.org/api/v2/";
- public static readonly string DefaultPackageSourceName = GettextCatalog.GetString ("Official NuGet Gallery");
-
- public static readonly PackageSource DefaultPackageSource =
- new PackageSource(DefaultPackageSourceUrl, DefaultPackageSourceName);
-
- public RegisteredPackageSources()
- : this(new PackageSource[0])
- {
- }
-
- public RegisteredPackageSources(IEnumerable<PackageSource> packageSources)
- : this(packageSources, DefaultPackageSource)
- {
- }
-
- public RegisteredPackageSources(
- IEnumerable<PackageSource> packageSources,
- PackageSource defaultPackageSource)
- {
- AddPackageSources(packageSources);
- AddDefaultPackageSourceIfNoRegisteredPackageSources(defaultPackageSource);
- }
-
- void AddPackageSources(IEnumerable<PackageSource> packageSources)
- {
- foreach (PackageSource source in packageSources) {
- Add(source);
- }
- }
-
- void AddDefaultPackageSourceIfNoRegisteredPackageSources(PackageSource defaultPackageSource)
- {
- if (HasNoRegisteredPackageSources) {
- Add(defaultPackageSource);
- }
- }
-
- bool HasNoRegisteredPackageSources {
- get { return Count == 0; }
- }
-
- public bool HasMultipleEnabledPackageSources {
- get { return GetEnabledPackageSources().Count() > 1; }
- }
-
- public IEnumerable<PackageSource> GetEnabledPackageSources()
- {
- return this.Where(packageSource => packageSource.IsEnabled);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourcesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourcesViewModel.cs index 9c35378387..010ac5cda7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourcesViewModel.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredPackageSourcesViewModel.cs @@ -32,8 +32,8 @@ using System.Collections.ObjectModel; using System.IO;
using System.Linq;
-using MonoDevelop.PackageManagement;
using NuGet;
+using NuGet.Protocol.Core.Types;
namespace MonoDevelop.PackageManagement
{
@@ -41,8 +41,8 @@ namespace MonoDevelop.PackageManagement {
ObservableCollection<PackageSourceViewModel> packageSourceViewModels =
new ObservableCollection<PackageSourceViewModel>();
- RegisteredPackageSources packageSources;
- IRegisteredPackageRepositories registeredPackageRepositories;
+ NuGet.Configuration.IPackageSourceProvider packageSourceProvider;
+
IFolderBrowser folderBrowser;
PackageSourceViewModelChecker packageSourceChecker = new PackageSourceViewModelChecker ();
@@ -53,26 +53,24 @@ namespace MonoDevelop.PackageManagement DelegateCommand browsePackageFolderCommand;
DelegateCommand updatePackageSourceCommand;
- RegisteredPackageSource newPackageSource = new RegisteredPackageSource();
+ PackageSourceViewModel newPackageSource = new PackageSourceViewModel ();
PackageSourceViewModel selectedPackageSourceViewModel;
bool isEditingSelectedPackageSource;
-
- public RegisteredPackageSourcesViewModel(
- IRegisteredPackageRepositories registeredPackageRepositories)
- : this(registeredPackageRepositories, new FolderBrowser())
+
+ public RegisteredPackageSourcesViewModel (ISourceRepositoryProvider sourceRepositoryProvider)
+ : this (sourceRepositoryProvider.PackageSourceProvider, new FolderBrowser ())
{
}
-
- public RegisteredPackageSourcesViewModel(
- IRegisteredPackageRepositories registeredPackageRepositories,
+
+ public RegisteredPackageSourcesViewModel (
+ NuGet.Configuration.IPackageSourceProvider packageSourceProvider,
IFolderBrowser folderBrowser)
{
- this.packageSources = registeredPackageRepositories.PackageSources;
+ this.packageSourceProvider = packageSourceProvider;
this.folderBrowser = folderBrowser;
- this.registeredPackageRepositories = registeredPackageRepositories;
packageSourceChecker.PackageSourceChecked += PackageSourceChecked;
- CreateCommands();
+ CreateCommands ();
}
void PackageSourceChecked (object sender, PackageSourceViewModelCheckedEventArgs e)
@@ -140,11 +138,18 @@ namespace MonoDevelop.PackageManagement {
ReplaceExistingPackageSourceCredentialProvider ();
- foreach (PackageSource packageSource in packageSources) {
+ foreach (NuGet.Configuration.PackageSource packageSource in GetPackageSourcesFromProvider ()) {
AddPackageSourceToViewModel(packageSource);
}
}
+ IEnumerable<NuGet.Configuration.PackageSource> GetPackageSourcesFromProvider ()
+ {
+ return packageSourceProvider
+ .LoadPackageSources ()
+ .Where (packageSource => !packageSource.IsMachineWide);
+ }
+ /// <summary>
/// Use this class as the source of package source credentials and disable any
/// prompt for credentials.
@@ -154,13 +159,27 @@ namespace MonoDevelop.PackageManagement HttpClient.DefaultCredentialProvider = new SettingsCredentialProvider (NullCredentialProvider.Instance, this);
}
- void AddPackageSourceToViewModel(PackageSource packageSource)
+ void AddPackageSourceToViewModel (NuGet.Configuration.PackageSource packageSource)
{
var packageSourceViewModel = new PackageSourceViewModel(packageSource);
packageSourceViewModels.Add(packageSourceViewModel);
packageSourceChecker.Check (packageSourceViewModel);
}
+
+ void AddPackageSourceToViewModel (NuGet.Configuration.PackageSource packageSource, string password)
+ {
+ // HACK: Workaround NuGet 3.4.3 bug.
+ // Set the password text after the view model is created.
+ packageSource.PasswordText = null;
+
+ var packageSourceViewModel = new PackageSourceViewModel (packageSource);
+ packageSourceViewModel.Password = password;
+
+ packageSourceViewModels.Add(packageSourceViewModel);
+
+ packageSourceChecker.Check (packageSourceViewModel);
+ }
public void Save()
{
@@ -194,7 +213,11 @@ namespace MonoDevelop.PackageManagement public string NewPackageSourcePassword {
get { return newPackageSource.Password; }
set {
- newPackageSource.Password = value;
+ if (String.IsNullOrEmpty (value)) {
+ newPackageSource.Password = null;
+ } else {
+ newPackageSource.Password = value;
+ }
OnPropertyChanged(viewModel => viewModel.NewPackageSourcePassword);
}
}
@@ -216,9 +239,10 @@ namespace MonoDevelop.PackageManagement void AddNewPackageSourceToViewModel()
{
- var packageSource = newPackageSource.ToPackageSource();
+ var packageSource = newPackageSource.GetPackageSource ();
packageSource.IsEnabled = true;
- AddPackageSourceToViewModel(packageSource);
+
+ AddPackageSourceToViewModel (packageSource, newPackageSource.Password);
}
void SelectLastPackageSourceViewModel()
@@ -313,18 +337,22 @@ namespace MonoDevelop.PackageManagement return packageSourceViewModels.Last();
}
- public void BrowsePackageFolder()
+ public bool BrowsePackageFolder()
{
string folder = folderBrowser.SelectFolder();
if (folder != null) {
UpdateNewPackageSourceUsingSelectedFolder(folder);
+ return true;
}
+ return false;
}
void UpdateNewPackageSourceUsingSelectedFolder(string folder)
{
NewPackageSourceUrl = folder;
- NewPackageSourceName = GetPackageSourceNameFromFolder(folder);
+ if (String.IsNullOrEmpty (NewPackageSourceName)) {
+ NewPackageSourceName = GetPackageSourceNameFromFolder (folder);
+ }
}
string GetPackageSourceNameFromFolder(string folder)
@@ -338,7 +366,7 @@ namespace MonoDevelop.PackageManagement isEditingSelectedPackageSource = value;
if (isEditingSelectedPackageSource) {
NewPackageSourceName = selectedPackageSourceViewModel.Name;
- NewPackageSourceUrl = selectedPackageSourceViewModel.SourceUrl;
+ NewPackageSourceUrl = selectedPackageSourceViewModel.Source;
NewPackageSourceUserName = selectedPackageSourceViewModel.UserName;
NewPackageSourcePassword = selectedPackageSourceViewModel.Password;
} else {
@@ -361,7 +389,7 @@ namespace MonoDevelop.PackageManagement public void UpdatePackageSource ()
{
selectedPackageSourceViewModel.Name = NewPackageSourceName;
- selectedPackageSourceViewModel.SourceUrl = NewPackageSourceUrl;
+ selectedPackageSourceViewModel.Source = NewPackageSourceUrl;
selectedPackageSourceViewModel.UserName = NewPackageSourceUserName;
selectedPackageSourceViewModel.Password = NewPackageSourcePassword;
@@ -372,7 +400,7 @@ namespace MonoDevelop.PackageManagement public void Save (IEnumerable<PackageSourceViewModel> packageSourceViewModels)
{
- registeredPackageRepositories.UpdatePackageSources (
+ packageSourceProvider.SavePackageSources (
packageSourceViewModels.Select (viewModel => viewModel.GetPackageSource ()));
}
@@ -390,7 +418,7 @@ namespace MonoDevelop.PackageManagement try {
packageSourceChecker.Dispose ();
} finally {
- PackageManagementServices.InitializeCredentialProvider ();
+ PackageManagementServices.InitializeCredentialService ();
}
}
@@ -401,7 +429,7 @@ namespace MonoDevelop.PackageManagement /// </summary>
IEnumerable<PackageSource> IPackageSourceProvider.LoadPackageSources ()
{
- return packageSourceViewModels.Select (viewModel => viewModel.GetPackageSource ());
+ return packageSourceViewModels.Select (viewModel => viewModel.GetNuGet2PackageSource ());
}
void IPackageSourceProvider.SavePackageSources (IEnumerable<PackageSource> sources)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredProjectTemplatePackageSources.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredProjectTemplatePackageSources.cs deleted file mode 100644 index a78f93a9ad..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RegisteredProjectTemplatePackageSources.cs +++ /dev/null @@ -1,59 +0,0 @@ -//
-// RegisteredProjectTemplatePackageSources.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 System.Collections.Generic;
-using NuGet;
-using Mono.Addins;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Ide.Templates;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RegisteredProjectTemplatePackageSources
- {
- RegisteredPackageSources packageSources = new RegisteredPackageSources();
-
- public RegisteredProjectTemplatePackageSources ()
- {
- packageSources = new RegisteredPackageSources (GetPackageSources ());
- }
-
- List<PackageSource> GetPackageSources()
- {
- var addinPackageSources = new List<PackageSource> ();
- foreach (PackageRepositoryNode node in AddinManager.GetExtensionNodes ("/MonoDevelop/Ide/ProjectTemplatePackageRepositories")) {
- addinPackageSources.Add (node.GetPackageSource ());
- }
- addinPackageSources.Add (RegisteredPackageSources.DefaultPackageSource);
- return addinPackageSources;
- }
-
- public RegisteredPackageSources PackageSources {
- get { return packageSources; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallNuGetPackageAction.cs new file mode 100644 index 0000000000..e3b4645654 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallNuGetPackageAction.cs @@ -0,0 +1,144 @@ +//
+// ReinstallNuGetPackageAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Threading;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+using NuGet.Versioning;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class ReinstallNuGetPackageAction : IPackageAction
+ {
+ INuGetProjectContext context;
+ InstallNuGetPackageAction installAction;
+ UninstallNuGetPackageAction uninstallAction;
+ IPackageManagementEvents packageManagementEvents;
+
+ public ReinstallNuGetPackageAction (
+ IDotNetProject project,
+ IMonoDevelopSolutionManager solutionManager)
+ : this (
+ project,
+ solutionManager,
+ new NuGetProjectContext (),
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public ReinstallNuGetPackageAction (
+ IDotNetProject project,
+ IMonoDevelopSolutionManager solutionManager,
+ INuGetProjectContext projectContext,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.context = projectContext;
+ this.packageManagementEvents = packageManagementEvents;
+
+ var repositories = solutionManager.CreateSourceRepositoryProvider ().GetRepositories ();
+
+ installAction = CreateInstallAction (solutionManager, project, repositories);
+ uninstallAction = CreateUninstallAction (solutionManager, project);
+ }
+
+ public string PackageId { get; set; }
+ public NuGetVersion Version { get; set; }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
+ using (IDisposable fileMonitor = CreateFileMonitor ()) {
+ uninstallAction.PackageId = PackageId;
+ uninstallAction.ForceRemove = true;
+ uninstallAction.Execute (cancellationToken);
+
+ installAction.PackageId = PackageId;
+ installAction.Version = Version;
+ installAction.LicensesMustBeAccepted = false;
+ installAction.OpenReadmeFile = false;
+
+ // Local copy references need to be preserved before the uninstall starts so
+ // we must disable this for the install action otherwise they will not be
+ // preserved.
+ installAction.PreserveLocalCopyReferences = false;
+
+ installAction.Execute (cancellationToken);
+ }
+ }
+ }
+
+ public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ protected virtual UninstallNuGetPackageAction CreateUninstallAction (IMonoDevelopSolutionManager solutionManager, IDotNetProject project)
+ {
+ return new UninstallNuGetPackageAction (
+ solutionManager,
+ project) {
+ };
+ }
+
+ protected virtual InstallNuGetPackageAction CreateInstallAction (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject project,
+ IEnumerable<SourceRepository> repositories)
+ {
+ return new InstallNuGetPackageAction (
+ repositories,
+ solutionManager,
+ project,
+ context
+ );
+ }
+
+ LocalCopyReferenceMaintainer CreateLocalCopyReferenceMaintainer ()
+ {
+ return new LocalCopyReferenceMaintainer (packageManagementEvents);
+ }
+
+ IDisposable CreateFileMonitor ()
+ {
+ return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
+ packageManagementEvents,
+ GetFileRemover ());
+ }
+
+ protected virtual IFileRemover GetFileRemover ()
+ {
+ return new FileRemover ();
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs deleted file mode 100644 index de0211a8fd..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallPackageAction.cs +++ /dev/null @@ -1,92 +0,0 @@ -//
-// ReinstallPackageAction.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 MonoDevelop.Components.Commands;
-using MonoDevelop.Core;
-using MonoDevelop.Ide.Commands;
-using MonoDevelop.Ide.Gui.Components;
-using MonoDevelop.PackageManagement.NodeBuilders;
-using MonoDevelop.Projects;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal 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 {
- get { return GettextCatalog.GetString ("Retargeting {0}...") + Environment.NewLine; }
- }
-
- protected override void ExecuteCore ()
- {
- using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
- using (IDisposable monitor = CreateFileMonitor (fileRemover)) {
- UninstallPackage ();
- }
- InstallPackage ();
- }
- }
-
- void UninstallPackage ()
- {
- UninstallPackageAction action = Project.CreateUninstallPackageAction ();
- action.Package = Package;
- action.ForceRemove = true;
- action.Execute ();
- }
-
- void InstallPackage ()
- {
- InstallPackageAction action = Project.CreateInstallPackageAction ();
- action.Package = Package;
- action.OpenReadMeText = false;
- action.PreserveLocalCopyReferences = false;
- action.LicensesMustBeAccepted = false;
- action.Execute ();
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallProjectPackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallProjectPackagesAction.cs deleted file mode 100644 index 93eaa2e337..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ReinstallProjectPackagesAction.cs +++ /dev/null @@ -1,163 +0,0 @@ -//
-// ReinstallProjectPackagesAction.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ReinstallProjectPackagesAction : IPackageAction
- {
- IPackageManagementProject project;
- IPackageManagementEvents packageManagementEvents;
- List<IPackage> packagesFromSourceRepository;
- List<IPackage> projectPackages;
- ReinstallPackageOperations operations;
-
- public ReinstallProjectPackagesAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- {
- this.project = project;
- this.packageManagementEvents = packageManagementEvents;
- }
-
- public IEnumerable<IPackage> Packages {
- get {
- BeforeExecute ();
- return projectPackages;
- }
- }
-
- public bool UpdateDependencies { get; set; }
- public bool AllowPrereleaseVersions { get; set; }
-
- public bool HasPackageScriptsToRun ()
- {
- return false;
- }
-
- void BeforeExecute ()
- {
- if (projectPackages != null)
- return;
-
- GetProjectPackagesToReinstall ();
- }
-
- public void Execute ()
- {
- BeforeExecute ();
- //if (PackageScriptRunner != null) {
- // ExecuteWithScriptRunner();
- //} else {
- ExecuteCore ();
- //}
- }
-
- void ExecuteCore ()
- {
- LogReinstallingPackagesMessage ();
- GetPackagesFromSourceRepository ();
- UninstallPackages ();
- GetReinstallPackageOperations ();
- RunPackageOperations ();
- AddPackageReferences ();
- }
-
- void GetProjectPackagesToReinstall ()
- {
- projectPackages = project.GetPackages ().ToList ();
- }
-
- void LogReinstallingPackagesMessage ()
- {
- string message = GettextCatalog.GetString ("Retargeting packages...{0}", Environment.NewLine);
- packageManagementEvents.OnPackageOperationMessageLogged (MessageLevel.Info, message);
- }
-
- void GetPackagesFromSourceRepository ()
- {
- packagesFromSourceRepository = new List<IPackage> ();
- foreach (IPackage package in projectPackages) {
- packagesFromSourceRepository.Add (GetPackageFromSourceRepository (package));
- }
- }
-
- IPackage GetPackageFromSourceRepository (IPackage package)
- {
- IPackage foundPackage = project.SourceRepository.FindPackage (package.Id, package.Version);
- if (foundPackage == null) {
- ThrowPackageNotFoundInSourceRepository (package);
- }
- return foundPackage;
- }
-
- void ThrowPackageNotFoundInSourceRepository (IPackage package)
- {
- string message = GettextCatalog.GetString (
- "Package {0} {1} not found in package source.",
- package.Id,
- package.Version);
- throw new ApplicationException (message);
- }
-
- void UninstallPackages ()
- {
- foreach (IPackage package in projectPackages) {
- var uninstallAction = new UninstallPackageAction (project, packageManagementEvents) {
- ForceRemove = true,
- Package = package,
- RemoveDependencies = false,
- AllowPrereleaseVersions = false
- };
- uninstallAction.Execute ();
- }
- }
-
- void GetReinstallPackageOperations ()
- {
- operations = project.GetReinstallPackageOperations (packagesFromSourceRepository);
- }
-
- void RunPackageOperations ()
- {
- project.RunPackageOperations (operations.Operations);
- }
-
- void AddPackageReferences ()
- {
- foreach (IPackage package in operations.PackagesInDependencyOrder) {
- project.AddPackageReference (package);
- }
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ResolveFileConflictEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ResolveFileConflictEventArgs.cs index b220db95b5..b2dd69ccd6 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ResolveFileConflictEventArgs.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ResolveFileConflictEventArgs.cs @@ -27,7 +27,7 @@ //
using System;
-using NuGet;
+using NuGet.ProjectManagement;
namespace MonoDevelop.PackageManagement
{
@@ -36,10 +36,10 @@ namespace MonoDevelop.PackageManagement public ResolveFileConflictEventArgs(string message)
{
this.Message = message;
- this.Resolution = FileConflictResolution.Ignore;
+ this.Resolution = FileConflictAction.Ignore;
}
public string Message { get; private set; }
- public FileConflictResolution Resolution { get; set; }
+ public FileConflictAction Resolution { get; set; }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreAndCheckForUpdatesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreAndCheckForUpdatesAction.cs new file mode 100644 index 0000000000..41d76e8dee --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreAndCheckForUpdatesAction.cs @@ -0,0 +1,170 @@ +//
+// RestoreAndCheckForUpdatesAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+using NuGet.ProjectManagement.Projects;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class RestoreAndCheckForUpdatesAction : IPackageAction
+ {
+ List<PackageRestoreData> packagesToRestore;
+ IPackageRestoreManager restoreManager;
+ MonoDevelopBuildIntegratedRestorer buildIntegratedRestorer;
+ IMonoDevelopSolutionManager solutionManager;
+ IPackageManagementEvents packageManagementEvents;
+ Solution solution;
+ List<NuGetProject> nugetProjects;
+ List<BuildIntegratedNuGetProject> buildIntegratedProjectsToBeRestored;
+
+ public RestoreAndCheckForUpdatesAction (Solution solution)
+ {
+ this.solution = solution;
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+
+ solutionManager = PackageManagementServices.Workspace.GetSolutionManager (solution);
+ nugetProjects = solutionManager.GetNuGetProjects ().ToList ();
+
+ if (AnyProjectsUsingPackagesConfig ()) {
+ restoreManager = new PackageRestoreManager (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solutionManager
+ );
+ }
+
+ if (AnyProjectsUsingProjectJson ()) {
+ buildIntegratedRestorer = new MonoDevelopBuildIntegratedRestorer (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solution.BaseDirectory);
+ }
+ }
+
+ bool AnyProjectsUsingPackagesConfig ()
+ {
+ return nugetProjects.Any (project => !(project is BuildIntegratedNuGetProject));
+ }
+
+ bool AnyProjectsUsingProjectJson ()
+ {
+ return GetBuildIntegratedNuGetProjects ().Any ();
+ }
+
+ IEnumerable<BuildIntegratedNuGetProject> GetBuildIntegratedNuGetProjects ()
+ {
+ return nugetProjects.OfType<BuildIntegratedNuGetProject> ();
+ }
+
+ public bool CheckForUpdatesAfterRestore { get; set; }
+
+ public async Task<bool> HasMissingPackages (CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (restoreManager != null) {
+ var packages = await restoreManager.GetPackagesInSolutionAsync (
+ solutionManager.SolutionDirectory,
+ cancellationToken);
+
+ packagesToRestore = packages.ToList ();
+ if (packagesToRestore.Any (package => package.IsMissing)) {
+ return true;
+ }
+ }
+
+ if (buildIntegratedRestorer != null) {
+ var projects = await buildIntegratedRestorer.GetProjectsRequiringRestore (GetBuildIntegratedNuGetProjects ());
+ buildIntegratedProjectsToBeRestored = projects.ToList ();
+ return buildIntegratedProjectsToBeRestored.Any ();
+ }
+
+ return false;
+ }
+
+ public void Execute ()
+ {
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ RestorePackagesAsync (cancellationToken).Wait ();
+
+ if (CheckForUpdatesAfterRestore) {
+ CheckForUpdates ();
+ }
+ }
+
+ public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ void CheckForUpdates ()
+ {
+ try {
+ PackageManagementServices.UpdatedPackagesInWorkspace.CheckForUpdates (new SolutionProxy (solution));
+ } catch (Exception ex) {
+ LoggingService.LogError ("Check for NuGet package updates error.", ex);
+ }
+ }
+
+ async Task RestorePackagesAsync (CancellationToken cancellationToken)
+ {
+ if (restoreManager != null) {
+ using (var monitor = new PackageRestoreMonitor (restoreManager)) {
+ await restoreManager.RestoreMissingPackagesAsync (
+ solutionManager.SolutionDirectory,
+ packagesToRestore,
+ new NuGetProjectContext (),
+ cancellationToken);
+ }
+ }
+
+ if (buildIntegratedRestorer != null) {
+ await buildIntegratedRestorer.RestorePackages (buildIntegratedProjectsToBeRestored, cancellationToken);
+ }
+
+ await Runtime.RunInMainThread (() => RefreshProjectReferences ());
+
+ packageManagementEvents.OnPackagesRestored ();
+ }
+
+ void RefreshProjectReferences ()
+ {
+ foreach (DotNetProject dotNetProject in solution.GetAllDotNetProjects ()) {
+ dotNetProject.RefreshReferenceStatus ();
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreAndUninstallNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreAndUninstallNuGetPackageAction.cs new file mode 100644 index 0000000000..33fed70455 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreAndUninstallNuGetPackageAction.cs @@ -0,0 +1,143 @@ +// +// RestoreAndUninstallNuGetPackageAction.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MonoDevelop.Core; +using MonoDevelop.Ide; +using NuGet.PackageManagement; +using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.Versioning; + +namespace MonoDevelop.PackageManagement +{ + internal class RestoreAndUninstallNuGetPackageAction : INuGetPackageAction, INuGetProjectActionsProvider + { + RestoreNuGetPackagesInProjectAction restoreAction; + UninstallNuGetPackageAction uninstallAction; + IDotNetProject dotNetProject; + MSBuildNuGetProject nugetProject; + PackagePathResolver packagePathResolver; + + public RestoreAndUninstallNuGetPackageAction ( + IMonoDevelopSolutionManager solutionManager, + IDotNetProject dotNetProject) + { + this.dotNetProject = dotNetProject; + + nugetProject = solutionManager.GetNuGetProject (dotNetProject) as MSBuildNuGetProject; + packagePathResolver = new PackagePathResolver (nugetProject.GetPackagesFolderPath (solutionManager)); + + restoreAction = new RestoreNuGetPackagesInProjectAction ( + dotNetProject.DotNetProject, + nugetProject, + solutionManager); + + uninstallAction = new UninstallNuGetPackageAction (solutionManager, dotNetProject); + } + + public string PackageId { get; set; } + public NuGetVersion Version { get; set; } + + public void Execute () + { + Execute (CancellationToken.None); + } + + public void Execute (CancellationToken cancellationToken) + { + ExecuteAsync (cancellationToken).Wait (); + } + + async Task ExecuteAsync (CancellationToken cancellationToken) + { + try { + restoreAction.Execute (cancellationToken); + } catch (Exception ex) { + bool result = await OnRestoreFailure (cancellationToken); + if (!result) { + throw ex; + } + return; + } + + uninstallAction.PackageId = PackageId; + uninstallAction.Execute (cancellationToken); + } + + public IEnumerable<NuGetProjectAction> GetNuGetProjectActions () + { + return uninstallAction.GetNuGetProjectActions () ?? new NuGetProjectAction[0]; + } + + public bool HasPackageScriptsToRun () + { + return false; + } + + async Task<bool> OnRestoreFailure (CancellationToken cancellationToken) + { + bool result = await Runtime.RunInMainThread (async () => { + if (ShouldForceUninstall ()) { + await ForceUninstall (); + return true; + } + return false; + }); + + if (result) { + return await nugetProject.PackagesConfigNuGetProject.UninstallPackageAsync ( + new PackageIdentity (PackageId, Version), + new NuGetProjectContext (), + cancellationToken + ); + } + return result; + } + + bool ShouldForceUninstall () + { + AlertButton result = MessageService.AskQuestion ( + GettextCatalog.GetString ("Unable to restore {0} package before removing. Do you want to force the NuGet package to be removed?", PackageId), + GettextCatalog.GetString ("Forcing a NuGet package to be removed may break the build."), + AlertButton.Yes, + AlertButton.No); + + return result == AlertButton.Yes; + } + + Task ForceUninstall () + { + var uninstaller = new NuGetPackageUninstaller (dotNetProject, packagePathResolver); + return uninstaller.ForceUninstall (PackageId, Version); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreBeforeUpdateAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreBeforeUpdateAction.cs deleted file mode 100644 index 55a64da3e3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreBeforeUpdateAction.cs +++ /dev/null @@ -1,106 +0,0 @@ -//
-// RestoreBeforeUpdateAction.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RestoreBeforeUpdateAction
- {
- IPackageManagementProjectService projectService;
- IBackgroundPackageActionRunner backgroundRunner;
-
- public RestoreBeforeUpdateAction ()
- : this (
- PackageManagementServices.ProjectService,
- PackageManagementServices.BackgroundPackageActionRunner)
- {
- }
-
- public RestoreBeforeUpdateAction (
- IPackageManagementProjectService projectService,
- IBackgroundPackageActionRunner backgroundRunner)
- {
- this.projectService = projectService;
- this.backgroundRunner = backgroundRunner;
- }
-
- public static void Restore (
- IPackageManagementSolution solution,
- IPackageManagementProject project,
- Action afterRestore)
- {
- var runner = new RestoreBeforeUpdateAction ();
- runner.RestoreProjectPackages (solution, project.DotNetProject, afterRestore);
- }
-
- public static void Restore (
- IPackageManagementSolution solution,
- IEnumerable<IPackageManagementProject> projects,
- Action afterRestore)
- {
- var runner = new RestoreBeforeUpdateAction ();
- runner.RestoreAllPackagesInSolution (
- solution,
- projects.Select (project => project.DotNetProject),
- afterRestore);
- }
-
- public void RestoreAllPackagesInSolution (
- IPackageManagementSolution solution,
- IEnumerable<DotNetProject> projects,
- Action afterRestore)
- {
- var restorer = new PackageRestorer (solution, projects);
- Restore (restorer, afterRestore);
- }
-
- void Restore (PackageRestorer restorer, Action afterRestore)
- {
- ProgressMonitorStatusMessage progressMessage = ProgressMonitorStatusMessageFactory.CreateRestoringPackagesBeforeUpdateMessage ();
-
- PackageManagementBackgroundDispatcher.Dispatch (() => {
- restorer.Restore (progressMessage);
- if (!restorer.RestoreFailed) {
- afterRestore ();
- }
- });
- }
-
- public void RestoreProjectPackages (
- IPackageManagementSolution solution,
- DotNetProject project,
- Action afterRestore)
- {
- var restorer = new PackageRestorer (solution, project);
- Restore (restorer, afterRestore);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesAction.cs new file mode 100644 index 0000000000..0c9c2dade3 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesAction.cs @@ -0,0 +1,134 @@ +//
+// RestoreNuGetPackagesAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+using NuGet.ProjectManagement.Projects;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class RestoreNuGetPackagesAction : IPackageAction
+ {
+ IPackageRestoreManager restoreManager;
+ MonoDevelopBuildIntegratedRestorer buildIntegratedRestorer;
+ IMonoDevelopSolutionManager solutionManager;
+ IPackageManagementEvents packageManagementEvents;
+ Solution solution;
+ List<NuGetProject> nugetProjects;
+
+ public RestoreNuGetPackagesAction (Solution solution)
+ {
+ this.solution = solution;
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+
+ solutionManager = PackageManagementServices.Workspace.GetSolutionManager (solution);
+
+ nugetProjects = solutionManager.GetNuGetProjects ().ToList ();
+
+ if (AnyProjectsUsingPackagesConfig ()) {
+ restoreManager = new PackageRestoreManager (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solutionManager
+ );
+ }
+
+ if (AnyProjectsUsingProjectJson ()) {
+ buildIntegratedRestorer = new MonoDevelopBuildIntegratedRestorer (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solution.BaseDirectory);
+ }
+ }
+
+ + bool AnyProjectsUsingPackagesConfig ()
+ {
+ return nugetProjects.Any (project => !(project is BuildIntegratedNuGetProject));
+ }
+
+ bool AnyProjectsUsingProjectJson ()
+ {
+ return GetBuildIntegratedNuGetProjects ().Any ();
+ }
+
+ IEnumerable<BuildIntegratedNuGetProject> GetBuildIntegratedNuGetProjects ()
+ {
+ return nugetProjects.OfType<BuildIntegratedNuGetProject> ();
+ }
+ + public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+
+ public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ if (restoreManager != null) {
+ using (var monitor = new PackageRestoreMonitor (restoreManager)) {
+ await restoreManager.RestoreMissingPackagesInSolutionAsync (
+ solutionManager.SolutionDirectory,
+ new NuGetProjectContext (),
+ cancellationToken);
+ }
+ }
+
+ if (buildIntegratedRestorer != null) {
+ await buildIntegratedRestorer.RestorePackages (
+ GetBuildIntegratedNuGetProjects (),
+ cancellationToken);
+ }
+
+ await Runtime.RunInMainThread (() => RefreshProjectReferences ());
+
+ packageManagementEvents.OnPackagesRestored ();
+ }
+ + void RefreshProjectReferences ()
+ {
+ foreach (DotNetProject dotNetProject in solution.GetAllDotNetProjects ()) {
+ dotNetProject.RefreshReferenceStatus ();
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesInNuGetIntegratedProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesInNuGetIntegratedProject.cs new file mode 100644 index 0000000000..bc7f14724e --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesInNuGetIntegratedProject.cs @@ -0,0 +1,82 @@ +//
+// RestoreNuGetPackagesInNuGetIntegratedProject.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.ProjectManagement.Projects;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class RestoreNuGetPackagesInNuGetIntegratedProject : IPackageAction
+ {
+ DotNetProject project;
+ BuildIntegratedNuGetProject nugetProject;
+ MonoDevelopBuildIntegratedRestorer packageRestorer;
+ IPackageManagementEvents packageManagementEvents;
+
+ public RestoreNuGetPackagesInNuGetIntegratedProject (
+ DotNetProject project,
+ BuildIntegratedNuGetProject nugetProject,
+ IMonoDevelopSolutionManager solutionManager)
+ {
+ this.project = project;
+ this.nugetProject = nugetProject;
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+
+ packageRestorer = new MonoDevelopBuildIntegratedRestorer (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solutionManager.SolutionDirectory);
+ }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+
+ public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ await packageRestorer.RestorePackages (nugetProject, cancellationToken);
+
+ await Runtime.RunInMainThread (() => project.RefreshReferenceStatus ());
+
+ packageManagementEvents.OnPackagesRestored ();
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesInProjectAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesInProjectAction.cs new file mode 100644 index 0000000000..cd0fa7c3d1 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestoreNuGetPackagesInProjectAction.cs @@ -0,0 +1,100 @@ +//
+// RestoreNuGetPackagesInProjectAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class RestoreNuGetPackagesInProjectAction : IPackageAction
+ {
+ IMonoDevelopSolutionManager solutionManager;
+ IPackageManagementEvents packageManagementEvents;
+ PackageRestoreManager restoreManager;
+ NuGetProject nugetProject;
+ DotNetProject project;
+
+ public RestoreNuGetPackagesInProjectAction (
+ DotNetProject project,
+ NuGetProject nugetProject,
+ IMonoDevelopSolutionManager solutionManager)
+ {
+ this.project = project;
+ this.nugetProject = nugetProject;
+ this.solutionManager = solutionManager;
+
+ packageManagementEvents = PackageManagementServices.PackageManagementEvents;
+
+ restoreManager = new PackageRestoreManager (
+ solutionManager.CreateSourceRepositoryProvider (),
+ solutionManager.Settings,
+ solutionManager
+ );
+ }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+
+ public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ using (var monitor = new PackageRestoreMonitor (restoreManager)) {
+ await restoreManager.RestoreMissingPackagesAsync (
+ solutionManager.SolutionDirectory,
+ nugetProject,
+ new NuGetProjectContext (),
+ cancellationToken);
+ }
+
+ await Runtime.RunInMainThread (() => RefreshProjectReferences ());
+
+ packageManagementEvents.OnPackagesRestored ();
+ }
+
+ void RefreshProjectReferences ()
+ {
+ foreach (DotNetProject dotNetProject in project.ParentSolution.GetAllDotNetProjects ()) {
+ dotNetProject.RefreshReferenceStatus ();
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestorePackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestorePackagesAction.cs deleted file mode 100644 index eb0c959263..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/RestorePackagesAction.cs +++ /dev/null @@ -1,194 +0,0 @@ -//
-// RestorePackagesAction.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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-using MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class RestorePackagesAction : IPackageAction
- {
- IPackageManagementSolution solution;
- IPackageManagementEvents packageManagementEvents;
- ISolutionPackageRepository solutionPackageRepository;
- IPackageRepositoryCache repositoryCache;
- IPackageManagerFactory packageManagerFactory;
- ILogger logger;
-
- public RestorePackagesAction ()
- : this (
- PackageManagementServices.Solution,
- PackageManagementServices.PackageManagementEvents)
- {
- }
-
- public RestorePackagesAction (
- IPackageManagementSolution solution,
- IPackageManagementEvents packageManagementEvents)
- : this (
- solution,
- packageManagementEvents,
- PackageManagementServices.PackageRepositoryCache,
- new MonoDevelopPackageManagerFactory ())
- {
- }
-
- public RestorePackagesAction (
- IPackageManagementSolution solution,
- IPackageManagementEvents packageManagementEvents,
- IPackageRepositoryCache repositoryCache,
- IPackageManagerFactory packageManagerFactory)
- {
- this.solution = solution;
- this.packageManagementEvents = packageManagementEvents;
- this.repositoryCache = repositoryCache;
- this.packageManagerFactory = packageManagerFactory;
-
- logger = new PackageManagementLogger (packageManagementEvents);
- }
-
- public IDotNetProject Project { get; set; }
-
- public void Execute ()
- {
- Log ("Restoring packages...");
-
- int packagesRestored = 0;
- List<PackageReference> packageReferences = GetPackageReferences ().ToList ();
- foreach (PackageReference packageReference in packageReferences) {
- if (IsPackageRestored (packageReference)) {
- LogPackageAlreadyRestored (packageReference);
- } else {
- packagesRestored++;
- RestorePackage (packageReference.Id, packageReference.Version);
- }
- }
-
- LogResult (packageReferences.Count, packagesRestored);
- }
-
- void Log (string message)
- {
- logger.Log (MessageLevel.Info, message);
- }
-
- void LogPackageAlreadyRestored (PackageReference packageReference)
- {
- logger.Log (MessageLevel.Debug, GettextCatalog.GetString ("Skipping '{0}' because it is already restored.", packageReference));
- }
-
- void LogResult (int totalPackageReferences, int packagesRestored)
- {
- if (packagesRestored == 0) {
- Log (GettextCatalog.GetString ("All packages are already restored."));
- } else if (packagesRestored > 0) {
- Log (GettextCatalog.GetPluralString ("1 package restored successfully.", "{0} packages restored successfully.", packagesRestored, packagesRestored));
- }
- }
-
- IEnumerable<PackageReference> GetPackageReferences ()
- {
- if (Project != null) {
- return GetPackageReferencesForSingleProject ();
- }
- return GetPackageReferencesForSolution ()
- .Concat (GetPackageReferencesForAllProjects ());
- }
-
- IEnumerable<PackageReference> GetPackageReferencesForSingleProject ()
- {
- IPackageRepository repository = repositoryCache.CreateAggregateRepository ();
- IPackageManagementProject project = solution.GetProject (repository, Project);
- return project.GetPackageReferences ();
- }
-
- IEnumerable<PackageReference> GetPackageReferencesForSolution ()
- {
- return SolutionPackageRepository.GetPackageReferences ();
- }
-
- IEnumerable<PackageReference> GetPackageReferencesForAllProjects ()
- {
- return solution
- .GetProjects (repositoryCache.CreateAggregateRepository ())
- .SelectMany (project => project.GetPackageReferences ())
- .Distinct ();
- }
-
- bool IsPackageRestored (PackageReference packageReference)
- {
- return SolutionPackageRepository.IsRestored (packageReference);
- }
-
- ISolutionPackageRepository SolutionPackageRepository {
- get {
- if (solutionPackageRepository == null) {
- solutionPackageRepository = solution.GetRepository ();
- }
- return solutionPackageRepository;
- }
- }
-
- void RestorePackage (string packageId, SemanticVersion version)
- {
- IPackageRepository sourceRepository = CreateSourceRepository ();
- using (IDisposable operation = sourceRepository.StartRestoreOperation (packageId, version.ToString ())) {
- IPackage package = PackageHelper.ResolvePackage (sourceRepository, packageId, version);
- IPackageManager packageManager = CreatePackageManager (sourceRepository);
-
- packageManager.InstallPackage (
- package,
- ignoreDependencies: true,
- allowPrereleaseVersions: true,
- ignoreWalkInfo: true);
-
- packageManagementEvents.OnPackageRestored (package);
- }
- }
-
- IPackageRepository CreateSourceRepository ()
- {
- return repositoryCache.CreateAggregateWithPriorityMachineCacheRepository ();
- }
-
- IPackageManager CreatePackageManager (IPackageRepository sourceRepository)
- {
- IPackageManager packageManager = packageManagerFactory.CreatePackageManager (sourceRepository, SolutionPackageRepository);
- packageManager.Logger = logger;
- return packageManager;
- }
-
- public bool HasPackageScriptsToRun ()
- {
- return false;
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsEventArgs.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsEventArgs.cs deleted file mode 100644 index c4a9527c8a..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsEventArgs.cs +++ /dev/null @@ -1,45 +0,0 @@ -//
-// SelectProjectsEventArgs.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class SelectProjectsEventArgs : EventArgs
- {
- public SelectProjectsEventArgs(IEnumerable<IPackageManagementSelectedProject> selectedProjects)
- {
- this.SelectedProjects = selectedProjects;
- }
-
- public IEnumerable<IPackageManagementSelectedProject> SelectedProjects { get; private set; }
-
- public bool IsAccepted { get; set; }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsService.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsService.cs deleted file mode 100644 index 72063554e5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsService.cs +++ /dev/null @@ -1,52 +0,0 @@ -//
-// SelectProjectsService.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using MonoDevelop.Ide;
-using MonoDevelop.PackageManagement;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class SelectProjectsService : ISelectProjectsService
- {
- public bool SelectProjects(IEnumerable<IPackageManagementSelectedProject> projects)
- {
- using (SelectProjectsDialog dialog = CreateSelectProjectsDialog (projects)) {
- int result = MessageService.ShowCustomDialog (dialog);
- return result == (int)Gtk.ResponseType.Ok;
- }
- }
-
- SelectProjectsDialog CreateSelectProjectsDialog(IEnumerable<IPackageManagementSelectedProject> projects)
- {
- var viewModel = new SelectProjectsViewModel(projects);
- return new SelectProjectsDialog(viewModel);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsViewModel.cs deleted file mode 100644 index 921e24f5c4..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectProjectsViewModel.cs +++ /dev/null @@ -1,61 +0,0 @@ -//
-// SelectProjectsViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Collections.ObjectModel;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class SelectProjectsViewModel
- {
- ObservableCollection<IPackageManagementSelectedProject> projects =
- new ObservableCollection<IPackageManagementSelectedProject>();
-
- public SelectProjectsViewModel(IEnumerable<IPackageManagementSelectedProject> projects)
- {
- AddProjects(projects);
- }
-
- void AddProjects(IEnumerable<IPackageManagementSelectedProject> projects)
- {
- foreach (IPackageManagementSelectedProject project in projects) {
- AddProject(project);
- }
- }
-
- void AddProject(IPackageManagementSelectedProject project)
- {
- projects.Add(project);
- }
-
- public ObservableCollection<IPackageManagementSelectedProject> Projects {
- get { return projects; }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectedProjectsForInstalledPackages.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectedProjectsForInstalledPackages.cs deleted file mode 100644 index cd839669d2..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectedProjectsForInstalledPackages.cs +++ /dev/null @@ -1,45 +0,0 @@ -//
-// SelectedProjectsForInstalledPackages.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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
-{
- internal class SelectedProjectsForInstalledPackages : PackageManagementSelectedProjects
- {
- public SelectedProjectsForInstalledPackages(IPackageManagementSolution solution)
- : base(solution)
- {
- }
-
- protected override bool IsProjectSelected(IPackageManagementProject project, IPackageFromRepository package)
- {
- return project.IsPackageInstalled(package);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectedProjectsForUpdatedPackages.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectedProjectsForUpdatedPackages.cs deleted file mode 100644 index 82bb39d287..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SelectedProjectsForUpdatedPackages.cs +++ /dev/null @@ -1,59 +0,0 @@ -//
-// SelectedProjectsForUpdatedPackages.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class SelectedProjectsForUpdatedPackages : PackageManagementSelectedProjects
- {
- public SelectedProjectsForUpdatedPackages(IPackageManagementSolution solution)
- : base(solution)
- {
- }
-
- protected override bool IsProjectSelected(IPackageManagementProject project, IPackageFromRepository package)
- {
- return IsProjectEnabled(project, package);
- }
-
- protected override bool IsProjectEnabled(IPackageManagementProject project, IPackageFromRepository package)
- {
- return project.GetPackages()
- .Where(p => IsPackageIdMatch(p.Id, package.Id))
- .Any(p => p.Version < package.Version);
- }
-
- bool IsPackageIdMatch(string id1, string id2)
- {
- return String.Equals(id1, id2, StringComparison.InvariantCultureIgnoreCase);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsFactory.cs deleted file mode 100644 index 8f41306204..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsFactory.cs +++ /dev/null @@ -1,42 +0,0 @@ -//
-// SettingsFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class SettingsFactory : ISettingsFactory
- {
- public ISettings CreateSettings(string directory)
- {
- var fileSystem = new PhysicalFileSystem(directory);
- return new Settings(fileSystem);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsLoader.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsLoader.cs new file mode 100644 index 0000000000..0d06291673 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsLoader.cs @@ -0,0 +1,75 @@ +// +// SettingsLoader.cs +// +// Author: +// Matt Ward <matt.ward@xamarin.com> +// +// Copyright (c) 2016 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 System.Security.Cryptography; +using MonoDevelop.Core; +using NuGet.Configuration; + +namespace MonoDevelop.PackageManagement +{ + internal static class SettingsLoader + { + public static ISettings LoadDefaultSettings (bool reportError = false) + { + return LoadDefaultSettings (null, reportError); + } + + public static ISettings LoadDefaultSettings (string rootDirectory, bool reportError = false) + { + try { + return Settings.LoadDefaultSettings (rootDirectory, null, null); + } catch (Exception ex) { + if (reportError) { + ShowReadNuGetConfigFileError (ex); + } else { + LoggingService.LogError ("Unable to load global NuGet.Config.", ex); + } + } + + return NullSettings.Instance; + } + + static void ShowReadNuGetConfigFileError (Exception ex) + { + Ide.MessageService.ShowError ( + GettextCatalog.GetString ("Unable to read the NuGet.Config file"), + String.Format (GetReadNuGetConfigFileErrorMessage (ex), + ex.Message), + ex); + } + + static string GetReadNuGetConfigFileErrorMessage (Exception ex) + { + if (ex is CryptographicException) { + return GettextCatalog.GetString ("Unable to decrypt passwords stored in the NuGet.Config file. The NuGet.Config file will be treated as read-only."); + } + + return GettextCatalog.GetString ("An error occurred when trying to read the NuGet.Config file. The NuGet.Config file will be treated as read-only.\n\n{0}"); + } + } +} + diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsProvider.cs index febdee98d5..630b452812 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsProvider.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SettingsProvider.cs @@ -26,7 +26,6 @@ using System;
using System.IO;
-using MonoDevelop.PackageManagement;
using NuGet;
using MonoDevelop.Core;
@@ -38,11 +37,7 @@ namespace MonoDevelop.PackageManagement = Settings.LoadDefaultSettings;
IPackageManagementProjectService projectService;
-
- public SettingsProvider ()
- : this (PackageManagementServices.ProjectService)
- {
- }
+ ISolution solution;
public SettingsProvider (IPackageManagementProjectService projectService)
{
@@ -51,6 +46,11 @@ namespace MonoDevelop.PackageManagement projectService.SolutionUnloaded += OnSettingsChanged;
}
+ public SettingsProvider (ISolution solution)
+ {
+ this.solution = solution;
+ }
+
public event EventHandler SettingsChanged;
void OnSettingsChanged (object sender, EventArgs e)
@@ -73,13 +73,21 @@ namespace MonoDevelop.PackageManagement string GetSolutionDirectory ()
{
- ISolution solution = projectService.OpenSolution;
+ ISolution solution = GetSolution ();
if (solution != null) {
return Path.Combine (solution.BaseDirectory, ".nuget");
}
return null;
}
+ ISolution GetSolution ()
+ {
+ if (solution != null)
+ return solution;
+
+ return projectService.OpenSolution;
+ }
+
ISettings LoadSettings (string directory)
{
if (directory == null) {
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepository.cs index 0f2d920814..99f03d5e30 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepository.cs @@ -47,17 +47,17 @@ namespace MonoDevelop.PackageManagement : this (
solution,
new MonoDevelopPackageRepositoryFactory(),
- PackageManagementServices.Options)
+ new SettingsProvider (solution))
{
}
public SolutionPackageRepository (
ISolution solution,
IMonoDevelopPackageRepositoryFactory repositoryFactory,
- PackageManagementOptions options)
+ ISettingsProvider settingsProvider)
{
this.repositoryFactory = repositoryFactory;
- repositoryPath = new SolutionPackageRepositoryPath(solution, options);
+ repositoryPath = new SolutionPackageRepositoryPath(solution, settingsProvider);
CreatePackagePathResolver();
CreateFileSystem();
CreateRepository(ConfigSettingsFileSystem.CreateConfigSettingsFileSystem(solution));
@@ -89,56 +89,5 @@ namespace MonoDevelop.PackageManagement public IPackagePathResolver PackagePathResolver {
get { return packagePathResolver; }
}
-
- public string GetInstallPath(IPackage package)
- {
- return repositoryPath.GetInstallPath(package);
- }
-
- public IEnumerable<IPackage> GetPackagesByDependencyOrder()
- {
- var packageSorter = new PackageSorter(null);
- return packageSorter.GetPackagesByDependencyOrder(repository);
- }
-
- public IEnumerable<IPackage> GetPackagesByReverseDependencyOrder()
- {
- return GetPackagesByDependencyOrder().Reverse();
- }
-
- public bool IsInstalled(IPackage package)
- {
- return repository.Exists(package);
- }
-
- public IQueryable<IPackage> GetPackages()
- {
- return repository.GetPackages();
- }
-
- public bool IsRestored (PackageReference packageReference)
- {
- if (packageReference.Version == null) {
- return false;
- }
-
- return CreateLocalPackageRepository ()
- .GetPackageLookupPaths (packageReference.Id, packageReference.Version)
- .Any ();
- }
-
- protected virtual LocalPackageRepository CreateLocalPackageRepository ()
- {
- return new LocalPackageRepository (packagePathResolver, fileSystem);
- }
-
- public IEnumerable<PackageReference> GetPackageReferences ()
- {
- var sharedRepository = Repository as SharedPackageRepository;
- if (sharedRepository != null) {
- return sharedRepository.PackageReferenceFile.GetPackageReferences ();
- }
- return Enumerable.Empty <PackageReference> ();
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryFactory.cs deleted file mode 100644 index f33e29a16b..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryFactory.cs +++ /dev/null @@ -1,59 +0,0 @@ -//
-// SolutionPackageRepositoryFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class SolutionPackageRepositoryFactory : ISolutionPackageRepositoryFactory
- {
- IMonoDevelopPackageRepositoryFactory repositoryFactory;
- PackageManagementOptions options;
-
- public SolutionPackageRepositoryFactory()
- : this(PackageManagementServices.PackageRepositoryCache, PackageManagementServices.Options)
- {
- }
-
- public SolutionPackageRepositoryFactory(
- IMonoDevelopPackageRepositoryFactory repositoryFactory,
- PackageManagementOptions options)
- {
- this.repositoryFactory = repositoryFactory;
- this.options = options;
- }
-
- public ISolutionPackageRepository CreateSolutionPackageRepository (ISolution solution)
- {
- return new SolutionPackageRepository (solution, repositoryFactory, options);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryPath.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryPath.cs index 2bc36444f7..45547cd9c5 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryPath.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionPackageRepositoryPath.cs @@ -37,44 +37,42 @@ namespace MonoDevelop.PackageManagement internal class SolutionPackageRepositoryPath
{
ISolution solution;
- DefaultPackagePathResolver pathResolver;
public SolutionPackageRepositoryPath(Project project)
- : this (new ProjectProxy (project), PackageManagementServices.Options)
+ : this (new ProjectProxy (project))
+ {
+ }
+
+ public SolutionPackageRepositoryPath (IProject project)
+ : this (project, new SettingsProvider (project.ParentSolution))
{
}
public SolutionPackageRepositoryPath (
IProject project,
- PackageManagementOptions options)
- : this (project.ParentSolution, options)
+ ISettingsProvider settingsProvider)
+ : this (project.ParentSolution, settingsProvider)
{
}
public SolutionPackageRepositoryPath (
ISolution solution,
- PackageManagementOptions options)
+ ISettingsProvider settingsProvider)
{
this.solution = solution;
- PackageRepositoryPath = GetSolutionPackageRepositoryPath (options);
+ PackageRepositoryPath = GetSolutionPackageRepositoryPath (settingsProvider);
}
- string GetSolutionPackageRepositoryPath (PackageManagementOptions options)
+ string GetSolutionPackageRepositoryPath (ISettingsProvider settingsProvider)
{
- string customPath = options.GetCustomPackagesDirectory ();
+ string customPath = settingsProvider.LoadSettings ().GetRepositoryPath ();
if (!String.IsNullOrEmpty (customPath)) {
return Path.GetFullPath (customPath);
}
- return Path.Combine (solution.BaseDirectory, options.PackagesDirectory);
+ return Path.Combine (solution.BaseDirectory, "packages");
}
public string PackageRepositoryPath { get; private set; }
-
- public string GetInstallPath(IPackage package)
- {
- pathResolver = new DefaultPackagePathResolver(PackageRepositoryPath);
- return pathResolver.GetInstallPath(package);
- }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionProxy.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionProxy.cs index b69b5fc984..5be6c16a25 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionProxy.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SolutionProxy.cs @@ -108,6 +108,14 @@ namespace MonoDevelop.PackageManagement projectRemoved (this, new DotNetProjectEventArgs (project));
}
}
+
+ public bool Equals (ISolution solution)
+ {
+ if (solution == null)
+ return false;
+
+ return Solution == solution.Solution;
+ }
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SourceRepositoryProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SourceRepositoryProvider.cs new file mode 100644 index 0000000000..b58179ff91 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SourceRepositoryProvider.cs @@ -0,0 +1,67 @@ +//
+// SourceRepositoryProvider.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using MonoDevelop.Core;
+using NuGet.Configuration;
+using NuGet.Protocol.Core.Types;
+using NuGet.Protocol.Core.v2;
+using NuGet.Protocol.Core.v3;
+using NuGet.Protocol.VisualStudio;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal static class SourceRepositoryProviderFactory
+ {
+ public static ISourceRepositoryProvider CreateSourceRepositoryProvider ()
+ {
+ var settings = SettingsLoader.LoadDefaultSettings ();
+ return CreateSourceRepositoryProvider (settings);
+ }
+
+ public static ISourceRepositoryProvider CreateSourceRepositoryProvider (ISettings settings)
+ {
+ var packageSourceProvider = new MonoDevelopPackageSourceProvider (settings);
+ return new SourceRepositoryProvider (packageSourceProvider, GetResourceProviders ());
+ }
+
+ static IEnumerable<Lazy<INuGetResourceProvider>> GetResourceProviders ()
+ {
+ yield return new Lazy<INuGetResourceProvider> (() => new PackageMetadataResourceLocalProvider ());
+ yield return new Lazy<INuGetResourceProvider> (() => new PackageSearchResourceLocalProvider ());
+
+ foreach (var provider in Repository.Provider.GetCoreV2 ()) {
+ yield return provider;
+ }
+
+ foreach (var provider in Repository.Provider.GetCoreV3 ()) {
+ yield return provider;
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopAggregateRepository.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SourceRepositoryViewModel.cs index 3463ea7f8f..94aa73ee3e 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/MonoDevelopAggregateRepository.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/SourceRepositoryViewModel.cs @@ -1,10 +1,10 @@ //
-// MonoDevelopAggregateRepository.cs
+// SourceRepositoryViewModel.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -24,44 +24,55 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using MonoDevelop.Core;
-using NuGet;
+using NuGet.Configuration;
+using NuGet.Protocol.Core.Types;
namespace MonoDevelop.PackageManagement
{
- internal class MonoDevelopAggregateRepository : AggregateRepository
+ internal class SourceRepositoryViewModel
{
- ConcurrentQueue<Exception> failures = new ConcurrentQueue<Exception> ();
+ List<SourceRepository> sourceRepositories;
- public MonoDevelopAggregateRepository (IEnumerable<IPackageRepository> repositories)
- : base (repositories)
+ public SourceRepositoryViewModel (string name)
{
+ Name = name;
+ sourceRepositories = new List<SourceRepository> ();
}
- public override void LogRepository (IPackageRepository repository, Exception ex)
+ public SourceRepositoryViewModel (SourceRepository sourceRepository)
+ : this (
+ new [] { sourceRepository },
+ sourceRepository.PackageSource)
{
- base.LogRepository (repository, ex);
- LoggingService.LogInfo ("PackageRepository failure.", ex);
- failures.Enqueue (ex);
}
- public bool AnyFailures ()
+ protected SourceRepositoryViewModel (
+ IEnumerable<SourceRepository> sourceRepositories,
+ PackageSource packageSource)
{
- return failures.Count > 0;
+ this.sourceRepositories = sourceRepositories.ToList ();
+ PackageSource = packageSource;
+
+ if (IsAggregate) {
+ Name = GettextCatalog.GetString ("All Sources");
+ } else {
+ Name = packageSource.Name;
+ }
}
- public bool AllFailed ()
+ public string Name { get; private set; }
+ public PackageSource PackageSource { get; private set; }
+
+ public IEnumerable<SourceRepository> GetSourceRepositories ()
{
- return failures.Count >= Repositories.Count ();
+ return sourceRepositories;
}
- public AggregateException GetAggregateException ()
- {
- return new AggregateException (failures);
+ public bool IsAggregate {
+ get { return sourceRepositories.Count > 1; }
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs deleted file mode 100644 index bbc5af1241..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafePackageManagementEvents.cs +++ /dev/null @@ -1,331 +0,0 @@ -//
-// ThreadSafePackageManagementEvents.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using NuGet;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class ThreadSafePackageManagementEvents : IThreadSafePackageManagementEvents
- {
- Action<Action> guiSyncDispatcher;
- IPackageManagementEvents unsafeEvents;
-
- public ThreadSafePackageManagementEvents (IPackageManagementEvents unsafeEvents)
- : this (unsafeEvents, MonoDevelopProjectSystem.DefaultGuiSyncDispatcher)
- {
- }
-
- public ThreadSafePackageManagementEvents (
- IPackageManagementEvents unsafeEvents,
- Action<Action> guiSyncDispatcher)
- {
- this.unsafeEvents = unsafeEvents;
- this.guiSyncDispatcher = guiSyncDispatcher;
-
- RegisterEventHandlers();
- }
-
- void RegisterEventHandlers()
- {
- unsafeEvents.PackageOperationsStarting += RaisePackageOperationStartingEventIfHasSubscribers;
- unsafeEvents.PackageOperationsFinished += RaisePackageOperationFinishedEventIfHasSubscribers;
- unsafeEvents.PackageOperationError += RaisePackageOperationErrorEventIfHasSubscribers;
- unsafeEvents.ParentPackageInstalled += RaiseParentPackageInstalledEventIfHasSubscribers;
- unsafeEvents.ParentPackageUninstalled += RaiseParentPackageUninstalledEventIfHasSubscribers;
- unsafeEvents.ParentPackagesUpdated += RaiseParentPackagesUpdatedEventIfHasSubscribers;
- unsafeEvents.ResolveFileConflict += RaiseResolveFileConflictEventIfHasSubscribers;
- }
-
- public void Dispose()
- {
- UnregisterEventHandlers();
- }
-
- void UnregisterEventHandlers()
- {
- unsafeEvents.PackageOperationsStarting -= RaisePackageOperationStartingEventIfHasSubscribers;
- unsafeEvents.PackageOperationsFinished -= RaisePackageOperationFinishedEventIfHasSubscribers;
- unsafeEvents.PackageOperationError -= RaisePackageOperationErrorEventIfHasSubscribers;
- unsafeEvents.ParentPackageInstalled -= RaiseParentPackageInstalledEventIfHasSubscribers;
- unsafeEvents.ParentPackageUninstalled -= RaiseParentPackageUninstalledEventIfHasSubscribers;
- unsafeEvents.ParentPackagesUpdated -= RaiseParentPackagesUpdatedEventIfHasSubscribers;
- unsafeEvents.ResolveFileConflict -= RaiseResolveFileConflictEventIfHasSubscribers;
- }
-
- void RaisePackageOperationStartingEventIfHasSubscribers(object sender, EventArgs e)
- {
- if (PackageOperationsStarting != null) {
- guiSyncDispatcher (() => RaisePackageOperationStartingEvent (sender, e));
- }
- }
-
- void RaisePackageOperationStartingEvent(object sender, EventArgs e)
- {
- PackageOperationsStarting(sender, e);
- }
-
- public event EventHandler PackageOperationsStarting;
-
- void RaisePackageOperationFinishedEventIfHasSubscribers(object sender, EventArgs e)
- {
- if (PackageOperationsFinished != null) {
- guiSyncDispatcher (() => RaisePackageOperationFinishedEvent (sender, e));
- }
- }
-
- void RaisePackageOperationFinishedEvent(object sender, EventArgs e)
- {
- PackageOperationsFinished(sender, e);
- }
-
- public event EventHandler PackageOperationsFinished;
-
- void RaisePackageOperationErrorEventIfHasSubscribers(object sender, PackageOperationExceptionEventArgs e)
- {
- if (PackageOperationError != null) {
- guiSyncDispatcher (() => RaisePackageOperationErrorEvent(sender, e));
- }
- }
-
- void RaisePackageOperationErrorEvent(object sender, PackageOperationExceptionEventArgs e)
- {
- if (PackageOperationError != null) {
- guiSyncDispatcher (() => PackageOperationError(sender, e));
- }
- }
-
- public event EventHandler<PackageOperationExceptionEventArgs> PackageOperationError;
-
- void RaiseParentPackageInstalledEventIfHasSubscribers(object sender, ParentPackageOperationEventArgs e)
- {
- if (ParentPackageInstalled != null) {
- guiSyncDispatcher (() => RaiseParentPackageInstalledEvent(sender, e));
- }
- }
-
- void RaiseParentPackageInstalledEvent(object sender, ParentPackageOperationEventArgs e)
- {
- ParentPackageInstalled(sender, e);
- }
-
- public event EventHandler<ParentPackageOperationEventArgs> ParentPackageInstalled;
-
- void RaiseParentPackageUninstalledEventIfHasSubscribers(object sender, ParentPackageOperationEventArgs e)
- {
- if (ParentPackageUninstalled != null) {
- guiSyncDispatcher (() => RaiseParentPackageUninstalledEvent(sender, e));
- }
- }
-
- void RaiseParentPackageUninstalledEvent(object sender, ParentPackageOperationEventArgs e)
- {
- ParentPackageUninstalled(sender, e);
- }
-
- public event EventHandler<ParentPackageOperationEventArgs> ParentPackageUninstalled;
-
- public event EventHandler<AcceptLicensesEventArgs> AcceptLicenses {
- add { unsafeEvents.AcceptLicenses += value; }
- remove { unsafeEvents.AcceptLicenses -= value; }
- }
-
- public event EventHandler<PackageOperationMessageLoggedEventArgs> PackageOperationMessageLogged {
- add { unsafeEvents.PackageOperationMessageLogged += value; }
- remove { unsafeEvents.PackageOperationMessageLogged -= value; }
- }
-
- public event EventHandler<SelectProjectsEventArgs> SelectProjects {
- add { unsafeEvents.SelectProjects += value; }
- remove { unsafeEvents.SelectProjects -= value; }
- }
-
- public void OnPackageOperationsStarting()
- {
- unsafeEvents.OnPackageOperationsStarting();
- }
-
- public void OnPackageOperationsFinished()
- {
- unsafeEvents.OnPackageOperationsFinished();
- }
-
- public void OnPackageOperationError(Exception ex)
- {
- unsafeEvents.OnPackageOperationError(ex);
- }
-
- public bool OnAcceptLicenses(IEnumerable<IPackage> packages)
- {
- return unsafeEvents.OnAcceptLicenses(packages);
- }
-
- public void OnParentPackageInstalled(IPackage package, IPackageManagementProject project)
- {
- OnParentPackageInstalled (package, project, new PackageOperation [0]);
- }
-
- public void OnParentPackageInstalled (IPackage package, IPackageManagementProject project, IEnumerable<PackageOperation> operations)
- {
- unsafeEvents.OnParentPackageInstalled (package, project, operations);
- }
-
- public void OnParentPackageUninstalled(IPackage package, IPackageManagementProject project)
- {
- unsafeEvents.OnParentPackageUninstalled(package, project);
- }
-
- public void OnPackageOperationMessageLogged(MessageLevel level, string message, params object[] args)
- {
- unsafeEvents.OnPackageOperationMessageLogged(level, message, args);
- }
-
- public bool OnSelectProjects(IEnumerable<IPackageManagementSelectedProject> selectedProjects)
- {
- return unsafeEvents.OnSelectProjects(selectedProjects);
- }
-
- public event EventHandler<ResolveFileConflictEventArgs> ResolveFileConflict;
-
- public FileConflictResolution OnResolveFileConflict(string message)
- {
- return unsafeEvents.OnResolveFileConflict(message);
- }
-
- void RaiseResolveFileConflictEventIfHasSubscribers (object sender, ResolveFileConflictEventArgs e)
- {
- if (ResolveFileConflict != null) {
- guiSyncDispatcher (() => ResolveFileConflict (sender, e));
- }
- }
-
- public event EventHandler<ParentPackagesOperationEventArgs> ParentPackagesUpdated;
-
- public void OnParentPackagesUpdated(IEnumerable<IPackage> packages)
- {
- unsafeEvents.OnParentPackagesUpdated(packages);
- }
-
- void RaiseParentPackagesUpdatedEventIfHasSubscribers(object sender, ParentPackagesOperationEventArgs e)
- {
- if (ParentPackagesUpdated != null) {
- guiSyncDispatcher (() => RaiseParentPackagesUpdatedEvent(sender, e));
- }
- }
-
- void RaiseParentPackagesUpdatedEvent(object sender, ParentPackagesOperationEventArgs e)
- {
- ParentPackagesUpdated(sender, e);
- }
-
- public event EventHandler PackagesRestored {
- add { unsafeEvents.PackagesRestored += value; }
- remove { unsafeEvents.PackagesRestored -= value; }
- }
-
- public void OnPackagesRestored()
- {
- unsafeEvents.OnPackagesRestored ();
- }
-
- public event EventHandler<FileEventArgs> FileChanged {
- add { unsafeEvents.FileChanged += value; }
- remove { unsafeEvents.FileChanged -= value; }
- }
-
- public void OnFileChanged (string path)
- {
- unsafeEvents.OnFileChanged (path);
- }
-
- public event EventHandler UpdatedPackagesAvailable {
- add { unsafeEvents.UpdatedPackagesAvailable += value; }
- remove { unsafeEvents.UpdatedPackagesAvailable -= value; }
- }
-
- public void OnUpdatedPackagesAvailable ()
- {
- unsafeEvents.OnUpdatedPackagesAvailable ();
- }
-
- public event EventHandler<FileRemovingEventArgs> FileRemoving {
- add { unsafeEvents.FileRemoving += value; }
- remove { unsafeEvents.FileRemoving -= value; }
- }
-
- public bool OnFileRemoving (string path)
- {
- return unsafeEvents.OnFileRemoving (path);
- }
-
- public event EventHandler<PackageRestoredEventArgs> PackageRestored {
- add { unsafeEvents.PackageRestored += value; }
- remove { unsafeEvents.PackageRestored -= value; }
- }
-
- public void OnPackageRestored (IPackage package)
- {
- unsafeEvents.OnPackageRestored (package);
- }
-
- public event EventHandler<DotNetProjectReferenceEventArgs> ReferenceAdding {
- add { unsafeEvents.ReferenceAdding += value; }
- remove { unsafeEvents.ReferenceAdding -= value; }
- }
-
- public event EventHandler<DotNetProjectReferenceEventArgs> ReferenceRemoving {
- add { unsafeEvents.ReferenceRemoving += value; }
- remove { unsafeEvents.ReferenceRemoving -= value; }
- }
-
- public void OnReferenceAdding (ProjectReference reference)
- {
- unsafeEvents.OnReferenceAdding (reference);
- }
-
- public void OnReferenceRemoving (ProjectReference reference)
- {
- unsafeEvents.OnReferenceRemoving (reference);
- }
-
- public event EventHandler<DotNetProjectImportEventArgs> ImportRemoved {
- add { unsafeEvents.ImportRemoved += value; }
- remove { unsafeEvents.ImportRemoved -= value; }
- }
-
- public void OnImportRemoved (IDotNetProject project, string import)
- {
- unsafeEvents.OnImportRemoved (project, import);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafeProjectBrowserUpdater.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafeProjectBrowserUpdater.cs deleted file mode 100644 index d3b9d94294..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/ThreadSafeProjectBrowserUpdater.cs +++ /dev/null @@ -1,54 +0,0 @@ -//
-// ThreadSafeProjectBrowserUpdater.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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
-{
- internal class ThreadSafeProjectBrowserUpdater : ProjectBrowserUpdater
- {
-// public ThreadSafeProjectBrowserUpdater()
-// : base(GetProjectBrowserControl())
-// {
-// }
-//
-// static ProjectBrowserControl GetProjectBrowserControl()
-// {
-// if (WorkbenchSingleton.InvokeRequired) {
-// return WorkbenchSingleton.SafeThreadFunction(() => GetProjectBrowserControl());
-// } else {
-// return ProjectBrowserPad.Instance.ProjectBrowserControl;
-// }
-// }
-//
-// protected override void ProjectItemAdded(object sender, ProjectItemEventArgs e)
-// {
-// WorkbenchSingleton.SafeThreadAsyncCall(() => base.ProjectItemAdded(sender, e));
-// }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UninstallNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UninstallNuGetPackageAction.cs new file mode 100644 index 0000000000..337d5b9540 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UninstallNuGetPackageAction.cs @@ -0,0 +1,124 @@ +//
+// UninstallNuGetPackageAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class UninstallNuGetPackageAction : INuGetPackageAction, INuGetProjectActionsProvider
+ {
+ INuGetPackageManager packageManager;
+ IDotNetProject dotNetProject;
+ NuGetProject project;
+ INuGetProjectContext context;
+ IPackageManagementEvents packageManagementEvents;
+ IEnumerable<NuGetProjectAction> actions;
+
+ public UninstallNuGetPackageAction (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject)
+ : this (
+ solutionManager,
+ dotNetProject,
+ new NuGetProjectContext (),
+ new MonoDevelopNuGetPackageManager (solutionManager),
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public UninstallNuGetPackageAction (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext,
+ INuGetPackageManager packageManager,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.dotNetProject = dotNetProject;
+ this.context = projectContext;
+ this.packageManager = packageManager;
+ this.packageManagementEvents = packageManagementEvents;
+
+ project = solutionManager.GetNuGetProject (dotNetProject);
+ }
+
+ public string PackageId { get; set; }
+ public bool ForceRemove { get; set; }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ using (var monitor = new NuGetPackageEventsMonitor (dotNetProject, packageManagementEvents)) {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ actions = await packageManager.PreviewUninstallPackageAsync (
+ project,
+ PackageId,
+ CreateUninstallationContext (),
+ context,
+ cancellationToken);
+
+ project.OnBeforeUninstall (actions);
+
+ await packageManager.ExecuteNuGetProjectActionsAsync (
+ project,
+ actions,
+ context,
+ cancellationToken);
+
+ project.OnAfterExecuteActions (actions);
+
+ await project.RunPostProcessAsync (context, cancellationToken);
+ }
+ + public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ UninstallationContext CreateUninstallationContext ()
+ {
+ return new UninstallationContext (false, ForceRemove);
+ }
+
+ public IEnumerable<NuGetProjectAction> GetNuGetProjectActions ()
+ {
+ return actions;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UninstallPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UninstallPackageAction.cs deleted file mode 100644 index 92eed7f570..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UninstallPackageAction.cs +++ /dev/null @@ -1,68 +0,0 @@ -//
-// UninstallPackageAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2012 Matthew Ward
-//
-// 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 MonoDevelop.Core;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UninstallPackageAction : ProcessPackageAction
- {
- public UninstallPackageAction(
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- : base(project, packageManagementEvents)
- {
- this.AllowPrereleaseVersions = true;
- }
-
- public bool ForceRemove { get; set; }
- public bool RemoveDependencies { get; set; }
-
- protected override void BeforeExecute()
- {
- base.BeforeExecute();
- }
-
- protected override void ExecuteCore()
- {
- Project.UninstallPackage(Package, this);
- OnParentPackageUninstalled();
- }
-
- public override bool HasPackageScriptsToRun()
- {
- BeforeExecute ();
- var files = new PackageFiles(Package);
- return files.HasUninstallPackageScript();
- }
-
- protected override string StartingMessageFormat {
- get { return GettextCatalog.GetString ("Removing {0}..."); }
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllNuGetPackagesInProjectAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllNuGetPackagesInProjectAction.cs new file mode 100644 index 0000000000..dee41027f4 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllNuGetPackagesInProjectAction.cs @@ -0,0 +1,244 @@ +//
+// UpdateAllNuGetPackagesInProjectAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using NuGet.PackageManagement;
+using NuGet.Packaging; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+using NuGet.Resolver;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class UpdateAllNuGetPackagesInProjectAction : IPackageAction, INuGetProjectActionsProvider
+ {
+ INuGetPackageManager packageManager;
+ IPackageRestoreManager restoreManager;
+ IMonoDevelopSolutionManager solutionManager;
+ INuGetProjectContext context;
+ IPackageManagementEvents packageManagementEvents;
+ IDotNetProject dotNetProject;
+ NuGetProject project; + IEnumerable<NuGetProjectAction> actions;
+ List<SourceRepository> primarySources;
+ IEnumerable<PackageReference> packageReferences;
+ bool includePrerelease;
+ string projectName;
+
+ public UpdateAllNuGetPackagesInProjectAction (
+ IMonoDevelopSolutionManager solutionManager,
+ DotNetProject dotNetProject)
+ : this (
+ solutionManager,
+ new DotNetProjectProxy (dotNetProject),
+ new NuGetProjectContext (),
+ new MonoDevelopNuGetPackageManager (solutionManager),
+ new MonoDevelopPackageRestoreManager (solutionManager),
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public UpdateAllNuGetPackagesInProjectAction (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext,
+ INuGetPackageManager packageManager,
+ IPackageRestoreManager restoreManager,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.solutionManager = solutionManager;
+ this.dotNetProject = dotNetProject;
+ this.context = projectContext;
+ this.packageManager = packageManager; + this.restoreManager = restoreManager;
+ this.packageManagementEvents = packageManagementEvents; + + primarySources = solutionManager.CreateSourceRepositoryProvider ().GetRepositories ().ToList ();
+
+ project = solutionManager.GetNuGetProject (dotNetProject);
+
+ projectName = dotNetProject.Name;
+ }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ includePrerelease = await ProjectHasPrereleasePackages (cancellationToken);
+
+ await RestoreAnyMissingPackages (cancellationToken);
+
+ actions = await packageManager.PreviewUpdatePackagesAsync (
+ project,
+ CreateResolutionContext (),
+ context,
+ primarySources,
+ new SourceRepository[0],
+ cancellationToken);
+
+ if (!actions.Any ()) {
+ packageManagementEvents.OnNoUpdateFound (dotNetProject); + return;
+ }
+
+ await CheckLicenses (cancellationToken);
+
+ using (IDisposable fileMonitor = CreateFileMonitor ()) {
+ using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
+ await packageManager.ExecuteNuGetProjectActionsAsync (
+ project,
+ actions,
+ context,
+ cancellationToken);
+ }
+ }
+
+ project.OnAfterExecuteActions (actions);
+
+ await project.RunPostProcessAsync (context, cancellationToken);
+
+ await OpenReadmeFiles (cancellationToken);
+ }
+ + async Task<bool> ProjectHasPrereleasePackages (CancellationToken cancellationToken)
+ {
+ packageReferences = await project.GetInstalledPackagesAsync (cancellationToken);
+ return packageReferences.Any (packageReference => packageReference.PackageIdentity.Version.IsPrerelease);
+ }
+ + public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ ResolutionContext CreateResolutionContext ()
+ {
+ return new ResolutionContext (
+ DependencyBehavior.Lowest,
+ includePrerelease,
+ false,
+ VersionConstraints.None
+ );
+ }
+
+ async Task RestoreAnyMissingPackages (CancellationToken cancellationToken)
+ {
+ var packages = await restoreManager.GetPackagesInSolutionAsync (
+ solutionManager.SolutionDirectory,
+ cancellationToken);
+
+ var missingPackages = packages.Select (package => IsMissingForCurrentProject (package)).ToList ();
+ if (missingPackages.Any ()) {
+ using (var monitor = new PackageRestoreMonitor (restoreManager, packageManagementEvents)) {
+ await restoreManager.RestoreMissingPackagesAsync (
+ solutionManager.SolutionDirectory,
+ project,
+ context,
+ cancellationToken);
+ }
+
+ await RunInMainThread (() => dotNetProject.RefreshReferenceStatus ());
+
+ packageManagementEvents.OnPackagesRestored ();
+ }
+ }
+
+ bool IsMissingForCurrentProject (PackageRestoreData package)
+ {
+ return package.IsMissing && package.ProjectNames.Any (name => name == projectName);
+ } + + protected virtual Task RunInMainThread (Action action) + { + return Runtime.RunInMainThread (action); + }
+
+ Task CheckLicenses (CancellationToken cancellationToken)
+ {
+ return NuGetPackageLicenseAuditor.AcceptLicenses (
+ primarySources,
+ actions,
+ packageManager,
+ GetLicenseAcceptanceService (),
+ cancellationToken);
+ } + + public IEnumerable<NuGetProjectAction> GetNuGetProjectActions () + { + return actions; + }
+
+ protected virtual ILicenseAcceptanceService GetLicenseAcceptanceService ()
+ {
+ return new LicenseAcceptanceService ();
+ }
+
+ LocalCopyReferenceMaintainer CreateLocalCopyReferenceMaintainer ()
+ {
+ return new LocalCopyReferenceMaintainer (packageManagementEvents);
+ }
+
+ IDisposable CreateFileMonitor ()
+ {
+ return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
+ packageManagementEvents,
+ GetFileRemover ());
+ }
+
+ protected virtual IFileRemover GetFileRemover ()
+ {
+ return new FileRemover ();
+ }
+
+ Task OpenReadmeFiles (CancellationToken cancellationToken)
+ {
+ var packages = GetPackagesUpdated ().ToList ();
+ return packageManager.OpenReadmeFiles (project, packages, context, cancellationToken);
+ }
+
+ IEnumerable<PackageIdentity> GetPackagesUpdated ()
+ {
+ return actions + .Where (action => action.NuGetProjectActionType == NuGetProjectActionType.Install) + .Select (action => action.PackageIdentity);
+ } + } +}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesForSelectedPageQuery.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllNuGetPackagesInSolution.cs index f3aa8d2b1c..ddb382c7d8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/PackagesForSelectedPageQuery.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllNuGetPackagesInSolution.cs @@ -1,10 +1,10 @@ //
-// PackagesForSelectedPageQuery.cs
+// UpdateAllNuGetPackagesInSolution.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -24,33 +24,36 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
-
-using MonoDevelop.PackageManagement;
-using NuGet;
+using System.Threading;
+using MonoDevelop.Projects;
namespace MonoDevelop.PackageManagement
{
- internal class PackagesForSelectedPageQuery
+ internal class UpdateAllNuGetPackagesInSolution
{
- public PackagesForSelectedPageQuery (
- PackagesViewModel viewModel,
- IEnumerable<IPackage> allPackages,
- string searchCriteria)
+ Solution solution;
+
+ public UpdateAllNuGetPackagesInSolution (Solution solution)
{
- Skip = viewModel.ItemsBeforeFirstPage;
- Take = viewModel.PageSize;
- AllPackages = allPackages;
- SearchCriteria = new PackageSearchCriteria (searchCriteria);
- TotalPackages = viewModel.TotalItems;
+ this.solution = solution;
}
- public int Skip { get; private set; }
- public int Take { get; private set; }
- public PackageSearchCriteria SearchCriteria { get; private set; }
+ public IEnumerable<IPackageAction> CreateActions ()
+ {
+ var solutionManager = PackageManagementServices.Workspace.GetSolutionManager (solution);
+
+ foreach (DotNetProject project in solution.GetAllDotNetProjects ()) {
+ yield return new UpdateAllNuGetPackagesInProjectAction (
+ solutionManager,
+ project);
+ }
+ }
- public int TotalPackages { get; set; }
- public IEnumerable<IPackage> AllPackages { get; set; }
+ public IEnumerable<IDotNetProject> GetProjects ()
+ {
+ return new SolutionProxy (solution).GetAllProjects ();
+ }
}
}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllPackagesInProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllPackagesInProject.cs deleted file mode 100644 index 31fdb59aa3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllPackagesInProject.cs +++ /dev/null @@ -1,65 +0,0 @@ -//
-// UpdateAllPackagesInProject.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdateAllPackagesInProject : UpdatePackageActions
- {
- IPackageManagementProject project;
-
- public UpdateAllPackagesInProject(IPackageManagementProject project)
- {
- this.project = project;
- this.UpdateDependencies = true;
- }
-
- public override IEnumerable<UpdatePackageAction> CreateActions()
- {
- foreach (IPackage package in GetPackages()) {
- yield return CreateUpdatePackageAction(package);
- }
- }
-
- IEnumerable<IPackage> GetPackages()
- {
- return project.GetPackagesInReverseDependencyOrder();
- }
-
- UpdatePackageAction CreateUpdatePackageAction(IPackage package)
- {
- UpdatePackageAction action = CreateDefaultUpdatePackageAction(project);
- action.PackageId = package.Id;
- if (!action.AllowPrereleaseVersions && !package.IsReleaseVersion ()) {
- action.AllowPrereleaseVersions = true;
- }
- return action;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllPackagesInSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllPackagesInSolution.cs deleted file mode 100644 index 73c63afa38..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateAllPackagesInSolution.cs +++ /dev/null @@ -1,82 +0,0 @@ -//
-// UpdateAllPackagesInSolution.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdateAllPackagesInSolution : UpdatePackageActions
- {
- IPackageManagementSolution solution;
- IPackageRepository sourceRepository;
- List<IPackageManagementProject> projects;
-
- public UpdateAllPackagesInSolution(
- IPackageManagementSolution solution,
- IPackageRepository sourceRepository)
- {
- this.solution = solution;
- this.sourceRepository = sourceRepository;
- UpdateDependencies = true;
- }
-
- public override IEnumerable<UpdatePackageAction> CreateActions()
- {
- foreach (IPackage package in GetPackages()) {
- foreach (IPackageManagementProject project in Projects) {
- yield return CreateAction(project, package);
- }
- }
- }
-
- public IEnumerable<IPackageManagementProject> Projects {
- get {
- if (projects == null) {
- projects = solution
- .GetProjects(sourceRepository)
- .ToList ();
- }
- return projects;
- }
- }
-
- IEnumerable<IPackage> GetPackages()
- {
- return solution.GetPackagesInReverseDependencyOrder();
- }
-
- UpdatePackageAction CreateAction(IPackageManagementProject project, IPackage package)
- {
- UpdatePackageAction action = CreateDefaultUpdatePackageAction(project);
- action.PackageId = package.Id;
- if (!action.AllowPrereleaseVersions && !package.IsReleaseVersion ()) {
- action.AllowPrereleaseVersions = true;
- }
- return action;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateNuGetPackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateNuGetPackageAction.cs new file mode 100644 index 0000000000..eeab215de5 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateNuGetPackageAction.cs @@ -0,0 +1,199 @@ +//
+// UpdateNuGetPackageAction.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.PackageManagement;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+using NuGet.Resolver;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class UpdateNuGetPackageAction : INuGetPackageAction, INuGetProjectActionsProvider
+ {
+ INuGetPackageManager packageManager;
+ IDotNetProject dotNetProject;
+ NuGetProject project;
+ List<SourceRepository> primarySources;
+ ISourceRepositoryProvider sourceRepositoryProvider;
+ IEnumerable<NuGetProjectAction> actions;
+ IPackageManagementEvents packageManagementEvents;
+ INuGetProjectContext context;
+
+ public UpdateNuGetPackageAction (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject)
+ : this (
+ solutionManager,
+ dotNetProject,
+ new NuGetProjectContext (),
+ new MonoDevelopNuGetPackageManager (solutionManager),
+ PackageManagementServices.PackageManagementEvents)
+ {
+ }
+
+ public UpdateNuGetPackageAction (
+ IMonoDevelopSolutionManager solutionManager,
+ IDotNetProject dotNetProject,
+ INuGetProjectContext projectContext,
+ INuGetPackageManager packageManager,
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.dotNetProject = dotNetProject;
+ this.context = projectContext;
+ this.packageManager = packageManager;
+ this.packageManagementEvents = packageManagementEvents;
+
+ project = solutionManager.GetNuGetProject (dotNetProject);
+
+ sourceRepositoryProvider = solutionManager.CreateSourceRepositoryProvider ();
+ primarySources = sourceRepositoryProvider.GetRepositories ().ToList ();
+ }
+
+ public string PackageId { get; set; }
+ public bool IncludePrerelease { get; set; }
+
+ public void Execute ()
+ {
+ Execute (CancellationToken.None);
+ }
+
+ public void Execute (CancellationToken cancellationToken)
+ {
+ using (var monitor = new NuGetPackageEventsMonitor (dotNetProject, packageManagementEvents)) {
+ ExecuteAsync (cancellationToken).Wait ();
+ }
+ }
+
+ async Task ExecuteAsync (CancellationToken cancellationToken)
+ {
+ actions = await packageManager.PreviewUpdatePackagesAsync (
+ PackageId,
+ project,
+ CreateResolutionContext (),
+ context,
+ primarySources,
+ new SourceRepository[0],
+ cancellationToken);
+
+ if (!actions.Any ()) {
+ packageManagementEvents.OnNoUpdateFound (dotNetProject);
+ return;
+ }
+
+ await CheckLicenses (cancellationToken);
+
+ SetDirectInstall ();
+
+ using (IDisposable fileMonitor = CreateFileMonitor ()) {
+ using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
+ await packageManager.ExecuteNuGetProjectActionsAsync (
+ project,
+ actions,
+ context,
+ cancellationToken);
+ }
+ }
+
+ packageManager.ClearDirectInstall (context);
+
+ project.OnAfterExecuteActions (actions);
+
+ await project.RunPostProcessAsync (context, cancellationToken);
+ }
+
+ public bool HasPackageScriptsToRun ()
+ {
+ return false;
+ }
+
+ ResolutionContext CreateResolutionContext ()
+ {
+ return new ResolutionContext (
+ DependencyBehavior.Lowest,
+ IncludePrerelease,
+ false,
+ VersionConstraints.None
+ );
+ }
+
+ Task CheckLicenses (CancellationToken cancellationToken)
+ {
+ return NuGetPackageLicenseAuditor.AcceptLicenses (
+ primarySources,
+ actions,
+ packageManager,
+ GetLicenseAcceptanceService (),
+ cancellationToken);
+ }
+
+ void SetDirectInstall ()
+ {
+ var matchedAction = actions.FirstOrDefault (IsInstallActionForPackageBeingUpdated);
+ if (matchedAction != null) {
+ packageManager.SetDirectInstall (matchedAction.PackageIdentity, context);
+ }
+ }
+
+ bool IsInstallActionForPackageBeingUpdated (NuGetProjectAction action)
+ {
+ return action.PackageIdentity.Id == PackageId &&
+ action.NuGetProjectActionType == NuGetProjectActionType.Install;
+ }
+
+ protected virtual ILicenseAcceptanceService GetLicenseAcceptanceService ()
+ {
+ return new LicenseAcceptanceService ();
+ }
+
+ LocalCopyReferenceMaintainer CreateLocalCopyReferenceMaintainer ()
+ {
+ return new LocalCopyReferenceMaintainer (packageManagementEvents);
+ }
+
+ public IEnumerable<NuGetProjectAction> GetNuGetProjectActions ()
+ {
+ return actions;
+ }
+
+ IDisposable CreateFileMonitor ()
+ {
+ return new PreventPackagesConfigFileBeingRemovedOnUpdateMonitor (
+ packageManagementEvents,
+ GetFileRemover ());
+ }
+
+ protected virtual IFileRemover GetFileRemover ()
+ {
+ return new FileRemover ();
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs deleted file mode 100644 index d6d20036b6..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageAction.cs +++ /dev/null @@ -1,145 +0,0 @@ -//
-// UpdatePackageAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using MonoDevelop.Core;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatePackageAction : ProcessPackageOperationsAction, IUpdatePackageSettings
- {
- IFileRemover fileRemover;
-
- public UpdatePackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- : this (
- project,
- packageManagementEvents,
- new FileRemover ())
- {
- }
-
- public UpdatePackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- IFileRemover fileRemover)
- : this (project, packageManagementEvents, fileRemover, new LicenseAcceptanceService ())
- {
- }
-
- public UpdatePackageAction (
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents,
- IFileRemover fileRemover,
- ILicenseAcceptanceService licenseAcceptanceService)
- : base (project, packageManagementEvents, licenseAcceptanceService)
- {
- this.fileRemover = fileRemover;
- UpdateDependencies = true;
- UpdateIfPackageDoesNotExistInProject = true;
- LicensesMustBeAccepted = true;
- }
-
- public bool UpdateDependencies { get; set; }
- public bool UpdateIfPackageDoesNotExistInProject { get; set; }
-
- protected override IEnumerable<PackageOperation> GetPackageOperations()
- {
- var installAction = Project.CreateInstallPackageAction();
- installAction.AllowPrereleaseVersions = AllowPrereleaseVersions;
- installAction.IgnoreDependencies = !UpdateDependencies;
- return Project.GetInstallPackageOperations(Package, installAction);
- }
-
- protected override void ExecuteCore()
- {
- if (ShouldUpdatePackage ()) {
- using (IOpenPackageReadMeMonitor readmeMonitor = CreateOpenPackageReadMeMonitor (Package.Id)) {
- using (IDisposable monitor = CreateFileMonitor (fileRemover)) {
- using (IDisposable referenceMaintainer = CreateLocalCopyReferenceMaintainer ()) {
- Project.UpdatePackage (Package, this);
- readmeMonitor.OpenReadMeFile ();
- }
- }
- }
- OnParentPackageInstalled ();
- } else {
- LogNoUpdatesAvailableForPackage (GetPackageId ());
- }
- }
-
- bool ShouldUpdatePackage()
- {
- if (!UpdateIfPackageDoesNotExistInProject) {
- return PackageIdExistsInProject () && ProjectHasOlderPackageInstalled (Package);
- } else if (PackageIdExistsInProject ()) {
- return ProjectHasOlderPackageInstalled (Package);
- }
- return true;
- }
-
- bool ProjectHasOlderPackageInstalled (IPackage package)
- {
- if (package != null) {
- return Project.HasOlderPackageInstalled (package);
- }
-
- return true;
- }
-
- void LogNoUpdatesAvailableForPackage (string packageId)
- {
- string message = GettextCatalog.GetString ("No updates available for '{0}' in project '{1}'.", packageId, Project.Name);
- Logger.Log (MessageLevel.Info, message);
- }
-
- protected override string StartingMessageFormat {
- get { return GettextCatalog.GetString ("Updating {0}..."); }
- }
-
- protected override bool ShouldLogEmptyLineForFinishedAction ()
- {
- return ShouldUpdatePackage ();
- }
-
- protected override bool ShouldLogStartingMessage ()
- {
- return ShouldUpdatePackage ();
- }
-
- protected override void CheckLicenses () - {
- if (ShouldUpdatePackage ()) { - base.CheckLicenses ();
- } - }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageActions.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageActions.cs deleted file mode 100644 index dc5f45b52c..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackageActions.cs +++ /dev/null @@ -1,53 +0,0 @@ -//
-// UpdatePackageActions.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-
-namespace MonoDevelop.PackageManagement
-{
- internal abstract class UpdatePackageActions : IUpdatePackageActions
- {
- public bool UpdateDependencies { get; set; }
- public bool AllowPrereleaseVersions { get; set; }
- //public IPackageScriptRunner PackageScriptRunner { get; set; }
-
- public abstract IEnumerable<UpdatePackageAction> CreateActions();
-
- protected UpdatePackageAction CreateDefaultUpdatePackageAction(IPackageManagementProject project)
- {
- UpdatePackageAction action = project.CreateUpdatePackageAction();
- SetUpdatePackageActionProperties(action);
- return action;
- }
-
- void SetUpdatePackageActionProperties(UpdatePackageAction action)
- {
- //action.PackageScriptRunner = PackageScriptRunner;
- action.UpdateDependencies = UpdateDependencies;
- action.UpdateIfPackageDoesNotExistInProject = false;
- action.AllowPrereleaseVersions = AllowPrereleaseVersions;
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesAction.cs deleted file mode 100644 index a76b2a0ad6..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesAction.cs +++ /dev/null @@ -1,114 +0,0 @@ -//
-// UpdatePackagesAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatePackagesAction : IUpdatePackagesAction
- {
- List<IPackage> packages = new List<IPackage>();
- List<PackageOperation> operations = new List<PackageOperation>();
- IPackageManagementEvents packageManagementEvents;
-
- public UpdatePackagesAction(
- IPackageManagementProject project,
- IPackageManagementEvents packageManagementEvents)
- {
- Project = project;
- this.packageManagementEvents = packageManagementEvents;
- UpdateDependencies = true;
- }
-
- public IPackageManagementProject Project { get; private set; }
-
- public IEnumerable<IPackage> Packages {
- get { return packages; }
- }
-
- public IEnumerable<PackageOperation> Operations {
- get { return operations; }
- }
-
- public bool UpdateDependencies { get; set; }
- public bool AllowPrereleaseVersions { get; set; }
- public ILogger Logger { get; set; }
-
- public bool HasPackageScriptsToRun()
- {
- var files = new PackageFilesForOperations(Operations);
- return files.HasAnyPackageScripts();
- }
-
- public void AddOperations(IEnumerable<PackageOperation> operations)
- {
- this.operations.AddRange(operations);
- }
-
- public void AddPackages(IEnumerable<IPackageFromRepository> packages)
- {
- this.packages.AddRange(packages);
- }
-
- public void Execute()
- {
- //if (PackageScriptRunner != null) {
- // ExecuteWithScriptRunner();
- //} else {
- ExecuteCore();
- //}
- }
-
- protected virtual void ExecuteCore()
- {
- Project.UpdatePackages(this);
- packageManagementEvents.OnParentPackagesUpdated(Packages);
- }
-
-// void ExecuteWithScriptRunner()
-// {
-// using (RunPackageScriptsAction runScriptsAction = CreateRunPackageScriptsAction()) {
-// ExecuteCore();
-// }
-// }
-//
-// RunPackageScriptsAction CreateRunPackageScriptsAction()
-// {
-// return CreateRunPackageScriptsAction(PackageScriptRunner, Project);
-// }
-//
-// protected virtual RunPackageScriptsAction CreateRunPackageScriptsAction(
-// IPackageScriptRunner scriptRunner,
-// IPackageManagementProject project)
-// {
-// return new RunPackageScriptsAction(scriptRunner, project);
-// }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesActionFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesActionFactory.cs deleted file mode 100644 index 4ed823a89d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesActionFactory.cs +++ /dev/null @@ -1,97 +0,0 @@ -//
-// UpdatePackagesActionFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatePackagesActionFactory
- {
- ILogger logger;
- IPackageManagementEvents packageManagementEvents;
- bool singleProjectSelected;
- IPackageManagementProject project;
- PackageManagementSelectedProjects selectedProjects;
- IEnumerable<IPackageFromRepository> packages;
-
- public UpdatePackagesActionFactory(ILogger logger, IPackageManagementEvents packageManagementEvents)
- {
- this.logger = logger;
- this.packageManagementEvents = packageManagementEvents;
- }
-
- public IUpdatePackagesAction CreateAction(
- PackageManagementSelectedProjects selectedProjects,
- IEnumerable<IPackageFromRepository> packages)
- {
- this.selectedProjects = selectedProjects;
- this.packages = packages;
-
- singleProjectSelected = selectedProjects.HasSingleProjectSelected();
-
- CreateProjectForDetermingPackageOperations();
- IUpdatePackagesAction action = CreateActionInternal();
- action.AddPackages(packages);
- action.Logger = logger;
-
- IEnumerable<PackageOperation> operations = GetPackageOperations(action);
- action.AddOperations(operations);
-
- return action;
- }
-
- IEnumerable<PackageOperation> GetPackageOperations(IUpdatePackagesAction action)
- {
- return project.GetUpdatePackagesOperations(packages, action);
- }
-
- IUpdatePackagesAction CreateActionInternal()
- {
- if (singleProjectSelected) {
- return project.CreateUpdatePackagesAction();
- } else {
- return new UpdateSolutionPackagesAction(selectedProjects.Solution, packageManagementEvents);
- }
- }
-
- void CreateProjectForDetermingPackageOperations()
- {
- IPackageRepository repository = packages.First().Repository;
- if (singleProjectSelected) {
- project = selectedProjects.GetSingleProjectSelected(repository);
- } else {
- project = selectedProjects.Solution.GetProjects(repository).First();
- }
- project.Logger = logger;
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesProgressMonitorStatusMessage.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesProgressMonitorStatusMessage.cs index 5b0d15ad19..d94f225d7f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesProgressMonitorStatusMessage.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatePackagesProgressMonitorStatusMessage.cs @@ -24,9 +24,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
-using MonoDevelop.PackageManagement;
namespace MonoDevelop.PackageManagement
{
@@ -37,12 +35,12 @@ namespace MonoDevelop.PackageManagement string packagesUpToDateWarningMessage;
public UpdatePackagesProgressMonitorStatusMessage (
- IPackageManagementProject project,
+ IDotNetProject project,
string packagesUpToDateMessage,
string packagesUpToDateWarningMessage,
ProgressMonitorStatusMessage message)
: this (
- new IPackageManagementProject [] { project },
+ new IDotNetProject [] { project },
packagesUpToDateMessage,
packagesUpToDateWarningMessage,
message)
@@ -50,7 +48,7 @@ namespace MonoDevelop.PackageManagement }
public UpdatePackagesProgressMonitorStatusMessage (
- IEnumerable<IPackageManagementProject> projects,
+ IEnumerable<IDotNetProject> projects,
string packagesUpToDateMessage,
string packagesUpToDateWarningMessage,
ProgressMonitorStatusMessage message)
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateSolutionPackagesAction.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateSolutionPackagesAction.cs deleted file mode 100644 index c2dc4ccfce..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdateSolutionPackagesAction.cs +++ /dev/null @@ -1,149 +0,0 @@ -//
-// UpdateSolutionPackagesAction.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdateSolutionPackagesAction : IUpdatePackagesAction
- {
- List<IPackageFromRepository> packages = new List<IPackageFromRepository>();
- List<PackageOperation> operations = new List<PackageOperation>();
- List<IPackageManagementProject> projects;
- IPackageManagementEvents packageManagementEvents;
-
- public UpdateSolutionPackagesAction(
- IPackageManagementSolution solution,
- IPackageManagementEvents packageManagementEvents)
- {
- this.Solution = solution;
- this.UpdateDependencies = true;
- this.packageManagementEvents = packageManagementEvents;
- }
-
- public IPackageManagementSolution Solution { get; private set; }
- //public IPackageScriptRunner PackageScriptRunner { get; set; }
- public bool UpdateDependencies { get; set; }
- public bool AllowPrereleaseVersions { get; set; }
- public ILogger Logger { get; set; }
-
- public IEnumerable<PackageOperation> Operations {
- get { return operations; }
- }
-
- public IEnumerable<IPackageFromRepository> Packages {
- get { return packages; }
- }
-
- public bool HasPackageScriptsToRun()
- {
- var files = new PackageFilesForOperations(Operations);
- return files.HasAnyPackageScripts();
- }
-
- public void AddOperations(IEnumerable<PackageOperation> operations)
- {
- this.operations.AddRange(operations);
- }
-
- public void AddPackages(IEnumerable<IPackageFromRepository> packages)
- {
- this.packages.AddRange(packages);
- }
-
- public void Execute()
- {
- //if (PackageScriptRunner != null) {
- // ExecuteWithScriptRunner();
- //} else {
- ExecuteCore();
- //}
- }
-
-// void ExecuteWithScriptRunner()
-// {
-// using (RunAllProjectPackageScriptsAction runScriptsAction = CreateRunPackageScriptsAction()) {
-// ExecuteCore();
-// }
-// }
-//
-// RunAllProjectPackageScriptsAction CreateRunPackageScriptsAction()
-// {
-// return CreateRunPackageScriptsAction(PackageScriptRunner, GetProjects());
-// }
-
- void ExecuteCore()
- {
- RunPackageOperations();
- UpdatePackageReferences();
- packageManagementEvents.OnParentPackagesUpdated(Packages);
- }
-
- void RunPackageOperations()
- {
- IPackageManagementProject project = GetProjects().First();
- project.RunPackageOperations(operations);
- }
-
- IEnumerable<IPackageManagementProject> GetProjects()
- {
- if (projects == null) {
- IPackageFromRepository package = packages.First();
- projects = Solution
- .GetProjects(package.Repository)
- .Select(project => {
- project.Logger = Logger;
- return project;
- })
- .ToList();
- }
- return projects;
- }
-
- void UpdatePackageReferences()
- {
- foreach (IPackageManagementProject project in GetProjects()) {
- foreach (IPackageFromRepository package in packages) {
- if (project.HasOlderPackageInstalled(package)) {
- project.UpdatePackageReference(package, this);
- }
- }
- }
- }
-
-// protected virtual RunAllProjectPackageScriptsAction CreateRunPackageScriptsAction(
-// IPackageScriptRunner scriptRunner,
-// IEnumerable<IPackageManagementProject> projects)
-// {
-// return new RunAllProjectPackageScriptsAction(scriptRunner, projects);
-// }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInProject.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesInProject.cs index 881a12d206..91513d713f 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInProject.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesInProject.cs @@ -1,10 +1,10 @@ //
-// UpdatedPackagesInProject.cs
+// UpdatedNuGetPackagesInProject.cs
//
// Author:
// Matt Ward <matt.ward@xamarin.com>
//
-// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+// Copyright (c) 2016 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
@@ -24,25 +24,26 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-using System;
using System.Collections.Generic;
using System.Linq;
-using NuGet;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
+using NuGet.Versioning;
namespace MonoDevelop.PackageManagement
{
- internal class UpdatedPackagesInProject
+ internal class UpdatedNuGetPackagesInProject
{
- List<IPackageName> packages;
+ List<PackageIdentity> packages;
- public UpdatedPackagesInProject (IDotNetProject project)
- : this (project, Enumerable.Empty<IPackageName> ())
+ public UpdatedNuGetPackagesInProject (IDotNetProject project)
+ : this (project, Enumerable.Empty<PackageIdentity> ())
{
}
- public UpdatedPackagesInProject (
+ public UpdatedNuGetPackagesInProject (
IDotNetProject project,
- IEnumerable<IPackageName> packages)
+ IEnumerable<PackageIdentity> packages)
{
Project = project;
this.packages = packages.ToList ();
@@ -50,7 +51,11 @@ namespace MonoDevelop.PackageManagement public IDotNetProject Project { get; private set; }
- public IEnumerable<IPackageName> GetPackages ()
+ public ISolution ParentSolution {
+ get { return Project.ParentSolution; }
+ }
+
+ public IEnumerable<PackageIdentity> GetPackages ()
{
return packages;
}
@@ -60,25 +65,17 @@ namespace MonoDevelop.PackageManagement return packages.Any ();
}
- public IPackageName GetUpdatedPackage (string packageId)
+ public PackageIdentity GetUpdatedPackage (string packageId)
{
return packages
.FirstOrDefault (package => package.Id == packageId);
}
- public void RemovePackage (IPackageName package)
- {
- int index = packages.FindIndex (existingPackageName => existingPackageName.Id == package.Id);
- if (index >= 0) {
- packages.RemoveAt (index);
- }
- }
-
public void RemoveUpdatedPackages (IEnumerable<PackageReference> packageReferences)
{
foreach (PackageReference packageReference in packageReferences) {
- IPackageName package = packages.Find (existingPackageName => existingPackageName.Id == packageReference.Id);
- if ((package != null) && (package.Version <= packageReference.Version)) {
+ PackageIdentity package = packages.Find (existingPackageName => existingPackageName.Id == packageReference.PackageIdentity.Id);
+ if ((package != null) && (package.Version <= packageReference.PackageIdentity.Version)) {
packages.Remove (package);
}
}
@@ -88,7 +85,7 @@ namespace MonoDevelop.PackageManagement void RemoveUninstalledPackages (IEnumerable<PackageReference> packageReferences)
{
- packages.RemoveAll (package => !packageReferences.Any (packageReference => packageReference.Id == package.Id));
+ packages.RemoveAll (package => !packageReferences.Any (packageReference => packageReference.PackageIdentity.Id == package.Id));
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesInWorkspace.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesInWorkspace.cs new file mode 100644 index 0000000000..6b3e345f01 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesInWorkspace.cs @@ -0,0 +1,134 @@ +//
+// UpdatedNuGetPackagesInWorkspace.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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 System.Collections.Generic;
+using System.Linq;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class UpdatedNuGetPackagesInWorkspace : IUpdatedNuGetPackagesInWorkspace
+ {
+ CheckForNuGetPackageUpdatesTaskRunner taskRunner;
+ IPackageManagementEvents packageManagementEvents;
+ List<ISolution> pendingSolutions = new List<ISolution> ();
+ List<UpdatedNuGetPackagesInProject> projectsWithUpdatedPackages = new List<UpdatedNuGetPackagesInProject> ();
+
+ public UpdatedNuGetPackagesInWorkspace (
+ IPackageManagementEvents packageManagementEvents)
+ {
+ this.packageManagementEvents = packageManagementEvents; + this.taskRunner = CreateTaskRunner (); + }
+
+ protected virtual CheckForNuGetPackageUpdatesTaskRunner CreateTaskRunner ()
+ {
+ return new CheckForNuGetPackageUpdatesTaskRunner (this);
+ }
+
+ public void Clear ()
+ {
+ taskRunner.Stop ();
+ projectsWithUpdatedPackages = new List<UpdatedNuGetPackagesInProject> ();
+ pendingSolutions = new List<ISolution> ();
+ }
+
+ public void Clear (ISolution solution)
+ {
+ projectsWithUpdatedPackages.RemoveAll (project => project.ParentSolution.Equals (solution));
+ pendingSolutions.RemoveAll (pendingSolution => pendingSolution.Equals (solution));
+ }
+
+ public void CheckForUpdates (ISolution solution)
+ {
+ GuiDispatch (() => {
+
+ if (taskRunner.IsRunning) {
+ pendingSolutions.Add (solution);
+ return;
+ }
+
+ taskRunner.Start (GetProjects (solution));
+ });
+ }
+
+ IEnumerable<IDotNetProject> GetProjects (ISolution solution)
+ {
+ if (solution != null) {
+ foreach (IDotNetProject project in solution.GetAllProjects ()) {
+ yield return project;
+ }
+ }
+ }
+ + public void CheckForUpdatesCompleted (IEnumerable<UpdatedNuGetPackagesInProject> projects)
+ {
+ projectsWithUpdatedPackages.AddRange (projects.ToList ());
+
+ if (AnyUpdates ()) {
+ packageManagementEvents.OnUpdatedPackagesAvailable ();
+ }
+
+ if (pendingSolutions.Any ()) {
+ var solution = pendingSolutions[0];
+ pendingSolutions.RemoveAt (0);
+ CheckForUpdates (solution);
+ }
+ }
+
+ public UpdatedNuGetPackagesInProject GetUpdatedPackages (IDotNetProject project)
+ {
+ UpdatedNuGetPackagesInProject updatedPackages = projectsWithUpdatedPackages
+ .FirstOrDefault (item => item.Project.Equals (project));
+
+ if (updatedPackages != null) {
+ return updatedPackages;
+ }
+ return new UpdatedNuGetPackagesInProject (project);
+ }
+
+ public bool AnyUpdates ()
+ {
+ return GuiSyncDispatch (() => {
+ return projectsWithUpdatedPackages.Any ();
+ });
+ }
+
+ protected virtual void GuiDispatch (Action action)
+ {
+ Runtime.RunInMainThread (action).Wait ();
+ }
+
+ T GuiSyncDispatch<T> (Func<T> action)
+ {
+ T result = default(T);
+ GuiDispatch (() => result = action ());
+ return result;
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesProvider.cs new file mode 100644 index 0000000000..63b15166cb --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedNuGetPackagesProvider.cs @@ -0,0 +1,153 @@ +//
+// UpdatedNuGetPackagesProvider.cs
+//
+// Author:
+// Matt Ward <matt.ward@xamarin.com>
+//
+// Copyright (c) 2016 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.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using MonoDevelop.Core;
+using NuGet.Logging;
+using NuGet.Packaging;
+using NuGet.Packaging.Core;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+
+namespace MonoDevelop.PackageManagement
+{
+ internal class UpdatedNuGetPackagesProvider
+ {
+ List<SourceRepository> sourceRepositories;
+ IDotNetProject dotNetProject;
+ NuGetProject project;
+ CancellationToken cancellationToken;
+ UpdatedNuGetPackagesInProject updatedPackagesInProject;
+ List<PackageIdentity> updatedPackages = new List<PackageIdentity> ();
+
+ public UpdatedNuGetPackagesProvider (
+ IDotNetProject dotNetProject,
+ IMonoDevelopSolutionManager solutionManager,
+ NuGetProject project,
+ CancellationToken cancellationToken = default(CancellationToken))
+ {
+ this.dotNetProject = dotNetProject;
+ this.project = project;
+
+ var sourceRepositoryProvider = solutionManager.CreateSourceRepositoryProvider ();
+ this.sourceRepositories = sourceRepositoryProvider.GetRepositories ().ToList ();
+
+ this.cancellationToken = cancellationToken;
+ }
+
+ public IEnumerable<PackageIdentity> UpdatedPackages {
+ get { return updatedPackages; }
+ }
+
+ public UpdatedNuGetPackagesInProject UpdatedPackagesInProject {
+ get {
+ if (updatedPackagesInProject == null) {
+ updatedPackagesInProject = new UpdatedNuGetPackagesInProject (dotNetProject, updatedPackages);
+ }
+ return updatedPackagesInProject;
+ }
+ }
+
+ public async Task FindUpdatedPackages ()
+ {
+ var installedPackages = await project.GetInstalledPackagesAsync (cancellationToken);
+
+ foreach (PackageReference packageReference in installedPackages) {
+ if (cancellationToken.IsCancellationRequested) {
+ break;
+ }
+
+ var tasks = sourceRepositories
+ .Select (sourceRepository => GetUpdates (sourceRepository, packageReference))
+ .ToList ();
+
+ tasks
+ .Select (task => task.ContinueWith (LogError, TaskContinuationOptions.OnlyOnFaulted))
+ .ToArray ();
+
+ try {
+ await Task.WhenAll (tasks);
+ } catch {
+ // Ignore any failures.
+ }
+
+ var updatedPackage = tasks
+ .Where (task => task.Exception == null)
+ .Select (task => task.Result)
+ .Where (package => package != null)
+ .OrderByDescending (package => package.Version)
+ .FirstOrDefault ();
+
+ if (updatedPackage != null) {
+ updatedPackages.Add (updatedPackage);
+ }
+ }
+ }
+ + async Task<PackageIdentity> GetUpdates (SourceRepository sourceRepository, PackageReference packageReference)
+ {
+ var metadataResource = await sourceRepository.GetResourceAsync<PackageMetadataResource> (cancellationToken);
+
+ if (metadataResource == null)
+ return null;
+
+ var packages = await metadataResource.GetMetadataAsync (
+ packageReference.PackageIdentity.Id,
+ includePrerelease: packageReference.PackageIdentity.Version.IsPrerelease,
+ includeUnlisted: false,
+ log: NullLogger.Instance,
+ token: cancellationToken);
+
+ var package = packages
+ .Where (p => IsPackageVersionAllowed (p, packageReference))
+ .OrderByDescending (p => p.Identity.Version).FirstOrDefault ();
+ if (package == null)
+ return null;
+
+ if (package.Identity.Version > packageReference.PackageIdentity.Version)
+ return package.Identity;
+
+ return null;
+ }
+
+ void LogError (Task<PackageIdentity> task)
+ {
+ LoggingService.LogError ("Check for updates error.", task.Exception.GetBaseException ());
+ }
+
+ bool IsPackageVersionAllowed (IPackageSearchMetadata package, PackageReference packageReference)
+ {
+ if (!packageReference.HasAllowedVersions)
+ return true;
+
+ return packageReference.AllowedVersions.Satisfies (package.Identity.Version);
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackageViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackageViewModel.cs deleted file mode 100644 index d26a7ded54..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackageViewModel.cs +++ /dev/null @@ -1,58 +0,0 @@ -//
-// UpdatedPackageViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatedPackageViewModel : PackageViewModel
- {
- public UpdatedPackageViewModel(
- IPackageViewModelParent parent,
- IPackageFromRepository package,
- SelectedProjectsForUpdatedPackages selectedProjects,
- IPackageManagementEvents packageManagementEvents,
- IPackageActionRunner actionRunner,
- ILogger logger)
- : base(parent, package, selectedProjects, packageManagementEvents, actionRunner, logger)
- {
- }
-
- protected override ProcessPackageOperationsAction CreateInstallPackageAction(
- IPackageManagementProject project)
- {
- return project.CreateUpdatePackageAction();
- }
-
- protected override IDisposable StartInstallOperation(IPackageFromRepository package)
- {
- return package.StartUpdateOperation();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackageViewModelFactory.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackageViewModelFactory.cs deleted file mode 100644 index 0154ed85e5..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackageViewModelFactory.cs +++ /dev/null @@ -1,55 +0,0 @@ -//
-// UpdatePackageViewModelFactory.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatedPackageViewModelFactory : PackageViewModelFactory
- {
- SelectedProjectsForUpdatedPackages selectedProjectsForUpdatedPackages;
-
- public UpdatedPackageViewModelFactory(IPackageViewModelFactory packageViewModelFactory)
- : base(packageViewModelFactory)
- {
- selectedProjectsForUpdatedPackages = new SelectedProjectsForUpdatedPackages(Solution);
- }
-
- public override PackageViewModel CreatePackageViewModel(IPackageViewModelParent parent, IPackageFromRepository package)
- {
- return new UpdatedPackageViewModel(
- parent,
- package,
- selectedProjectsForUpdatedPackages,
- PackageManagementEvents,
- PackageActionRunner,
- Logger);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackages.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackages.cs deleted file mode 100644 index 049efda942..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackages.cs +++ /dev/null @@ -1,109 +0,0 @@ -//
-// UpdatedPackages.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatedPackages
- {
- IPackageRepository sourceRepository;
- List<IPackageName> installedPackages;
- IPackageConstraintProvider constraintProvider;
-
- public UpdatedPackages (
- IPackageManagementProject project,
- IPackageRepository aggregateRepository)
- : this (
- project.GetPackageReferences (),
- aggregateRepository,
- project.ConstraintProvider)
- {
- }
-
- public UpdatedPackages (
- IEnumerable<PackageReference> packageReferences,
- IPackageRepository aggregrateRepository,
- IPackageConstraintProvider constraintProvider)
- {
- installedPackages = packageReferences
- .Select (packageReference => new PackageName (packageReference.Id, packageReference.Version))
- .Select (packageReference => (IPackageName)packageReference)
- .ToList ();
-
- this.sourceRepository = aggregrateRepository;
- this.constraintProvider = constraintProvider;
- }
-
- public UpdatedPackages(
- IQueryable<IPackage> installedPackages,
- IPackageRepository aggregrateRepository)
- {
- }
-
- public string SearchTerms { get; set; }
-
- public IEnumerable<IPackage> GetUpdatedPackages (bool includePrerelease = false)
- {
- List<IPackageName> localPackages = installedPackages;
- IEnumerable<IPackageName> distinctLocalPackages = DistinctPackages (localPackages);
- return GetUpdatedPackages (distinctLocalPackages, includePrerelease);
- }
-
- /// <summary>
- /// If we have jQuery 1.6 and 1.7 then return just jquery 1.6
- /// </summary>
- IEnumerable<IPackageName> DistinctPackages (List<IPackageName> packages)
- {
- if (packages.Any ()) {
- packages.Sort ((x, y) => x.Version.CompareTo (y.Version));
- return packages.Distinct<IPackageName> (PackageEqualityComparer.Id).ToList ();
- }
- return packages;
- }
-
- IEnumerable<IPackage> GetUpdatedPackages (
- IEnumerable<IPackageName> localPackages,
- bool includePrelease)
- {
- IEnumerable<IVersionSpec> constraints = localPackages
- .Select (package => constraintProvider.GetConstraint (package.Id));
-
- return sourceRepository.GetUpdates (
- localPackages,
- includePrelease,
- false,
- null,
- constraints);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs deleted file mode 100644 index 36c274a81f..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesInSolution.cs +++ /dev/null @@ -1,270 +0,0 @@ -//
-// UpdatedPackagesInSolution.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 System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using MonoDevelop.PackageManagement;
-using MonoDevelop.Core;
-using MonoDevelop.Ide;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatedPackagesInSolution : IUpdatedPackagesInSolution
- {
- IPackageManagementSolution solution;
- IRegisteredPackageRepositories registeredPackageRepositories;
- IPackageManagementEvents packageManagementEvents;
- CheckForUpdatesTaskRunner taskRunner;
- List<ParentPackageOperationDuringCheckForUpdates> packageOperationsDuringCheckForUpdates = new List<ParentPackageOperationDuringCheckForUpdates> ();
- List<UpdatedPackagesInProject> projectsWithUpdatedPackages = new List<UpdatedPackagesInProject> ();
-
- class ParentPackageOperationDuringCheckForUpdates - {
- public ParentPackageOperationDuringCheckForUpdates (ParentPackageOperationEventArgs eventArgs, bool isInstall)
- {
- EventArgs = eventArgs;
- IsInstall = isInstall;
- }
-
- public ParentPackageOperationEventArgs EventArgs { get; set; }
- public bool IsInstall { get; set; }
- }
-
- public UpdatedPackagesInSolution (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageManagementEvents packageManagementEvents)
- : this (
- solution,
- registeredPackageRepositories,
- packageManagementEvents,
- new CheckForUpdatesTaskRunner ())
- {
- }
-
- public UpdatedPackagesInSolution (
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
- IPackageManagementEvents packageManagementEvents,
- CheckForUpdatesTaskRunner taskRunner)
- {
- this.solution = solution;
- this.registeredPackageRepositories = registeredPackageRepositories;
- this.packageManagementEvents = packageManagementEvents;
- this.taskRunner = taskRunner;
-
- this.packageManagementEvents.ParentPackageInstalled += PackageInstalled;
- this.packageManagementEvents.ParentPackageUninstalled += PackageUninstalled;
- }
-
- void PackageInstalled (object sender, ParentPackageOperationEventArgs e)
- {
- RefreshUpdatedPackages (e, true);
- }
-
- void PackageUninstalled (object sender, ParentPackageOperationEventArgs e)
- {
- RefreshUpdatedPackages (e, false);
- }
-
- void RefreshUpdatedPackages (ParentPackageOperationEventArgs e, bool installed)
- {
- GuiDispatch (() => {
- if (taskRunner.IsRunning) {
- packageOperationsDuringCheckForUpdates.Add (
- new ParentPackageOperationDuringCheckForUpdates (e, installed));
- } else {
- RemoveUpdatedPackages (e, installed);
- }
- });
- }
-
- void RemoveUpdatedPackages (ParentPackageOperationEventArgs e, bool installed)
- {
- UpdatedPackagesInProject updatedPackages = GetUpdatedPackages (e.Project.Project);
- if (updatedPackages.AnyPackages ()) {
- if (!installed) {
- updatedPackages.RemovePackage (e.Package);
- }
- updatedPackages.RemoveUpdatedPackages (e.Project.GetPackageReferences ());
- }
- }
-
- public void Clear ()
- {
- taskRunner.Stop ();
- projectsWithUpdatedPackages = new List<UpdatedPackagesInProject> ();
- packageOperationsDuringCheckForUpdates = new List<ParentPackageOperationDuringCheckForUpdates> ();
- }
-
- public void CheckForUpdates ()
- {
- GuiDispatch (() => {
- Clear ();
- var task = new CheckForUpdatesTask (this, GetProjectsWithPackages ());
- taskRunner.Start (task);
- });
- }
-
- public void CheckForUpdatesCompleted (IEnumerable<UpdatedPackagesInProject> projects)
- {
- projectsWithUpdatedPackages = projects.ToList ();
-
- RemovePackagesUpdatedDuringCheckForUpdates ();
-
- if (AnyUpdates ()) {
- packageManagementEvents.OnUpdatedPackagesAvailable ();
- }
- }
-
- void RemovePackagesUpdatedDuringCheckForUpdates ()
- {
- foreach (ParentPackageOperationDuringCheckForUpdates operation in packageOperationsDuringCheckForUpdates) {
- RemoveUpdatedPackages (operation.EventArgs, operation.IsInstall);
- }
- packageOperationsDuringCheckForUpdates.Clear ();
- }
-
- IEnumerable<IPackageManagementProject> GetProjectsWithPackages ()
- {
- return GetProjects ().Where (project => HasPackages (project));
- }
-
- IEnumerable<IPackageManagementProject> GetProjects ()
- {
- IPackageRepository repository = registeredPackageRepositories.CreateAggregateRepository ();
- return solution.GetProjects (repository).ToList ();
- }
-
- bool HasPackages (IPackageManagementProject project)
- {
- return FileExists (project.Project.GetPackagesConfigFilePath ());
- }
-
- public UpdatedPackagesInProject CheckForUpdates (IPackageManagementProject project)
- {
- LogCheckingForUpdates (project.Name);
-
- project.Logger = new PackageManagementLogger (packageManagementEvents);
-
- var packageReferences = project.GetPackageReferences ();
-
- List<IPackage> packages = GetUpdatedStablePackages (project, packageReferences).ToList ();
- packages.AddRange (GetUpdatedPrereleasePackages (project, packageReferences));
-
- LogPackagesFound (packages.Count);
-
- return new UpdatedPackagesInProject (project.Project, packages);
- }
-
- IEnumerable<IPackage> GetUpdatedStablePackages (
- IPackageManagementProject project,
- IEnumerable<PackageReference> packageReferences)
- {
- return GetUpdatedPackages (project, packageReferences, false, packageRef => packageRef.IsReleaseVersion ());
- }
-
- IEnumerable<IPackage> GetUpdatedPrereleasePackages (
- IPackageManagementProject project,
- IEnumerable<PackageReference> packageReferences)
- {
- return GetUpdatedPackages (project, packageReferences, true, packageRef => !packageRef.IsReleaseVersion ());
- }
-
- IEnumerable<IPackage> GetUpdatedPackages (
- IPackageManagementProject project,
- IEnumerable<PackageReference> packageReferences,
- bool includePrerelease,
- Func<PackageReference, bool> filter)
- {
- var filteredPackageReferences = packageReferences.Where (filter).ToList ();
-
- if (!filteredPackageReferences.Any ())
- return Enumerable.Empty <IPackage> ();
-
- var updatedPackages = new UpdatedPackages (
- filteredPackageReferences,
- project.SourceRepository,
- project.ConstraintProvider);
-
- return updatedPackages.GetUpdatedPackages (includePrerelease);
- }
-
- void LogCheckingForUpdates (string projectName)
- {
- Log (GettextCatalog.GetString ("Checking {0} for updates...", projectName));
- }
-
- void LogPackagesFound (int count)
- {
- Log (GettextCatalog.GetPluralString ("{0} update found.", "{0} updates found.", count, count));
- }
-
- void Log (string message)
- {
- packageManagementEvents.OnPackageOperationMessageLogged (MessageLevel.Info, message);
- }
-
- public UpdatedPackagesInProject GetUpdatedPackages (IDotNetProject project)
- {
- UpdatedPackagesInProject updatedPackages = projectsWithUpdatedPackages
- .FirstOrDefault (item => item.Project.Equals (project));
-
- if (updatedPackages != null) {
- return updatedPackages;
- }
- return new UpdatedPackagesInProject (project);
- }
-
- public bool AnyUpdates ()
- {
- return GuiSyncDispatch (() => {
- return projectsWithUpdatedPackages.Any ();
- });
- }
-
- protected virtual void GuiDispatch (Action action)
- {
- Runtime.RunInMainThread (action).Wait ();
- }
-
- T GuiSyncDispatch<T> (Func<T> action)
- {
- T result = default(T);
- GuiDispatch (() => result = action ());
- return result;
- }
-
- protected virtual bool FileExists (string path)
- {
- return File.Exists (path);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesMonitor.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesMonitor.cs index ff4b92691b..040bb30ed7 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesMonitor.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesMonitor.cs @@ -27,49 +27,43 @@ using System;
using System.Collections.Generic;
using System.Linq;
-using MonoDevelop.PackageManagement;
-using NuGet;
namespace MonoDevelop.PackageManagement
{
internal class UpdatedPackagesMonitor : IDisposable
{
- List<IPackageManagementProject> projects;
- bool packagesUpdated;
+ List<IDotNetProject> projects;
+ List<IDotNetProject> projectsNotUpdated = new List<IDotNetProject> ();
- public UpdatedPackagesMonitor (IPackageManagementProject project)
- : this (new IPackageManagementProject [] { project })
+ public UpdatedPackagesMonitor (IDotNetProject project)
+ : this (new IDotNetProject [] { project })
{
}
- public UpdatedPackagesMonitor (IEnumerable<IPackageManagementProject> projects)
+ public UpdatedPackagesMonitor (IEnumerable<IDotNetProject> projects)
{
this.projects = projects.ToList ();
- RegisterProjectEvents ();
+ PackageManagementServices.PackageManagementEvents.NoUpdateFound += NoUpdateFound;
}
- void RegisterProjectEvents ()
+ void NoUpdateFound (object sender, DotNetProjectEventArgs e)
{
- foreach (IPackageManagementProject project in projects) {
- project.PackageReferenceAdded += PackageReferenceAdded;
- }
+ projectsNotUpdated.Add (e.Project);
}
- void PackageReferenceAdded (object sender, PackageOperationEventArgs e)
+ public void Dispose ()
{
- packagesUpdated = true;
+ PackageManagementServices.PackageManagementEvents.NoUpdateFound -= NoUpdateFound;
}
- public void Dispose ()
+ public bool AnyPackagesUpdated ()
{
- foreach (IPackageManagementProject project in projects) {
- project.PackageReferenceAdded -= PackageReferenceAdded;
- }
+ return projects.Any (project => IsProjectUpdated (project));
}
- public bool AnyPackagesUpdated ()
+ bool IsProjectUpdated (IDotNetProject project)
{
- return packagesUpdated;
+ return !projectsNotUpdated.Any (project.Equals);
}
}
}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesViewModel.cs deleted file mode 100644 index a808374cb3..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UpdatedPackagesViewModel.cs +++ /dev/null @@ -1,130 +0,0 @@ -//
-// UpdatedPackagesViewModel.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 System.Collections.Generic;
-using System.Linq;
-
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UpdatedPackagesViewModel : PackagesViewModel
- {
- PackageManagementSelectedProjects selectedProjects;
- UpdatedPackages updatedPackages;
- string errorMessage = String.Empty;
- ILogger logger;
- IPackageManagementEvents packageManagementEvents;
-
- public UpdatedPackagesViewModel(
- IPackageManagementSolution solution,
- IRegisteredPackageRepositories registeredPackageRepositories,
- UpdatedPackageViewModelFactory packageViewModelFactory,
- ITaskFactory taskFactory)
- : base(
- registeredPackageRepositories,
- packageViewModelFactory,
- taskFactory)
- {
- this.selectedProjects = new PackageManagementSelectedProjects(solution);
- this.logger = packageViewModelFactory.Logger;
- this.packageManagementEvents = packageViewModelFactory.PackageManagementEvents;
-
- packageManagementEvents.ParentPackagesUpdated += PackagesUpdated;
-
- ShowPackageSources = true;
- ShowUpdateAllPackages = true;
- ShowPrerelease = true;
- }
-
- void PackagesUpdated(object sender, EventArgs e)
- {
- ReadPackages();
- }
-
- protected override void OnDispose()
- {
- packageManagementEvents.ParentPackagesUpdated -= PackagesUpdated;
- }
-
- protected override void UpdateRepositoryBeforeReadPackagesTaskStarts()
- {
- try {
- IPackageRepository repository = RegisteredPackageRepositories.ActiveRepository;
- IQueryable<IPackage> installedPackages = GetInstalledPackages(repository);
- updatedPackages = new UpdatedPackages(installedPackages, repository);
- } catch (Exception ex) {
- errorMessage = ex.Message;
- }
- }
-
- IQueryable<IPackage> GetInstalledPackages(IPackageRepository aggregateRepository)
- {
- return selectedProjects.GetInstalledPackages(aggregateRepository);
- }
-
- protected override IQueryable<IPackage> GetAllPackages()
- {
- if (updatedPackages == null) {
- ThrowSavedException();
- }
- return GetUpdatedPackages();
- }
-
- void ThrowSavedException()
- {
- throw new ApplicationException(errorMessage);
- }
-
- IQueryable<IPackage> GetUpdatedPackages()
- {
- return updatedPackages.GetUpdatedPackages(IncludePrerelease).AsQueryable();
- }
-
- protected override void TryUpdatingAllPackages()
- {
- List<IPackageFromRepository> packages = GetPackagesFromViewModels().ToList();
- using (IDisposable operation = StartUpdateOperation(packages.First())) {
- var factory = new UpdatePackagesActionFactory(logger, packageManagementEvents);
- IUpdatePackagesAction action = factory.CreateAction(selectedProjects, packages);
- ActionRunner.Run(action);
- }
- }
-
- IDisposable StartUpdateOperation(IPackageFromRepository package)
- {
- return package.Repository.StartUpdateOperation();
- }
-
- IEnumerable<IPackageFromRepository> GetPackagesFromViewModels()
- {
- return PackageViewModels.Select(viewModel => viewModel.GetPackage() as IPackageFromRepository);
- }
- }
-}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UserAgentGeneratorForRepositoryRequests.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UserAgentGeneratorForRepositoryRequests.cs deleted file mode 100644 index 74490b9c25..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/UserAgentGeneratorForRepositoryRequests.cs +++ /dev/null @@ -1,60 +0,0 @@ -//
-// UserAgentGeneratorForRepositoryRequests.cs
-//
-// Author:
-// Matt Ward <ward.matt@gmail.com>
-//
-// Copyright (C) 2013 Matthew Ward
-//
-// 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 NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- internal class UserAgentGeneratorForRepositoryRequests
- {
- MonoDevelopHttpUserAgent userAgent = new MonoDevelopHttpUserAgent();
-
- public void Register (IPackageRepositoryFactoryEvents repositoryFactoryEvents)
- {
- repositoryFactoryEvents.RepositoryCreated += RepositoryCreated;
- }
-
- void RepositoryCreated(object sender, PackageRepositoryFactoryEventArgs e)
- {
- RegisterHttpClient(e.Repository as IHttpClientEvents);
- }
-
- void RegisterHttpClient(IHttpClientEvents clientEvents)
- {
- if (clientEvents != null) {
- clientEvents.SendingRequest += SendingRequest;
- }
- }
-
- void SendingRequest(object sender, WebRequestEventArgs e)
- {
- HttpUtility.SetUserAgent(e.Request, userAgent.ToString());
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/WildcardVersionSpec.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/WildcardVersionSpec.cs deleted file mode 100644 index f3d61c2575..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement/WildcardVersionSpec.cs +++ /dev/null @@ -1,153 +0,0 @@ -//
-// WildcardVersion.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 System.Linq;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement
-{
- /// <summary>
- /// Implicit wildcard version specification.
- ///
- /// 1 => 1.*
- /// 1.2 => 1.2.*
- /// 1.2.3 => 1.2.3.*
- /// 1.2.3.4 => 1.2.3.4
- /// </summary>
- internal class WildcardVersionSpec
- {
- string[] parts;
- int wildcardPart = -1;
-
- bool HasWildcards {
- get { return wildcardPart != -1; }
- }
-
- public WildcardVersionSpec (string version)
- {
- Parse (version);
- }
-
- public VersionSpec VersionSpec { get; private set; }
-
- void Parse (string versionText)
- {
- SplitIntoParts (versionText);
-
- if (!ParseExactVersion (ConvertVersionIfSingleNumber (versionText))) {
- return;
- }
-
- ConfigureMaximumVersion ();
- }
-
- void SplitIntoParts (string versionText)
- {
- parts = versionText.Split ('.');
- }
-
- /// <summary>
- /// Version "1" will fail to be parsed by the SemanticVersion
- /// class so append ".0" to allow the conversion to succeed.
- /// </summary>
- string ConvertVersionIfSingleNumber (string versionText)
- {
- if (parts.Length == 1) {
- return versionText + ".0";
- }
- return versionText;
- }
-
- bool ParseExactVersion (string versionText)
- {
- SemanticVersion version = null;
- if (SemanticVersion.TryParse (versionText, out version)) {
- VersionSpec = new VersionSpec (version);
- return true;
- }
- return false;
- }
-
- void ConfigureMaximumVersion ()
- {
- if (!NeedsWildCard ())
- return;
-
- VersionSpec.IsMaxInclusive = false;
- VersionSpec.MaxVersion = GetMaximumWildcardVersion (VersionSpec.MinVersion);
- }
-
- bool NeedsWildCard ()
- {
- return parts.Length < 4;
- }
-
- string GetMinimumWildcardVersion (string wildcardVersion)
- {
- return wildcardVersion.Replace ('*', '0');
- }
-
- SemanticVersion GetMaximumWildcardVersion (SemanticVersion minVersion)
- {
- return new SemanticVersion (GetMaximumWildcardVersion (minVersion.Version));
- }
-
- Version GetMaximumWildcardVersion (Version minVersion)
- {
- switch (parts.Length) {
- case 1:
- return new Version (minVersion.Major + 1, 0, 0, 0);
- case 2:
- return new Version (minVersion.Major, minVersion.Minor + 1, 0, 0);
- default:
- return new Version (minVersion.Major, minVersion.Minor, minVersion.Build + 1, 0);
- }
- }
-
- public bool Satisfies (SemanticVersion version)
- {
- if (VersionSpec == null)
- return true;
-
- if (!IsSpecial (VersionSpec.MinVersion) && IsSpecial (version)) {
- version = RemoveSpecialPart (version);
- }
- return VersionSpec.Satisfies (version);
- }
-
- static bool IsSpecial (SemanticVersion version)
- {
- return !String.IsNullOrEmpty (version.SpecialVersion);
- }
-
- SemanticVersion RemoveSpecialPart (SemanticVersion version)
- {
- return new SemanticVersion (version.Version);
- }
- }
-}
-
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DetailControlModel.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DetailControlModel.cs new file mode 100644 index 0000000000..61a9808ea1 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DetailControlModel.cs @@ -0,0 +1,316 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.ProjectManagement.Projects; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace NuGet.PackageManagement.UI +{ + /// <summary> + /// The base class of PackageDetailControlModel and PackageSolutionDetailControlModel. + /// When user selects an action, this triggers version list update. + /// </summary> + internal abstract class DetailControlModel : INotifyPropertyChanged + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] + protected IEnumerable<NuGetProject> _nugetProjects; + + // all versions of the _searchResultPackage + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] + protected List<NuGetVersion> _allPackageVersions; + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] + protected PackageItemListViewModel _searchResultPackage; + + //[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] + //protected ItemFilter _filter; + + private Dictionary<NuGetVersion, DetailedPackageMetadata> _metadataDict; + + protected DetailControlModel(IEnumerable<NuGetProject> nugetProjects) + { + _nugetProjects = nugetProjects; + // _options = new Options(); + + // Show dependency behavior and file conflict options if any of the projects are non-build integrated + // _options.ShowClassicOptions = nugetProjects.Any(project => !(project is BuildIntegratedNuGetProject)); + } + + /// <summary> + /// The method is called when the associated DocumentWindow is closed. + /// </summary> + public virtual void CleanUp() + { + } + + /// <summary> + /// Returns the list of projects that are selected for the given action + /// </summary> + //public abstract IEnumerable<NuGetProject> GetSelectedProjects(UserAction action); + + /// <summary> + /// Sets the package to be displayed in the detail control. + /// </summary> + /// <param name="searchResultPackage">The package to be displayed.</param> + /// <param name="filter">The current filter. This will used to select the default action.</param> + public async virtual Task SetCurrentPackage( + PackageItemListViewModel searchResultPackage)//, + // ItemFilter filter) + { + _searchResultPackage = searchResultPackage; + //_filter = filter; + //OnPropertyChanged(nameof(Id)); + //OnPropertyChanged(nameof(IconUrl)); + + var versions = await searchResultPackage.GetVersionsAsync(); + + _allPackageVersions = versions.Select(v => v.Version).ToList(); + + //CreateVersions(); + //OnCurrentPackageChanged(); + } + /* + protected virtual void OnCurrentPackageChanged() + { + } + + public virtual void OnFilterChanged(ItemFilter? previousFilter, ItemFilter currentFilter) + { + _filter = currentFilter; + } + + /// <summary> + /// Get all installed packages across all projects (distinct) + /// </summary> + public virtual IEnumerable<PackageIdentity> InstalledPackages + { + get + { + return NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate + { + var installedPackages = new List<Packaging.PackageReference>(); + foreach (var project in _nugetProjects) + { + var projectInstalledPackages = await project.GetInstalledPackagesAsync(CancellationToken.None); + installedPackages.AddRange(projectInstalledPackages); + } + return installedPackages.Select(e => e.PackageIdentity).Distinct(PackageIdentity.Comparer); + }); + } + } + + /// <summary> + /// Get all installed packages across all projects (distinct) + /// </summary> + public virtual IEnumerable<Packaging.Core.PackageDependency> InstalledPackageDependencies + { + get + { + return NuGetUIThreadHelper.JoinableTaskFactory.Run(async delegate + { + var installedPackages = new HashSet<Packaging.Core.PackageDependency>(); + foreach (var project in _nugetProjects) + { + var dependencies = await GetDependencies(project); + + installedPackages.UnionWith(dependencies); + } + return installedPackages; + }); + } + } + + private static async Task<IReadOnlyList<Packaging.Core.PackageDependency>> GetDependencies(NuGetProject project) + { + var results = new List<Packaging.Core.PackageDependency>(); + + var projectInstalledPackages = await project.GetInstalledPackagesAsync(CancellationToken.None); + var buildIntegratedProject = project as BuildIntegratedNuGetProject; + + foreach (var package in projectInstalledPackages) + { + VersionRange range = null; + + if (buildIntegratedProject != null && package.HasAllowedVersions) + { + // The actual range is passed as the allowed version range for build integrated projects. + range = package.AllowedVersions; + } + else + { + range = new VersionRange( + minVersion: package.PackageIdentity.Version, + includeMinVersion: true, + maxVersion: package.PackageIdentity.Version, + includeMaxVersion: true); + } + + var dependency = new Packaging.Core.PackageDependency(package.PackageIdentity.Id, range); + + results.Add(dependency); + } + + return results; + } +*/ + // Called after package install/uninstall. + public abstract void Refresh(); + + public event PropertyChangedEventHandler PropertyChanged; + + protected void OnPropertyChanged(string propertyName) + { + var handler = PropertyChanged; + if (handler != null) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } + + public string Id + { + get { return _searchResultPackage?.Id; } + } + + public Uri IconUrl + { + get { return _searchResultPackage?.IconUrl; } + } + + private DetailedPackageMetadata _packageMetadata; + + public DetailedPackageMetadata PackageMetadata + { + get { return _packageMetadata; } + set + { + if (_packageMetadata != value) + { + _packageMetadata = value; + OnPropertyChanged(nameof(PackageMetadata)); + } + } + } + + protected abstract void CreateVersions(); + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] + protected List<DisplayVersion> _versions; + + // The list of versions that can be installed + public List<DisplayVersion> Versions + { + get { return _versions; } + } + + private DisplayVersion _selectedVersion; + + public DisplayVersion SelectedVersion + { + get { return _selectedVersion; } + set + { + if (_selectedVersion != value) + { + _selectedVersion = value; + + DetailedPackageMetadata packageMetadata; + if (_metadataDict != null && + _selectedVersion != null && + _metadataDict.TryGetValue(_selectedVersion.Version, out packageMetadata)) + { + PackageMetadata = packageMetadata; + } + else + { + PackageMetadata = null; + } + + OnPropertyChanged(nameof(SelectedVersion)); + } + } + } + + // Calculate the version to select among _versions and select it + protected void SelectVersion() + { + if (_versions.Count == 0) + { + // there's nothing to select + return; + } + + DisplayVersion versionToSelect = _versions + .Where(v => v != null && v.Version.Equals(_searchResultPackage.Version)) + .FirstOrDefault(); + if (versionToSelect == null) + { + versionToSelect = _versions[0]; + } + + if (versionToSelect != null) + { + SelectedVersion = versionToSelect; + } + } + + internal async Task LoadPackageMetadaAsync(IPackageMetadataProvider metadataProvider, CancellationToken token) + { + var versions = await _searchResultPackage.GetVersionsAsync(); + + var packages = Enumerable.Empty<IPackageSearchMetadata>(); + try + { + // load up the full details for each version + if (metadataProvider != null) + packages = await metadataProvider.GetPackageMetadataListAsync(Id, true, false, token); + } + catch (InvalidOperationException) + { + // Ignore failures. + } + + var uniquePackages = packages + .GroupBy(m => m.Identity.Version, (v, ms) => ms.First()); + + var s = uniquePackages + .GroupJoin( + versions, + m => m.Identity.Version, + d => d.Version, + (m, d) => new DetailedPackageMetadata(m, d.FirstOrDefault()?.DownloadCount)); + + _metadataDict = s.ToDictionary(m => m.Version); + + DetailedPackageMetadata p; + if (SelectedVersion != null + && _metadataDict.TryGetValue(SelectedVersion.Version, out p)) + { + PackageMetadata = p; + } + } + + public abstract bool IsSolution { get; } + + /*private Options _options; + + public Options Options + { + get { return _options; } + set + { + _options = value; + OnPropertyChanged(nameof(Options)); + } + }*/ + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DetailedPackageMetadata.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DetailedPackageMetadata.cs new file mode 100644 index 0000000000..e16eddcd53 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DetailedPackageMetadata.cs @@ -0,0 +1,67 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace NuGet.PackageManagement.UI +{ + public class DetailedPackageMetadata + { + public DetailedPackageMetadata() + { + } + + public DetailedPackageMetadata(IPackageSearchMetadata serverData, long? downloadCount) + { + Version = serverData.Identity.Version; + Summary = serverData.Summary; + Description = serverData.Description; + Authors = serverData.Authors; + Owners = serverData.Owners; + IconUrl = serverData.IconUrl; + LicenseUrl = serverData.LicenseUrl; + ProjectUrl = serverData.ProjectUrl; + ReportAbuseUrl = serverData.ReportAbuseUrl; + Tags = serverData.Tags; + DownloadCount = downloadCount; + Published = serverData.Published; + DependencySets = serverData.DependencySets? + .Select(e => new PackageDependencySetMetadata(e)) + ?? new PackageDependencySetMetadata[] { }; + HasDependencies = DependencySets.Any( + dependencySet => dependencySet.Dependencies != null && dependencySet.Dependencies.Count > 0); + } + + public NuGetVersion Version { get; set; } + public string Summary { get; set; } + + public string Description { get; set; } + + public string Authors { get; set; } + + public string Owners { get; set; } + + public Uri IconUrl { get; set; } + + public Uri LicenseUrl { get; set; } + + public Uri ProjectUrl { get; set; } + + public Uri ReportAbuseUrl { get; set; } + + public string Tags { get; set; } + + public long? DownloadCount { get; set; } + + public DateTimeOffset? Published { get; set; } + + public IEnumerable<PackageDependencySetMetadata> DependencySets { get; set; } + + // This property is used by data binding to display text "No dependencies" + public bool HasDependencies { get; set; } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DisplayVersion.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DisplayVersion.cs new file mode 100644 index 0000000000..94c0fd2413 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/DisplayVersion.cs @@ -0,0 +1,74 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using NuGet.Versioning;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Represents a version that will be displayed on the UI.
+ /// </summary>
+ internal class DisplayVersion
+ {
+ private readonly string _additionalInfo;
+
+ private readonly string _toString;
+
+ public DisplayVersion(
+ NuGetVersion version,
+ string additionalInfo)
+ : this(GetRange(version), additionalInfo)
+ {
+ }
+
+ public DisplayVersion(
+ VersionRange range,
+ string additionalInfo)
+ {
+ Range = range;
+ _additionalInfo = additionalInfo;
+
+ Version = range.MinVersion;
+
+ // Display a single version if the range is locked
+ if (range.HasLowerAndUpperBounds && range.MinVersion == range.MaxVersion)
+ {
+ _toString = string.IsNullOrEmpty(_additionalInfo) ?
+ Version.ToNormalizedString() :
+ _additionalInfo + " " + Version.ToNormalizedString();
+ }
+ else
+ {
+ // Display the range, use the original value for floating ranges
+ _toString = string.IsNullOrEmpty(_additionalInfo) ?
+ Range.OriginalString :
+ _additionalInfo + " " + Range.OriginalString;
+ }
+ }
+
+ public NuGetVersion Version { get; }
+
+ public VersionRange Range { get; }
+
+ public override string ToString()
+ {
+ return _toString;
+ }
+
+ public override bool Equals(object obj)
+ {
+ var other = obj as DisplayVersion;
+ return other != null && other.Version == Version;
+ }
+
+ public override int GetHashCode()
+ {
+ return Version.GetHashCode();
+ }
+
+ private static VersionRange GetRange(NuGetVersion version)
+ {
+ return new VersionRange(minVersion: version, includeMinVersion: true, maxVersion: version, includeMaxVersion: true);
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/FeedSearchContinuationToken.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/FeedSearchContinuationToken.cs new file mode 100644 index 0000000000..29f8c00f64 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/FeedSearchContinuationToken.cs @@ -0,0 +1,17 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using NuGet.Protocol.Core.Types;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Most commonly used continuation token for plain package feeds.
+ /// </summary>
+ internal class FeedSearchContinuationToken : ContinuationToken
+ {
+ public int StartIndex { get; set; }
+ public string SearchString { get; set; }
+ public SearchFilter SearchFilter { get; set; }
+ }
+}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IItemLoader.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IItemLoader.cs new file mode 100644 index 0000000000..a3edc5ca0e --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IItemLoader.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace NuGet.PackageManagement.UI
+{
+ internal interface IItemLoaderState
+ {
+ LoadingStatus LoadingStatus { get; }
+ int ItemsCount { get; }
+ IDictionary<string, LoadingStatus> SourceLoadingStatus { get; }
+ }
+
+ /// <summary>
+ /// Represents stateful item loader contract that supports pagination and background loading
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ internal interface IItemLoader<T>
+ {
+ bool IsMultiSource { get; }
+
+ IItemLoaderState State { get; }
+
+ IEnumerable<T> GetCurrent();
+
+ Task LoadNextAsync(IProgress<IItemLoaderState> progress, CancellationToken cancellationToken);
+
+ Task UpdateStateAsync(IProgress<IItemLoaderState> progress, CancellationToken cancellationToken);
+
+ void Reset();
+
+ Task<int> GetTotalCountAsync(int maxCount, CancellationToken cancellationToken);
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/INuGetUILogger.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/INuGetUILogger.cs new file mode 100644 index 0000000000..5baf10b5b4 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/INuGetUILogger.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace NuGet.PackageManagement.UI
+{
+ public interface INuGetUILogger
+ {
+ void Log(ProjectManagement.MessageLevel level, string message, params object[] args);
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IPackageFeed.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IPackageFeed.cs new file mode 100644 index 0000000000..a29317a86e --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IPackageFeed.cs @@ -0,0 +1,46 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.Protocol.Core.Types;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Package feed abstraction providing services of package enumeration with search criteria.
+ /// Supports pagination and background processing.
+ /// </summary>
+ internal interface IPackageFeed
+ {
+ bool IsMultiSource { get; }
+
+ /// <summary>
+ /// Starts new search.
+ /// </summary>
+ /// <param name="searchText">Optional text to search</param>
+ /// <param name="filter">Combined search filter</param>
+ /// <param name="cancellationToken">A cancellation token</param>
+ /// <returns>Search result. Possible outcome</returns>
+ Task<SearchResult<IPackageSearchMetadata>> SearchAsync(
+ string searchText, SearchFilter filter, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Proceeds with loading of next page using the same search criteria.
+ /// </summary>
+ /// <param name="continuationToken">Search state as returned with previous search result</param>
+ /// <param name="cancellationToken">A cancellation token</param>
+ /// <returns>Search result</returns>
+ Task<SearchResult<IPackageSearchMetadata>> ContinueSearchAsync(
+ ContinuationToken continuationToken, CancellationToken cancellationToken);
+
+ /// <summary>
+ /// Retrieves a search result of a background search operation.
+ /// </summary>
+ /// <param name="refreshToken">Search state as returned with previous search result</param>
+ /// <param name="cancellationToken">A cancellation token</param>
+ /// <returns>Refreshed search result</returns>
+ Task<SearchResult<IPackageSearchMetadata>> RefreshSearchAsync(
+ RefreshToken refreshToken, CancellationToken cancellationToken);
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IPackageMetadataProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IPackageMetadataProvider.cs new file mode 100644 index 0000000000..54bc36c39d --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/IPackageMetadataProvider.cs @@ -0,0 +1,58 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; + +namespace NuGet.PackageManagement.UI +{ + /// <summary> + /// Contract for a generalized package metadata provider associated with a package source(s). + /// </summary> + internal interface IPackageMetadataProvider + { + /// <summary> + /// Retrieves a package metadata of a specific version along with list of all available versions + /// </summary> + /// <param name="identity">Desired package id with version</param> + /// <param name="includePrerelease">Filters pre-release versions</param> + /// <param name="cancellationToken">Cancellation token</param> + /// <returns>Package metadata</returns> + Task<IPackageSearchMetadata> GetPackageMetadataAsync(PackageIdentity identity, + bool includePrerelease, CancellationToken cancellationToken); + + /// <summary> + /// Retrieves a package metadata of a highest available version along with list of all available versions + /// </summary> + /// <param name="identity">Desired package identity</param> + /// <param name="includePrerelease">Filters pre-release versions</param> + /// <param name="cancellationToken">A cancellation token</param> + /// <returns>Package metadata</returns> + Task<IPackageSearchMetadata> GetLatestPackageMetadataAsync(PackageIdentity identity, + bool includePrerelease, CancellationToken cancellationToken); + + /// <summary> + /// Retrieves a list of metadata objects of all available versions for given package id. + /// </summary> + /// <param name="packageId">Desired package Id</param> + /// <param name="includePrerelease">Filters pre-release versions</param> + /// <param name="includeUnlisted">Filters unlisted versions</param> + /// <param name="cancellationToken">A cancellation token</param> + /// <returns>Collection of packages matching query parameters</returns> + Task<IEnumerable<IPackageSearchMetadata>> GetPackageMetadataListAsync(string packageId, + bool includePrerelease, bool includeUnlisted, CancellationToken cancellationToken); + + /// <summary> + /// Retrieves a package metadata of a specific version along with list of all available versions + /// </summary> + /// <param name="identity">Desired package id with version</param> + /// <param name="includePrerelease">Filters pre-release versions</param> + /// <param name="cancellationToken">Cancellation token</param> + /// <returns>Package metadata</returns> + Task<IPackageSearchMetadata> GetLocalPackageMetadataAsync(PackageIdentity identity, + bool includePrerelease, CancellationToken cancellationToken); + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/LoadingStatus.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/LoadingStatus.cs new file mode 100644 index 0000000000..fb133b3f8c --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/LoadingStatus.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// List of possible statuses of items loading operation (search).
+ /// Utilized by item loader and UI for progress tracking.
+ /// </summary>
+ public enum LoadingStatus
+ {
+ Unknown, // not initialized
+ Cancelled, // loading cancelled
+ ErrorOccurred, // error occured
+ Loading, // loading is running in background
+ NoItemsFound, // loading complete, no items found
+ NoMoreItems, // loading complete, no more items discovered beyond current page
+ Ready // loading of current page is done, next page is available
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/MultiSourcePackageFeed.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/MultiSourcePackageFeed.cs new file mode 100644 index 0000000000..1c4262a5ee --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/MultiSourcePackageFeed.cs @@ -0,0 +1,250 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.Common;
+using NuGet.Indexing;
+using NuGet.Protocol.Core.Types;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Consolidated live sources package feed enumerating packages and aggregating search results.
+ /// </summary>
+ internal class MultiSourcePackageFeed : IPackageFeed
+ {
+ private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(5);
+ private const int PageSize = 25;
+
+ private readonly SourceRepository[] _sourceRepositories;
+ private readonly INuGetUILogger _logger;
+
+ public bool IsMultiSource => _sourceRepositories.Length > 1;
+
+ private class AggregatedContinuationToken : ContinuationToken
+ {
+ public string SearchString { get; set; }
+ public IDictionary<string, ContinuationToken> SourceSearchCursors { get; set; } = new Dictionary<string, ContinuationToken>();
+ }
+
+ private class AggregatedRefreshToken : RefreshToken
+ {
+ public string SearchString { get; set; }
+ public IDictionary<string, Task<SearchResult<IPackageSearchMetadata>>> SearchTasks { get; set; }
+ public IDictionary<string, LoadingStatus> SourceSearchStatus { get; set; }
+ }
+
+ public MultiSourcePackageFeed(IEnumerable<SourceRepository> sourceRepositories, INuGetUILogger logger)
+ {
+ if (sourceRepositories == null)
+ {
+ throw new ArgumentNullException(nameof(sourceRepositories));
+ }
+
+ if (!sourceRepositories.Any())
+ {
+ throw new ArgumentException("Collection of source repositories cannot be empty", nameof(sourceRepositories));
+ }
+
+ _sourceRepositories = sourceRepositories.ToArray();
+
+ _logger = logger;
+ }
+
+ public async Task<SearchResult<IPackageSearchMetadata>> SearchAsync(string searchText, SearchFilter filter, CancellationToken cancellationToken)
+ {
+ var searchTasks = TaskCombinators.ObserveErrorsAsync(
+ _sourceRepositories,
+ r => r.PackageSource.Name,
+ (r, t) => r.SearchAsync(searchText, filter, PageSize, t),
+ LogError,
+ cancellationToken);
+
+ return await WaitForCompletionOrBailOutAsync(searchText, searchTasks, cancellationToken);
+ }
+
+ public async Task<SearchResult<IPackageSearchMetadata>> ContinueSearchAsync(ContinuationToken continuationToken, CancellationToken cancellationToken)
+ {
+ var searchToken = continuationToken as AggregatedContinuationToken;
+
+ if (searchToken?.SourceSearchCursors == null)
+ {
+ throw new InvalidOperationException("Invalid token");
+ }
+
+ var searchTokens = _sourceRepositories
+ .Join(searchToken.SourceSearchCursors,
+ r => r.PackageSource.Name,
+ c => c.Key,
+ (r, c) => new { Repository = r, NextToken = c.Value });
+
+ var searchTasks = TaskCombinators.ObserveErrorsAsync(
+ searchTokens,
+ j => j.Repository.PackageSource.Name,
+ (j, t) => j.Repository.SearchAsync(j.NextToken, PageSize, t),
+ LogError,
+ cancellationToken);
+
+ return await WaitForCompletionOrBailOutAsync(searchToken.SearchString, searchTasks, cancellationToken);
+ }
+
+ public async Task<SearchResult<IPackageSearchMetadata>> RefreshSearchAsync(RefreshToken refreshToken, CancellationToken cancellationToken)
+ {
+ var searchToken = refreshToken as AggregatedRefreshToken;
+
+ if (searchToken == null)
+ {
+ throw new InvalidOperationException("Invalid token");
+ }
+
+ return await WaitForCompletionOrBailOutAsync(searchToken.SearchString, searchToken.SearchTasks, cancellationToken);
+ }
+
+ private async Task<SearchResult<IPackageSearchMetadata>> WaitForCompletionOrBailOutAsync(
+ string searchText,
+ IDictionary<string, Task<SearchResult<IPackageSearchMetadata>>> searchTasks,
+ CancellationToken cancellationToken)
+ {
+ if (searchTasks.Count == 0)
+ {
+ return SearchResult.Empty<IPackageSearchMetadata>();
+ }
+
+ var aggregatedTask = Task.WhenAll(searchTasks.Values);
+
+ RefreshToken refreshToken = null;
+ if (aggregatedTask != await Task.WhenAny(aggregatedTask, Task.Delay(DefaultTimeout)))
+ {
+ refreshToken = new AggregatedRefreshToken
+ {
+ SearchString = searchText,
+ SearchTasks = searchTasks,
+ RetryAfter = DefaultTimeout
+ };
+ }
+
+ var partitionedTasks = searchTasks
+ .ToLookup(t => t.Value.Status == TaskStatus.RanToCompletion);
+
+ var completedOnly = partitionedTasks[true];
+
+ SearchResult<IPackageSearchMetadata> aggregated;
+
+ if (completedOnly.Any())
+ {
+ var results = await Task.WhenAll(completedOnly.Select(kv => kv.Value));
+ aggregated = await AggregateSearchResultsAsync(searchText, results);
+ }
+ else
+ {
+ aggregated = SearchResult.Empty<IPackageSearchMetadata>();
+ }
+
+ aggregated.RefreshToken = refreshToken;
+
+ var notCompleted = partitionedTasks[false];
+
+ if (notCompleted.Any())
+ {
+ aggregated.SourceSearchStatus
+ .AddRange(notCompleted
+ .ToDictionary(kv => kv.Key, kv => GetLoadingStatus(kv.Value.Status)));
+ }
+
+ return aggregated;
+ }
+
+ private static LoadingStatus GetLoadingStatus(TaskStatus taskStatus)
+ {
+ switch(taskStatus)
+ {
+ case TaskStatus.Canceled:
+ return LoadingStatus.Cancelled;
+ case TaskStatus.Created:
+ case TaskStatus.RanToCompletion:
+ case TaskStatus.Running:
+ case TaskStatus.WaitingForActivation:
+ case TaskStatus.WaitingForChildrenToComplete:
+ case TaskStatus.WaitingToRun:
+ return LoadingStatus.Loading;
+ case TaskStatus.Faulted:
+ return LoadingStatus.ErrorOccurred;
+ default:
+ return LoadingStatus.Unknown;
+ }
+ }
+
+ private async Task<SearchResult<IPackageSearchMetadata>> AggregateSearchResultsAsync(
+ string searchText,
+ IEnumerable<SearchResult<IPackageSearchMetadata>> results)
+ {
+ SearchResult<IPackageSearchMetadata> result;
+
+ var nonEmptyResults = results.Where(r => r.Any()).ToArray();
+ if (nonEmptyResults.Length == 0)
+ {
+ result = SearchResult.Empty<IPackageSearchMetadata>();
+ }
+ else if (nonEmptyResults.Length == 1)
+ {
+ result = SearchResult.FromItems(nonEmptyResults[0].Items);
+ }
+ else
+ {
+ var items = nonEmptyResults.Select(r => r.Items).ToArray();
+
+ var indexer = new RelevanceSearchResultsIndexer();
+ var aggregator = new SearchResultsAggregator(indexer);
+ var aggregatedItems = await aggregator.AggregateAsync(
+ searchText, items);
+
+ result = SearchResult.FromItems(aggregatedItems.ToArray());
+ // set correct count of unmerged items
+ result.RawItemsCount = items.Aggregate(0, (r, next) => r + next.Count);
+ }
+
+ result.SourceSearchStatus = results
+ .SelectMany(r => r.SourceSearchStatus)
+ .ToDictionary(kv => kv.Key, kv => kv.Value);
+
+ var cursors = results
+ .Where(r => r.NextToken != null)
+ .ToDictionary(r => r.SourceSearchStatus.Single().Key, r => r.NextToken);
+
+ if (cursors.Keys.Any())
+ {
+ result.NextToken = new AggregatedContinuationToken
+ {
+ SearchString = searchText,
+ SourceSearchCursors = cursors
+ };
+ }
+
+ return result;
+ }
+
+ private void LogError(Task task, object state)
+ {
+ if (_logger == null)
+ {
+ // observe the task exception when no UI logger provided.
+ Trace.WriteLine(ExceptionUtilities.DisplayMessage(task.Exception));
+ return;
+ }
+
+ // UI logger only can be engaged from the main thread
+ MonoDevelop.Core.Runtime.RunInMainThread(() =>
+ {
+ var errorMessage = ExceptionUtilities.DisplayMessage(task.Exception);
+ _logger.Log(
+ ProjectManagement.MessageLevel.Error,
+ $"[{state.ToString()}] {errorMessage}");
+ });
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/MultiSourcePackageMetadataProvider.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/MultiSourcePackageMetadataProvider.cs new file mode 100644 index 0000000000..5b1081fed4 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/MultiSourcePackageMetadataProvider.cs @@ -0,0 +1,174 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using NuGet.Packaging.Core; +using NuGet.Protocol.Core.Types; +using NuGet.Versioning; + +namespace NuGet.PackageManagement.UI +{ + /// <summary> + /// Implements a consolidated metadata provider for multiple package sources + /// with optional local repository as a fallback metadata source. + /// </summary> + internal class MultiSourcePackageMetadataProvider : IPackageMetadataProvider + { + private readonly IEnumerable<SourceRepository> _sourceRepositories; + private readonly SourceRepository _localRepository; + private readonly SourceRepository _globalLocalRepository; + private readonly Logging.ILogger _logger; + + public MultiSourcePackageMetadataProvider( + IEnumerable<SourceRepository> sourceRepositories, + SourceRepository optionalLocalRepository, + SourceRepository optionalGlobalLocalRepository, + Logging.ILogger logger) + { + if (sourceRepositories == null) + { + throw new ArgumentNullException(nameof(sourceRepositories)); + } + _sourceRepositories = sourceRepositories; + + _localRepository = optionalLocalRepository; + + _globalLocalRepository = optionalGlobalLocalRepository; + + if (logger == null) + { + throw new ArgumentNullException(nameof(logger)); + } + _logger = logger; + } + + public async Task<IPackageSearchMetadata> GetPackageMetadataAsync(PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) + { + var tasks = _sourceRepositories + .Select(r => r.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken)) + .ToList(); + + if (_localRepository != null) + { + tasks.Add(_localRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken)); + } + + var ignored = tasks + .Select(task => task.ContinueWith(LogError, TaskContinuationOptions.OnlyOnFaulted)) + .ToArray(); + + var completed = (await Task.WhenAll(tasks)) + .Where(m => m != null); + + var master = completed.FirstOrDefault(m => !string.IsNullOrEmpty(m.Summary)) + ?? completed.FirstOrDefault() + ?? PackageSearchMetadataBuilder.FromIdentity(identity).Build(); + + return master.WithVersions( + asyncValueFactory: () => MergeVersionsAsync(identity, completed)); + } + + public async Task<IPackageSearchMetadata> GetLatestPackageMetadataAsync(PackageIdentity identity, + bool includePrerelease, CancellationToken cancellationToken) + { + var tasks = _sourceRepositories + .Select(r => r.GetLatestPackageMetadataAsync(identity.Id, includePrerelease, cancellationToken)) + .ToArray(); + + var ignored = tasks + .Select(task => task.ContinueWith(LogError, TaskContinuationOptions.OnlyOnFaulted)) + .ToArray(); + + var completed = (await Task.WhenAll(tasks)) + .Where(m => m != null); + + var highest = completed + .OrderByDescending(e => e.Identity.Version, VersionComparer.VersionRelease) + .FirstOrDefault(); + + return highest?.WithVersions( + asyncValueFactory: () => MergeVersionsAsync(identity, completed)); + } + + public async Task<IEnumerable<IPackageSearchMetadata>> GetPackageMetadataListAsync(string packageId, bool includePrerelease, bool includeUnlisted, CancellationToken cancellationToken) + { + var tasks = _sourceRepositories + .Select(r => r.GetPackageMetadataListAsync(packageId, includePrerelease, includeUnlisted, cancellationToken)) + .ToArray(); + + var ignored = tasks + .Select(task => task.ContinueWith(LogError, TaskContinuationOptions.OnlyOnFaulted)) + .ToArray(); + + var completed = (await Task.WhenAll(tasks)) + .Where(m => m != null); + + return completed.SelectMany(p => p); + } + + public async Task<IPackageSearchMetadata> GetLocalPackageMetadataAsync(PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) + { + var result = await _localRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken); + + if (result == null) + { + if (_globalLocalRepository != null) + result = await _globalLocalRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken); + + if (result == null) + { + return null; + } + } + + return result.WithVersions(asyncValueFactory: () => FetchAndMergeVersionsAsync(identity, includePrerelease, cancellationToken)); + } + + private static async Task<IEnumerable<VersionInfo>> MergeVersionsAsync(PackageIdentity identity, IEnumerable<IPackageSearchMetadata> packages) + { + var versions = await Task.WhenAll(packages.Select(m => m.GetVersionsAsync())); + + var allVersions = versions + .SelectMany(v => v) + .Concat(new[] { new VersionInfo(identity.Version) }); + + return allVersions + .GroupBy(v => v.Version, v => v.DownloadCount) + .Select(g => new VersionInfo(g.Key, g.Max())) + .ToArray(); + } + + private async Task<IEnumerable<VersionInfo>> FetchAndMergeVersionsAsync(PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken) + { + var tasks = _sourceRepositories + .Select(r => r.GetPackageMetadataAsync(identity, includePrerelease, cancellationToken)) + .ToList(); + + if (_localRepository != null) + { + tasks.Add(_localRepository.GetPackageMetadataFromLocalSourceAsync(identity, cancellationToken)); + } + + var ignored = tasks + .Select(task => task.ContinueWith(LogError, TaskContinuationOptions.OnlyOnFaulted)) + .ToArray(); + + var completed = (await Task.WhenAll(tasks)) + .Where(m => m != null); + + return await MergeVersionsAsync(identity, completed); + } + + private void LogError(Task task) + { + foreach (var ex in task.Exception.Flatten().InnerExceptions) + { + _logger.LogError(ex.ToString()); + } + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDependencyMetadata.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDependencyMetadata.cs new file mode 100644 index 0000000000..ee835cb087 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDependencyMetadata.cs @@ -0,0 +1,43 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Globalization; +using NuGet.Versioning; + +namespace NuGet.PackageManagement.UI +{ + public class PackageDependencyMetadata + { + public PackageDependencyMetadata() + { + } + + public PackageDependencyMetadata(Packaging.Core.PackageDependency serverData) + { + Id = serverData.Id; + Range = serverData.VersionRange; + } + + public string Id { get; } + + public VersionRange Range { get; } + + public PackageDependencyMetadata(string id, VersionRange range) + { + Id = id; + Range = range; + } + + public override string ToString() + { + if (Range == null) + { + return Id; + } + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}", + Id, Range.PrettyPrint()); + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDependentSetMetadata.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDependentSetMetadata.cs new file mode 100644 index 0000000000..69a0c3aced --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDependentSetMetadata.cs @@ -0,0 +1,25 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Linq; +using NuGet.Frameworks; +using NuGet.Packaging; + +namespace NuGet.PackageManagement.UI +{ + public class PackageDependencySetMetadata + { + public PackageDependencySetMetadata(PackageDependencyGroup dependencyGroup) + { + TargetFramework = dependencyGroup.TargetFramework; + Dependencies = dependencyGroup.Packages + .Select(d => new PackageDependencyMetadata(d)) + .ToList() + .AsReadOnly(); + } + + public NuGetFramework TargetFramework { get; private set; } + public IReadOnlyCollection<PackageDependencyMetadata> Dependencies { get; private set; } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDetailControlModel.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDetailControlModel.cs new file mode 100644 index 0000000000..954558f2f6 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageDetailControlModel.cs @@ -0,0 +1,144 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Threading.Tasks; +using NuGet.Packaging.Core; +using NuGet.ProjectManagement; +using NuGet.Versioning; + +namespace NuGet.PackageManagement.UI +{ + // used to manage packages in one project. + internal class PackageDetailControlModel : DetailControlModel + { + public PackageDetailControlModel (NuGetProject nugetProject) + : this (new [] { nugetProject }) + { + } + + public PackageDetailControlModel( + IEnumerable<NuGetProject> nugetProjects) + : base(nugetProjects) + { + Debug.Assert(nugetProjects.Count() == 1); + } + + //public async override Task SetCurrentPackage( + // PackageItemListViewModel searchResultPackage) + // ItemFilter filter) + //{ + // await base.SetCurrentPackage(searchResultPackage); + // + // UpdateInstalledVersion(); + //} + + public override bool IsSolution + { + get { return false; } + } +/* + private void UpdateInstalledVersion() + { + var installed = InstalledPackageDependencies.Where(p => + StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id)).OrderByDescending(p => p.VersionRange?.MinVersion, VersionComparer.Default); + + var dependency = installed.FirstOrDefault(package => package.VersionRange != null && package.VersionRange.HasLowerBound); + + if (dependency != null) + { + InstalledVersion = dependency.VersionRange.MinVersion; + } + else + { + InstalledVersion = null; + } + } +*/ + public override void Refresh() + { +// UpdateInstalledVersion(); +// CreateVersions(); + } + + private static bool HasId(string id, IEnumerable<PackageIdentity> packages) + { + return packages.Any(p => + StringComparer.OrdinalIgnoreCase.Equals(p.Id, id)); + } + + protected override void CreateVersions() + { +/* _versions = new List<DisplayVersion>(); + var installedDependency = InstalledPackageDependencies.Where(p => + StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id) && p.VersionRange != null && p.VersionRange.HasLowerBound) + .OrderByDescending(p => p.VersionRange.MinVersion) + .FirstOrDefault(); + + // installVersion is null if the package is not installed + var installedVersion = installedDependency?.VersionRange?.MinVersion; + + var allVersions = _allPackageVersions.OrderByDescending(v => v); + var latestPrerelease = allVersions.FirstOrDefault(v => v.IsPrerelease); + var latestStableVersion = allVersions.FirstOrDefault(v => !v.IsPrerelease); + + // Add lastest prerelease if neeeded + if (latestPrerelease != null + && (latestStableVersion == null || latestPrerelease > latestStableVersion) && + !latestPrerelease.Equals(installedVersion)) + { + _versions.Add(new DisplayVersion(latestPrerelease, Resources.Version_LatestPrerelease)); + } + + // Add latest stable if needed + if (latestStableVersion != null && + !latestStableVersion.Equals(installedVersion)) + { + _versions.Add(new DisplayVersion(latestStableVersion, Resources.Version_LatestStable)); + } + + // add a separator + if (_versions.Count > 0) + { + _versions.Add(null); + } + + foreach (var version in allVersions) + { + if (!version.Equals(installedVersion)) + { + _versions.Add(new DisplayVersion(version, string.Empty)); + } + } + + SelectVersion(); + + OnPropertyChanged(nameof(Versions)); +*/ } + + private NuGetVersion _installedVersion; + + public NuGetVersion InstalledVersion + { + get { return _installedVersion; } + private set + { + _installedVersion = value; + OnPropertyChanged(nameof(InstalledVersion)); + } + } + + //public override IEnumerable<NuGetProject> GetSelectedProjects(UserAction action) + //{ + // return _nugetProjects; + //} + + public IEnumerable<NuGetVersion> AllPackageVersions { + get { return _allPackageVersions; } + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageItemListViewModel.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageItemListViewModel.cs new file mode 100644 index 0000000000..0c026204e5 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageItemListViewModel.cs @@ -0,0 +1,306 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Globalization;
+using System.Linq;
+using System.Threading.Tasks;
+using NuGet.Common;
+using NuGet.Packaging.Core;
+using NuGet.Protocol.Core.Types;
+using NuGet.Versioning;
+
+namespace NuGet.PackageManagement.UI
+{
+ // This is the model class behind the package items in the infinite scroll list.
+ // Some of its properties, such as Latest Version, Status, are fetched on-demand in the background.
+ internal class PackageItemListViewModel : INotifyPropertyChanged
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public string Id { get; set; }
+
+ public NuGetVersion Version { get; set; }
+
+ private string _author;
+ public string Author
+ {
+ get
+ {
+ return _author;
+ }
+ set
+ {
+ _author = value;
+ OnPropertyChanged(nameof(Author));
+ }
+ }
+
+ // The installed version of the package.
+ private NuGetVersion _installedVersion;
+ public NuGetVersion InstalledVersion
+ {
+ get
+ {
+ return _installedVersion;
+ }
+ set
+ {
+ if (!VersionEquals(_installedVersion, value))
+ {
+ _installedVersion = value;
+ OnPropertyChanged(nameof(InstalledVersion));
+ }
+ }
+ }
+
+ // The version that can be installed or updated to. It is null
+ // if the installed version is already the latest.
+ private NuGetVersion _latestVersion;
+ public NuGetVersion LatestVersion
+ {
+ get
+ {
+ return _latestVersion;
+ }
+ set
+ {
+ if (!VersionEquals(_latestVersion, value))
+ {
+ _latestVersion = value;
+ OnPropertyChanged(nameof(LatestVersion));
+
+ // update tool tip
+ if (_latestVersion != null)
+ {
+ var displayVersion = new DisplayVersion(_latestVersion, string.Empty);
+ LatestVersionToolTip = string.Format(
+ CultureInfo.CurrentCulture,
+ "Latest version: {0}",
+ displayVersion);
+ }
+ else
+ {
+ LatestVersionToolTip = null;
+ }
+ }
+ }
+ }
+
+ private string _latestVersionToolTip;
+
+ public string LatestVersionToolTip
+ {
+ get
+ {
+ return _latestVersionToolTip;
+ }
+ set
+ {
+ _latestVersionToolTip = value;
+ OnPropertyChanged(nameof(LatestVersionToolTip));
+ }
+ }
+
+ private bool _selected;
+
+ public bool Selected
+ {
+ get { return _selected; }
+ set
+ {
+ if (_selected != value)
+ {
+ _selected = value;
+ OnPropertyChanged(nameof(Selected));
+ }
+ }
+ }
+
+ private bool VersionEquals(NuGetVersion v1, NuGetVersion v2)
+ {
+ if (v1 == null && v2 == null)
+ {
+ return true;
+ }
+
+ if (v1 == null)
+ {
+ return false;
+ }
+
+ return v1.Equals(v2, VersionComparison.Default);
+ }
+
+ private long? _downloadCount;
+
+ public long? DownloadCount
+ {
+ get
+ {
+ return _downloadCount;
+ }
+ set
+ {
+ _downloadCount = value;
+ OnPropertyChanged(nameof(DownloadCount));
+ }
+ }
+
+ public string Summary { get; set; }
+
+ private PackageStatus _status = PackageStatus.NotInstalled;
+ public PackageStatus Status
+ {
+ get
+ {
+ //TriggerStatusLoader();
+ return _status;
+ }
+
+ private set
+ {
+ bool refresh = _status != value;
+ _status = value;
+
+ if (refresh)
+ {
+ OnPropertyChanged(nameof(Status));
+ }
+ }
+ }
+
+ /*private bool _providersLoaderStarted;
+
+ private AlternativePackageManagerProviders _providers;
+ public AlternativePackageManagerProviders Providers
+ {
+ get
+ {
+ if (!_providersLoaderStarted && ProvidersLoader != null)
+ {
+ _providersLoaderStarted = true;
+ Task.Run(async () =>
+ {
+ var result = await ProvidersLoader.Value;
+
+ await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
+
+ Providers = result;
+ });
+ }
+
+ return _providers;
+ }
+
+ private set
+ {
+ _providers = value;
+ OnPropertyChanged(nameof(Providers));
+ }
+ }
+
+ private Lazy<Task<AlternativePackageManagerProviders>> _providersLoader;
+ internal Lazy<Task<AlternativePackageManagerProviders>> ProvidersLoader
+ {
+ get
+ {
+ return _providersLoader;
+ }
+
+ set
+ {
+ if (_providersLoader != value)
+ {
+ _providersLoaderStarted = false;
+ }
+
+ _providersLoader = value;
+ OnPropertyChanged(nameof(Providers));
+ }
+ }*/
+
+
+ public Uri IconUrl { get; set; }
+
+ public Lazy<Task<IEnumerable<VersionInfo>>> Versions { get; set; }
+
+ public Task<IEnumerable<VersionInfo>> GetVersionsAsync() => Versions.Value;
+
+ /*private Lazy<Task<NuGetVersion>> _backgroundLoader;
+
+ private void TriggerStatusLoader()
+ {
+ if (!_backgroundLoader.IsValueCreated)
+ {
+ Task.Run(async () =>
+ {
+ var result = await _backgroundLoader.Value;
+
+ await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
+
+ LatestVersion = result;
+ Status = GetPackageStatus(LatestVersion, InstalledVersion);
+ });
+ }
+ }
+
+ public void UpdatePackageStatus(IEnumerable<PackageIdentity> installedPackages)
+ {
+ // Get the minimum version installed in any target project/solution
+ InstalledVersion = installedPackages
+ .GetPackageVersions(Id)
+ .MinOrDefault();
+
+ _backgroundLoader = AsyncLazy.New(
+ async () =>
+ {
+ var packageVersions = await GetVersionsAsync();
+ var latestAvailableVersion = packageVersions
+ .Select(p => p.Version)
+ .MaxOrDefault();
+
+ return latestAvailableVersion;
+ });
+
+ OnPropertyChanged(nameof(Status));
+ }
+
+ private static PackageStatus GetPackageStatus(NuGetVersion latestAvailableVersion, NuGetVersion installedVersion)
+ {
+ var status = PackageStatus.NotInstalled;
+ if (installedVersion != null)
+ {
+ status = PackageStatus.Installed;
+ if (VersionComparer.VersionRelease.Compare(installedVersion, latestAvailableVersion) < 0)
+ {
+ status = PackageStatus.UpdateAvailable;
+ }
+ }
+
+ return status;
+ }*/
+
+ protected void OnPropertyChanged(string propertyName)
+ {
+ if (PropertyChanged != null)
+ {
+ var e = new PropertyChangedEventArgs(propertyName);
+ PropertyChanged(this, e);
+ }
+ }
+
+ public override string ToString()
+ {
+ return Id;
+ }
+
+ public string Title { get; set; }
+ public Uri LicenseUrl { get; set; }
+ public Uri ProjectUrl { get; set; }
+ public DateTimeOffset? Published { get; set; }
+ public string Description { get; set; }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageItemLoader.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageItemLoader.cs new file mode 100644 index 0000000000..8aca38e310 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageItemLoader.cs @@ -0,0 +1,299 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.Common;
+using NuGet.Protocol.Core.Types;
+
+namespace NuGet.PackageManagement.UI
+{
+ internal class PackageItemLoader : IItemLoader<PackageItemListViewModel>
+ {
+ private readonly PackageLoadContext _context;
+ private readonly string _searchText;
+ private readonly bool _includePrerelease;
+
+ private readonly IPackageFeed _packageFeed;
+ //private PackageCollection _installedPackages;
+
+ private SearchFilter SearchFilter => new SearchFilter
+ {
+ IncludePrerelease = _includePrerelease,
+ SupportedFrameworks = _context.GetSupportedFrameworks()
+ };
+
+ // Never null
+ private PackageFeedSearchState _state = new PackageFeedSearchState();
+
+ public IItemLoaderState State => _state;
+
+ public bool IsMultiSource => _packageFeed.IsMultiSource;
+
+ private class PackageFeedSearchState : IItemLoaderState
+ {
+ private readonly SearchResult<IPackageSearchMetadata> _results;
+
+ public PackageFeedSearchState()
+ {
+ }
+
+ public PackageFeedSearchState(SearchResult<IPackageSearchMetadata> results)
+ {
+ if (results == null)
+ {
+ throw new ArgumentNullException(nameof(results));
+ }
+ _results = results;
+ }
+
+ public SearchResult<IPackageSearchMetadata> Results => _results;
+
+ public LoadingStatus LoadingStatus
+ {
+ get
+ {
+ if (_results == null)
+ {
+ // initial status when no load called before
+ return LoadingStatus.Unknown;
+ }
+
+ return AggregateLoadingStatus(SourceLoadingStatus?.Values);
+ }
+ }
+
+ // returns the "raw" counter which is not the same as _results.Items.Count
+ // simply because it correlates to un-merged items
+ public int ItemsCount => _results?.RawItemsCount ?? 0;
+
+ public IDictionary<string, LoadingStatus> SourceLoadingStatus => _results?.SourceSearchStatus;
+
+ private static LoadingStatus AggregateLoadingStatus(IEnumerable<LoadingStatus> statuses)
+ {
+ var count = statuses?.Count() ?? 0;
+
+ if (count == 0)
+ {
+ return LoadingStatus.Loading;
+ }
+
+ var first = statuses.First();
+ if (count == 1 || statuses.All(x => x == first))
+ {
+ return first;
+ }
+
+ if (statuses.Contains(LoadingStatus.Loading))
+ {
+ return LoadingStatus.Loading;
+ }
+
+ if (statuses.Contains(LoadingStatus.ErrorOccurred))
+ {
+ return LoadingStatus.ErrorOccurred;
+ }
+
+ if (statuses.Contains(LoadingStatus.Cancelled))
+ {
+ return LoadingStatus.Cancelled;
+ }
+
+ if (statuses.Contains(LoadingStatus.Ready))
+ {
+ return LoadingStatus.Ready;
+ }
+
+ if (statuses.Contains(LoadingStatus.NoMoreItems))
+ {
+ return LoadingStatus.NoMoreItems;
+ }
+
+ if (statuses.Contains(LoadingStatus.NoItemsFound))
+ {
+ return LoadingStatus.NoItemsFound;
+ }
+
+ return first;
+ }
+ }
+
+ public PackageItemLoader(
+ PackageLoadContext context,
+ IPackageFeed packageFeed,
+ string searchText = null,
+ bool includePrerelease = true)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException(nameof(context));
+ }
+ _context = context;
+
+ if (packageFeed == null)
+ {
+ throw new ArgumentNullException(nameof(packageFeed));
+ }
+ _packageFeed = packageFeed;
+
+ _searchText = searchText ?? string.Empty;
+ _includePrerelease = includePrerelease;
+ }
+
+ public async Task<int> GetTotalCountAsync(int maxCount, CancellationToken cancellationToken)
+ {
+ // Go off the UI thread to perform non-UI operations
+ //await TaskScheduler.Default;
+
+ int totalCount = 0;
+ ContinuationToken nextToken = null;
+ do
+ {
+ var searchResult = await SearchAsync(nextToken, cancellationToken);
+ while (searchResult.RefreshToken != null)
+ {
+ searchResult = await _packageFeed.RefreshSearchAsync(searchResult.RefreshToken, cancellationToken);
+ }
+ totalCount += searchResult.Items?.Count() ?? 0;
+ nextToken = searchResult.NextToken;
+ } while (nextToken != null && totalCount <= maxCount);
+
+ return totalCount;
+ }
+
+ public async Task<IReadOnlyList<IPackageSearchMetadata>> GetAllPackagesAsync(CancellationToken cancellationToken)
+ {
+ // Go off the UI thread to perform non-UI operations
+ //await TaskScheduler.Default;
+
+ var packages = new List<IPackageSearchMetadata>();
+ ContinuationToken nextToken = null;
+ do
+ {
+ var searchResult = await SearchAsync(nextToken, cancellationToken);
+ while (searchResult.RefreshToken != null)
+ {
+ searchResult = await _packageFeed.RefreshSearchAsync(searchResult.RefreshToken, cancellationToken);
+ }
+
+ nextToken = searchResult.NextToken;
+
+ packages.AddRange(searchResult.Items);
+
+ } while (nextToken != null);
+
+ return packages;
+ }
+
+ public async Task LoadNextAsync(IProgress<IItemLoaderState> progress, CancellationToken cancellationToken)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadBegin);
+
+ var nextToken = _state.Results?.NextToken;
+ var cleanState = SearchResult.Empty<IPackageSearchMetadata>();
+ cleanState.NextToken = nextToken;
+ await UpdateStateAndReportAsync(cleanState, progress);
+
+ var searchResult = await SearchAsync(nextToken, cancellationToken);
+
+ cancellationToken.ThrowIfCancellationRequested();
+
+ await UpdateStateAndReportAsync(searchResult, progress);
+
+ NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadEnd);
+ }
+
+ public async Task UpdateStateAsync(IProgress<IItemLoaderState> progress, CancellationToken cancellationToken)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+
+ NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadBegin);
+
+ progress?.Report(_state);
+
+ var refreshToken = _state.Results?.RefreshToken;
+ if (refreshToken != null)
+ {
+ var searchResult = await _packageFeed.RefreshSearchAsync(refreshToken, cancellationToken);
+
+ cancellationToken.ThrowIfCancellationRequested();
+
+ await UpdateStateAndReportAsync(searchResult, progress);
+ }
+
+ NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadEnd);
+ }
+
+ private async Task<SearchResult<IPackageSearchMetadata>> SearchAsync(ContinuationToken continuationToken, CancellationToken cancellationToken)
+ {
+ if (continuationToken != null)
+ {
+ return await _packageFeed.ContinueSearchAsync(continuationToken, cancellationToken);
+ }
+
+ return await _packageFeed.SearchAsync(_searchText, SearchFilter, cancellationToken);
+ }
+
+ private async Task UpdateStateAndReportAsync(SearchResult<IPackageSearchMetadata> searchResult, IProgress<IItemLoaderState> progress)
+ {
+ // cache installed packages here for future use
+ //_installedPackages = await _context.GetInstalledPackagesAsync();
+
+ var state = new PackageFeedSearchState(searchResult);
+ _state = state;
+ progress?.Report(state);
+ }
+
+ public void Reset()
+ {
+ _state = new PackageFeedSearchState();
+ }
+
+ public IEnumerable<PackageItemListViewModel> GetCurrent()
+ {
+ if (_state.ItemsCount == 0)
+ {
+ return Enumerable.Empty<PackageItemListViewModel>();
+ }
+
+ var listItems = _state.Results
+ .Select(metadata =>
+ {
+ var listItem = new PackageItemListViewModel
+ {
+ Id = metadata.Identity.Id,
+ Version = metadata.Identity.Version,
+ IconUrl = metadata.IconUrl,
+ Author = metadata.Authors,
+ DownloadCount = metadata.DownloadCount,
+ Summary = metadata.Summary,
+ Description = metadata.Description,
+ Title = metadata.Title,
+ LicenseUrl = metadata.LicenseUrl,
+ ProjectUrl = metadata.ProjectUrl,
+ Published = metadata.Published,
+ Versions = AsyncLazy.New(() => metadata.GetVersionsAsync())
+ };
+ /*listItem.UpdatePackageStatus(_installedPackages);
+
+ if (!_context.IsSolution && _context.PackageManagerProviders.Any())
+ {
+ listItem.ProvidersLoader = AsyncLazy.New(
+ () => AlternativePackageManagerProviders.CalculateAlternativePackageManagersAsync(
+ _context.PackageManagerProviders,
+ listItem.Id,
+ _context.Projects[0]));
+ }*/
+
+ return listItem;
+ });
+
+ return listItems.ToArray();
+ }
+ }
+}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageLoadContext.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageLoadContext.cs new file mode 100644 index 0000000000..e69db3cefb --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageLoadContext.cs @@ -0,0 +1,97 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.Frameworks;
+using NuGet.ProjectManagement;
+using NuGet.Protocol.Core.Types;
+
+namespace NuGet.PackageManagement.UI
+{
+ internal class PackageLoadContext
+ {
+ //private readonly Task<PackageCollection> _installedPackagesTask;
+
+ public IEnumerable<SourceRepository> SourceRepositories { get; private set; }
+
+ public NuGetPackageManager PackageManager { get; private set; }
+
+ public NuGetProject[] Projects { get; private set; }
+
+ // Indicates whether the loader is created by solution package manager.
+ public bool IsSolution { get; private set; }
+
+ //public IEnumerable<IVsPackageManagerProvider> PackageManagerProviders { get; private set; }
+
+ //public PackageSearchMetadataCache CachedPackages { get; set; }
+
+ public PackageLoadContext(
+ IEnumerable<SourceRepository> sourceRepositories,
+ bool isSolution,
+ NuGetProject project)
+ {
+ SourceRepositories = sourceRepositories;
+ IsSolution = isSolution;
+ //PackageManager = uiContext.PackageManager;
+ Projects = new [] { project };
+ //PackageManagerProviders = uiContext.PackageManagerProviders;
+
+ //_installedPackagesTask = PackageCollection.FromProjectsAsync(Projects, CancellationToken.None);
+ }
+
+ //public Task<PackageCollection> GetInstalledPackagesAsync() =>_installedPackagesTask;
+
+ // Returns the list of frameworks that we need to pass to the server during search
+ public IEnumerable<string> GetSupportedFrameworks()
+ {
+ var frameworks = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
+
+ foreach (var project in Projects)
+ {
+ NuGetFramework framework;
+ if (project.TryGetMetadata(NuGetProjectMetadataKeys.TargetFramework,
+ out framework))
+ {
+ if (framework != null
+ && framework.IsAny)
+ {
+ // One of the project's target framework is AnyFramework. In this case,
+ // we don't need to pass the framework filter to the server.
+ return Enumerable.Empty<string>();
+ }
+
+ if (framework != null
+ && framework.IsSpecificFramework)
+ {
+ frameworks.Add(framework.DotNetFrameworkName);
+ }
+ }
+ else
+ {
+ // we also need to process SupportedFrameworks
+ IEnumerable<NuGetFramework> supportedFrameworks;
+ if (project.TryGetMetadata(
+ NuGetProjectMetadataKeys.SupportedFrameworks,
+ out supportedFrameworks))
+ {
+ foreach (var f in supportedFrameworks)
+ {
+ if (f.IsAny)
+ {
+ return Enumerable.Empty<string>();
+ }
+
+ frameworks.Add(f.DotNetFrameworkName);
+ }
+ }
+ }
+ }
+
+ return frameworks;
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageStatus.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageStatus.cs new file mode 100644 index 0000000000..a06b92b1e4 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/PackageStatus.cs @@ -0,0 +1,16 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+namespace NuGet.PackageManagement.UI
+{
+ internal enum PackageStatus
+ {
+ NotInstalled,
+
+ // the latest applicable version is installed.
+ Installed,
+
+ UpdateAvailable
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/SearchResult.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/SearchResult.cs new file mode 100644 index 0000000000..900a7c3a21 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/SearchResult.cs @@ -0,0 +1,71 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Feed specific data describing current position to continue search from.
+ /// It's opaque to external consumer.
+ /// </summary>
+ internal class ContinuationToken { }
+
+ /// <summary>
+ /// Feed specific state of current search operation to retrieve search results.
+ /// Used for polling results of prolonged search. Opaque to external consumer.
+ /// </summary>
+ internal class RefreshToken
+ {
+ public TimeSpan RetryAfter { get; set; }
+ }
+
+ /// <summary>
+ /// Generic search result as returned by a feed including actual items and current search
+ /// state including but not limited to continuation token and refresh token.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ internal class SearchResult<T> : IEnumerable<T>
+ {
+ public IReadOnlyList<T> Items { get; set; }
+
+ public ContinuationToken NextToken { get; set; }
+
+ public RefreshToken RefreshToken { get; set; }
+
+ public IEnumerator<T> GetEnumerator() => Items.GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => Items.GetEnumerator();
+
+ public IDictionary<string, LoadingStatus> SourceSearchStatus { get; set; }
+
+ // total number of unmerged items found
+ public int RawItemsCount { get; set; }
+ }
+
+ /// <summary>
+ /// Helper class providing shortcuts to create new result instance
+ /// </summary>
+ internal static class SearchResult
+ {
+ public static SearchResult<T> FromItems<T>(params T[] items) => new SearchResult<T>
+ {
+ Items = items,
+ RawItemsCount = items.Length
+ };
+
+ public static SearchResult<T> FromItems<T>(IReadOnlyList<T> items) => new SearchResult<T>
+ {
+ Items = items,
+ RawItemsCount = items.Count
+ };
+
+ public static SearchResult<T> Empty<T>() => new SearchResult<T>
+ {
+ Items = new T[] { },
+ SourceSearchStatus = new Dictionary<string, LoadingStatus> { }
+ };
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/SourceRepositoryExtensions.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/SourceRepositoryExtensions.cs new file mode 100644 index 0000000000..883ba76887 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/SourceRepositoryExtensions.cs @@ -0,0 +1,215 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using NuGet.Packaging.Core;
+using NuGet.Protocol.Core.Types;
+using NuGet.Versioning;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Helper class encapsulating common scenarios of source repository operations.
+ /// </summary>
+ internal static class SourceRepositoryExtensions
+ {
+ public static Task<SearchResult<IPackageSearchMetadata>> SearchAsync(this SourceRepository sourceRepository, string searchText, SearchFilter searchFilter, int pageSize, CancellationToken cancellationToken)
+ {
+ var searchToken = new FeedSearchContinuationToken
+ {
+ SearchString = searchText,
+ SearchFilter = searchFilter,
+ StartIndex = 0
+ };
+
+ return sourceRepository.SearchAsync(searchToken, pageSize, cancellationToken);
+ }
+
+ public static async Task<SearchResult<IPackageSearchMetadata>> SearchAsync(
+ this SourceRepository sourceRepository, ContinuationToken continuationToken, int pageSize, CancellationToken cancellationToken)
+ {
+ var searchToken = continuationToken as FeedSearchContinuationToken;
+ if (searchToken == null)
+ {
+ throw new InvalidOperationException("Invalid token");
+ }
+
+ var searchResource = await sourceRepository.GetResourceAsync<PackageSearchResource>(cancellationToken);
+
+ IEnumerable<IPackageSearchMetadata> searchResults = null;
+ if (searchResource != null) {
+ searchResults = await searchResource.SearchAsync(
+ searchToken.SearchString,
+ searchToken.SearchFilter,
+ searchToken.StartIndex,
+ pageSize + 1,
+ Logging.NullLogger.Instance,
+ cancellationToken);
+ }
+
+ var items = searchResults?.ToArray() ?? new IPackageSearchMetadata[] { };
+
+ var hasMoreItems = items.Length > pageSize;
+ if (hasMoreItems)
+ {
+ items = items.Take(items.Length - 1).ToArray();
+ }
+
+ var result = SearchResult.FromItems(items);
+
+ var loadingStatus = hasMoreItems
+ ? LoadingStatus.Ready
+ : items.Length == 0
+ ? LoadingStatus.NoItemsFound
+ : LoadingStatus.NoMoreItems;
+ result.SourceSearchStatus = new Dictionary<string, LoadingStatus>
+ {
+ { sourceRepository.PackageSource.Name, loadingStatus }
+ };
+
+ if (hasMoreItems)
+ {
+ result.NextToken = new FeedSearchContinuationToken
+ {
+ SearchString = searchToken.SearchString,
+ SearchFilter = searchToken.SearchFilter,
+ StartIndex = searchToken.StartIndex + items.Length
+ };
+ }
+
+ return result;
+ }
+
+ public static async Task<IPackageSearchMetadata> GetPackageMetadataAsync(
+ this SourceRepository sourceRepository, PackageIdentity identity, bool includePrerelease, CancellationToken cancellationToken)
+ {
+ var metadataResource = await sourceRepository.GetResourceAsync<PackageMetadataResource>(cancellationToken);
+ IEnumerable<IPackageSearchMetadata> packages = null;
+ if (metadataResource != null) {
+ packages = await metadataResource.GetMetadataAsync(
+ identity.Id,
+ includePrerelease: true,
+ includeUnlisted: false,
+ log: Logging.NullLogger.Instance,
+ token: cancellationToken);
+ }
+
+ if (packages?.FirstOrDefault() == null)
+ {
+ return null;
+ }
+
+ var packageMetadata = packages
+ .FirstOrDefault(p => p.Identity.Version == identity.Version)
+ ?? PackageSearchMetadataBuilder.FromIdentity(identity).Build();
+
+ return packageMetadata.WithVersions(ToVersionInfo(packages, includePrerelease));
+ }
+
+ public static async Task<IPackageSearchMetadata> GetPackageMetadataFromLocalSourceAsync(
+ this SourceRepository localRepository, PackageIdentity identity, CancellationToken cancellationToken)
+ {
+ var localResource = await localRepository.GetResourceAsync<PackageMetadataResource>(cancellationToken);
+ IEnumerable<IPackageSearchMetadata> localPackages = null;
+ if (localResource != null) {
+ localPackages = await localResource.GetMetadataAsync(
+ identity.Id,
+ includePrerelease: true,
+ includeUnlisted: true,
+ log: Logging.NullLogger.Instance,
+ token: cancellationToken);
+ }
+
+ var packageMetadata = localPackages?.FirstOrDefault(p => p.Identity.Version == identity.Version);
+
+ var versions = new[]
+ {
+ new VersionInfo(identity.Version)
+ };
+
+ return packageMetadata?.WithVersions(versions);
+ }
+
+ public static async Task<IPackageSearchMetadata> GetLatestPackageMetadataAsync(
+ this SourceRepository sourceRepository, string packageId, bool includePrerelease, CancellationToken cancellationToken)
+ {
+ var metadataResource = await sourceRepository.GetResourceAsync<PackageMetadataResource>(cancellationToken);
+ IEnumerable<IPackageSearchMetadata> packages = null;
+ if (metadataResource != null) {
+ packages = await metadataResource.GetMetadataAsync(
+ packageId,
+ includePrerelease,
+ false,
+ Logging.NullLogger.Instance,
+ cancellationToken);
+ }
+
+ var highest = packages?
+ .OrderByDescending(e => e.Identity.Version, VersionComparer.VersionRelease)
+ .FirstOrDefault();
+
+ return highest?.WithVersions(ToVersionInfo(packages, includePrerelease));
+ }
+
+ public static async Task<IEnumerable<IPackageSearchMetadata>> GetPackageMetadataListAsync(
+ this SourceRepository sourceRepository, string packageId, bool includePrerelease, bool includeUnlisted, CancellationToken cancellationToken)
+ {
+ var metadataResource = await sourceRepository.GetResourceAsync<PackageMetadataResource>(cancellationToken);
+ IEnumerable<IPackageSearchMetadata> packages = null;
+ if (metadataResource != null) {
+ packages = await metadataResource.GetMetadataAsync(
+ packageId,
+ includePrerelease,
+ includeUnlisted,
+ Logging.NullLogger.Instance,
+ cancellationToken);
+ }
+ return packages;
+ }
+
+ private static IEnumerable<VersionInfo> ToVersionInfo(IEnumerable<IPackageSearchMetadata> packages, bool includePrerelease)
+ {
+ return packages?
+ .Where(v => includePrerelease || !v.Identity.Version.IsPrerelease)
+ .OrderByDescending(m => m.Identity.Version, VersionComparer.VersionRelease)
+ .Select(m => new VersionInfo(m.Identity.Version, m.DownloadCount));
+ }
+
+ public static async Task<IEnumerable<string>> IdStartsWithAsync(
+ this SourceRepository sourceRepository, string packageIdPrefix, bool includePrerelease, CancellationToken cancellationToken)
+ {
+ var autoCompleteResource = await sourceRepository.GetResourceAsync<AutoCompleteResource>(cancellationToken);
+ IEnumerable<string> packageIds = null;
+ if (autoCompleteResource != null) {
+ packageIds = await autoCompleteResource.IdStartsWith(
+ packageIdPrefix,
+ includePrerelease: includePrerelease,
+ log: Logging.NullLogger.Instance,
+ token: cancellationToken);
+ }
+
+ return packageIds ?? Enumerable.Empty<string>();
+ }
+
+ public static async Task<IEnumerable<NuGetVersion>> VersionStartsWithAsync(
+ this SourceRepository sourceRepository, string packageId, string versionPrefix, bool includePrerelease, CancellationToken cancellationToken)
+ {
+ var autoCompleteResource = await sourceRepository.GetResourceAsync<AutoCompleteResource>(cancellationToken);
+ IEnumerable<NuGetVersion> versions = null;
+ if (autoCompleteResource != null) {
+ versions = await autoCompleteResource.VersionStartsWith(
+ packageId,
+ versionPrefix,
+ includePrerelease: includePrerelease,
+ log: Logging.NullLogger.Instance,
+ token: cancellationToken);
+ }
+
+ return versions ?? Enumerable.Empty<NuGetVersion>();
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/TaskCombinators.cs b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/TaskCombinators.cs new file mode 100644 index 0000000000..833accd8d8 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/NuGet.PackageManagement.UI/TaskCombinators.cs @@ -0,0 +1,72 @@ +// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace NuGet.PackageManagement.UI
+{
+ /// <summary>
+ /// Contains task execution strategies, such as parallel throttled execution.
+ /// </summary>
+ internal static class TaskCombinators
+ {
+ public const int MaxDegreeOfParallelism = 16;
+
+ public static async Task<IEnumerable<TValue>> ThrottledAsync<TSource, TValue>(
+ IEnumerable<TSource> sources,
+ Func<TSource, CancellationToken, Task<TValue>> valueSelector,
+ CancellationToken cancellationToken)
+ {
+ var bag = new ConcurrentBag<TSource>(sources);
+ var values = new ConcurrentQueue<TValue>();
+
+ Func<Task> taskBody = async () =>
+ {
+ TSource source;
+ while (bag.TryTake(out source))
+ {
+ var value = await valueSelector(source, cancellationToken);
+ values.Enqueue(value);
+ }
+ };
+
+ var tasks = Enumerable
+ .Repeat(0, MaxDegreeOfParallelism)
+ .Select(_ => Task.Run(taskBody));
+
+ await Task.WhenAll(tasks);
+
+ return values;
+ }
+
+ public static IDictionary<string, Task<TValue>> ObserveErrorsAsync<TSource, TValue>(
+ IEnumerable<TSource> sources,
+ Func<TSource, string> keySelector,
+ Func<TSource, CancellationToken, Task<TValue>> valueSelector,
+ Action<Task, object> observeErrorAction,
+ CancellationToken cancellationToken)
+ {
+ var tasks = sources
+ .ToDictionary(
+ s => keySelector(s),
+ s =>
+ {
+ var valueTask = valueSelector(s, cancellationToken);
+ var ignored = valueTask.ContinueWith(
+ observeErrorAction,
+ s,
+ cancellationToken,
+ TaskContinuationOptions.OnlyOnFaulted,
+ TaskScheduler.Current);
+ return valueTask;
+ });
+
+ return tasks;
+ }
+ }
+}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.HyperlinkWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.HyperlinkWidget.cs deleted file mode 100644 index c5680531eb..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.HyperlinkWidget.cs +++ /dev/null @@ -1,19 +0,0 @@ -
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.PackageManagement
-{
- internal partial class HyperlinkWidget
- {
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.PackageManagement.HyperlinkWidget
- global::Stetic.BinContainer.Attach (this);
- this.Name = "MonoDevelop.PackageManagement.HyperlinkWidget";
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.Hide ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.ManagePackagesDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.ManagePackagesDialog.cs deleted file mode 100644 index 828e0600a0..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.ManagePackagesDialog.cs +++ /dev/null @@ -1,135 +0,0 @@ -
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.PackageManagement
-{
- internal partial class ManagePackagesDialog
- {
- private global::Gtk.Notebook notebook;
- private global::MonoDevelop.PackageManagement.PackagesWidget availablePackagesWidget;
- private global::Gtk.Label availablePackagesLabel;
- private global::MonoDevelop.PackageManagement.PackagesWidget installedPackagesWidget;
- private global::Gtk.Label installedPackagesLabel;
- private global::MonoDevelop.PackageManagement.PackagesWidget UpdatedPackagesWidget;
- private global::Gtk.Label updatedPackagesLabel;
- private global::MonoDevelop.PackageManagement.PackagesWidget recentPackagesWidget;
- private global::Gtk.Label recentPackagesLabel;
- private global::Gtk.Expander messagesExpander;
- private global::Gtk.ScrolledWindow GtkScrolledWindow8;
- private global::Gtk.TextView messagesTextView;
- private global::Gtk.Label messagesExpanderLabel;
- private global::Gtk.Button buttonClose;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.PackageManagement.ManagePackagesDialog
- this.Name = "MonoDevelop.PackageManagement.ManagePackagesDialog";
- this.Title = global::Mono.Unix.Catalog.GetString ("Manage Packages");
- this.WindowPosition = ((global::Gtk.WindowPosition)(1));
- this.DefaultWidth = 640;
- this.DefaultHeight = 480;
- // Internal child MonoDevelop.PackageManagement.ManagePackagesDialog.VBox
- global::Gtk.VBox w1 = this.VBox;
- w1.Name = "mainVBox";
- w1.BorderWidth = ((uint)(2));
- // Container child mainVBox.Gtk.Box+BoxChild
- this.notebook = new global::Gtk.Notebook ();
- this.notebook.CanFocus = true;
- this.notebook.Name = "notebook";
- this.notebook.CurrentPage = 0;
- // Container child notebook.Gtk.Notebook+NotebookChild
- this.availablePackagesWidget = null;
- this.notebook.Add (this.availablePackagesWidget);
- // Notebook tab
- this.availablePackagesLabel = new global::Gtk.Label ();
- this.availablePackagesLabel.Name = "availablePackagesLabel";
- this.availablePackagesLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("Available");
- this.notebook.SetTabLabel (this.availablePackagesWidget, this.availablePackagesLabel);
- this.availablePackagesLabel.ShowAll ();
- // Container child notebook.Gtk.Notebook+NotebookChild
- this.installedPackagesWidget = null;
- this.notebook.Add (this.installedPackagesWidget);
- global::Gtk.Notebook.NotebookChild w3 = ((global::Gtk.Notebook.NotebookChild)(this.notebook [this.installedPackagesWidget]));
- w3.Position = 1;
- // Notebook tab
- this.installedPackagesLabel = new global::Gtk.Label ();
- this.installedPackagesLabel.Name = "installedPackagesLabel";
- this.installedPackagesLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("Installed");
- this.notebook.SetTabLabel (this.installedPackagesWidget, this.installedPackagesLabel);
- this.installedPackagesLabel.ShowAll ();
- // Container child notebook.Gtk.Notebook+NotebookChild
- this.UpdatedPackagesWidget = null;
- this.notebook.Add (this.UpdatedPackagesWidget);
- global::Gtk.Notebook.NotebookChild w4 = ((global::Gtk.Notebook.NotebookChild)(this.notebook [this.UpdatedPackagesWidget]));
- w4.Position = 2;
- // Notebook tab
- this.updatedPackagesLabel = new global::Gtk.Label ();
- this.updatedPackagesLabel.Name = "updatedPackagesLabel";
- this.updatedPackagesLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("Updated");
- this.notebook.SetTabLabel (this.UpdatedPackagesWidget, this.updatedPackagesLabel);
- this.updatedPackagesLabel.ShowAll ();
- // Container child notebook.Gtk.Notebook+NotebookChild
- this.recentPackagesWidget = null;
- this.notebook.Add (this.recentPackagesWidget);
- global::Gtk.Notebook.NotebookChild w5 = ((global::Gtk.Notebook.NotebookChild)(this.notebook [this.recentPackagesWidget]));
- w5.Position = 3;
- // Notebook tab
- this.recentPackagesLabel = new global::Gtk.Label ();
- this.recentPackagesLabel.Name = "recentPackagesLabel";
- this.recentPackagesLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("Recent");
- this.notebook.SetTabLabel (this.recentPackagesWidget, this.recentPackagesLabel);
- this.recentPackagesLabel.ShowAll ();
- w1.Add (this.notebook);
- global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(w1 [this.notebook]));
- w6.Position = 0;
- // Container child mainVBox.Gtk.Box+BoxChild
- this.messagesExpander = new global::Gtk.Expander (null);
- this.messagesExpander.CanFocus = true;
- this.messagesExpander.Name = "messagesExpander";
- // Container child messagesExpander.Gtk.Container+ContainerChild
- this.GtkScrolledWindow8 = new global::Gtk.ScrolledWindow ();
- this.GtkScrolledWindow8.Name = "GtkScrolledWindow8";
- this.GtkScrolledWindow8.ShadowType = ((global::Gtk.ShadowType)(1));
- // Container child GtkScrolledWindow8.Gtk.Container+ContainerChild
- this.messagesTextView = new global::Gtk.TextView ();
- this.messagesTextView.CanFocus = true;
- this.messagesTextView.Name = "messagesTextView";
- this.messagesTextView.Editable = false;
- this.messagesTextView.CursorVisible = false;
- this.GtkScrolledWindow8.Add (this.messagesTextView);
- this.messagesExpander.Add (this.GtkScrolledWindow8);
- this.messagesExpanderLabel = new global::Gtk.Label ();
- this.messagesExpanderLabel.Name = "messagesExpanderLabel";
- this.messagesExpanderLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("Messages");
- this.messagesExpanderLabel.UseUnderline = true;
- this.messagesExpander.LabelWidget = this.messagesExpanderLabel;
- w1.Add (this.messagesExpander);
- global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1 [this.messagesExpander]));
- w9.Position = 1;
- w9.Expand = false;
- // Internal child MonoDevelop.PackageManagement.ManagePackagesDialog.ActionArea
- global::Gtk.HButtonBox w10 = this.ActionArea;
- w10.Name = "buttonArea";
- w10.Spacing = 10;
- w10.BorderWidth = ((uint)(5));
- w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
- // Container child buttonArea.Gtk.ButtonBox+ButtonBoxChild
- this.buttonClose = new global::Gtk.Button ();
- this.buttonClose.CanDefault = true;
- this.buttonClose.CanFocus = true;
- this.buttonClose.Name = "buttonClose";
- this.buttonClose.UseStock = true;
- this.buttonClose.UseUnderline = true;
- this.buttonClose.Label = "gtk-close";
- this.AddActionWidget (this.buttonClose, -7);
- global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonClose]));
- w11.Expand = false;
- w11.Fill = false;
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.Show ();
- this.messagesExpander.Activated += new global::System.EventHandler (this.MessagesExpanderActivated);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PackageLicenseWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PackageLicenseWidget.cs deleted file mode 100644 index eff892805d..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PackageLicenseWidget.cs +++ /dev/null @@ -1,90 +0,0 @@ -
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.PackageManagement
-{
- internal partial class PackageLicenseWidget
- {
- private global::Gtk.HBox mainHBox;
- private global::Gtk.VBox packageIdVBox;
- private global::Gtk.HBox packageIdHBox;
- private global::Gtk.Label packageIdLabel;
- private global::MonoDevelop.PackageManagement.HyperlinkWidget licenseHyperlinkWidget;
- private global::Gtk.Label fillerLabel;
- private global::Gtk.ScrolledWindow GtkScrolledWindow;
- private global::Gtk.TextView packageSummaryTextView;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.PackageManagement.PackageLicenseWidget
- global::Stetic.BinContainer.Attach (this);
- this.Name = "MonoDevelop.PackageManagement.PackageLicenseWidget";
- // Container child MonoDevelop.PackageManagement.PackageLicenseWidget.Gtk.Container+ContainerChild
- this.mainHBox = new global::Gtk.HBox ();
- this.mainHBox.Name = "mainHBox";
- this.mainHBox.Spacing = 6;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.packageIdVBox = new global::Gtk.VBox ();
- this.packageIdVBox.Name = "packageIdVBox";
- this.packageIdVBox.Spacing = 6;
- // Container child packageIdVBox.Gtk.Box+BoxChild
- this.packageIdHBox = new global::Gtk.HBox ();
- this.packageIdHBox.Name = "packageIdHBox";
- this.packageIdHBox.Spacing = 6;
- // Container child packageIdHBox.Gtk.Box+BoxChild
- this.packageIdLabel = new global::Gtk.Label ();
- this.packageIdLabel.Name = "packageIdLabel";
- this.packageIdLabel.UseMarkup = true;
- this.packageIdHBox.Add (this.packageIdLabel);
- global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.packageIdHBox [this.packageIdLabel]));
- w1.Position = 0;
- w1.Expand = false;
- w1.Fill = false;
- this.packageIdVBox.Add (this.packageIdHBox);
- global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.packageIdVBox [this.packageIdHBox]));
- w2.Position = 0;
- w2.Expand = false;
- w2.Fill = false;
- // Container child packageIdVBox.Gtk.Box+BoxChild
- this.licenseHyperlinkWidget = new global::MonoDevelop.PackageManagement.HyperlinkWidget ();
- this.licenseHyperlinkWidget.Events = ((global::Gdk.EventMask)(256));
- this.licenseHyperlinkWidget.Name = "licenseHyperlinkWidget";
- this.licenseHyperlinkWidget.Label = global::Mono.Unix.Catalog.GetString ("View License");
- this.packageIdVBox.Add (this.licenseHyperlinkWidget);
- global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.packageIdVBox [this.licenseHyperlinkWidget]));
- w3.Position = 1;
- w3.Expand = false;
- // Container child packageIdVBox.Gtk.Box+BoxChild
- this.fillerLabel = new global::Gtk.Label ();
- this.fillerLabel.Name = "fillerLabel";
- this.packageIdVBox.Add (this.fillerLabel);
- global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.packageIdVBox [this.fillerLabel]));
- w4.Position = 2;
- this.mainHBox.Add (this.packageIdVBox);
- global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.packageIdVBox]));
- w5.Position = 0;
- w5.Expand = false;
- w5.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
- this.GtkScrolledWindow.Name = "GtkScrolledWindow";
- this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
- // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
- this.packageSummaryTextView = new global::Gtk.TextView ();
- this.packageSummaryTextView.CanFocus = true;
- this.packageSummaryTextView.Name = "packageSummaryTextView";
- this.packageSummaryTextView.Editable = false;
- this.packageSummaryTextView.CursorVisible = false;
- this.packageSummaryTextView.WrapMode = ((global::Gtk.WrapMode)(2));
- this.GtkScrolledWindow.Add (this.packageSummaryTextView);
- this.mainHBox.Add (this.GtkScrolledWindow);
- global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.GtkScrolledWindow]));
- w7.Position = 1;
- this.Add (this.mainHBox);
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.Hide ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PackagesWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PackagesWidget.cs deleted file mode 100644 index 4401840b74..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PackagesWidget.cs +++ /dev/null @@ -1,570 +0,0 @@ -
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.PackageManagement
-{
- internal partial class PackagesWidget
- {
- private global::Gtk.HPaned mainPane;
-
- private global::Gtk.VBox packagesListVBox;
-
- private global::Gtk.ScrolledWindow packagesTreeScrolledWindow;
-
- private global::Gtk.TreeView packagesTreeView;
-
- private global::Gtk.HBox pagedResultsHBox;
-
- private global::Gtk.Label pagedResultsLeftLabel;
-
- private global::MonoDevelop.PackageManagement.PagedResultsWidget pagedResultsWidget;
-
- private global::Gtk.Label pagedResultsRightLabel;
-
- private global::Gtk.VBox packageInfoVBox;
-
- private global::Gtk.ComboBox packageSourceComboBox;
-
- private global::Gtk.HBox packageSearchHBox;
-
- private global::Gtk.Entry packageSearchEntry;
-
- private global::Gtk.Button packageSearchButton;
-
- private global::MonoDevelop.Components.ImageView imageSearch;
-
- private global::Gtk.CheckButton includePrereleaseCheckButton;
-
- private global::Gtk.HButtonBox updateAllPackagesButtonBox;
-
- private global::Gtk.Button updateAllPackagesButton;
-
- private global::Gtk.Frame packageInfoFrame;
-
- private global::Gtk.Alignment packageInfoFrameAlignment;
-
- private global::Gtk.ScrolledWindow GtkScrolledWindow;
-
- private global::Gtk.VBox packageInfoFrameVBox;
-
- private global::Gtk.HBox packageCreatedByHBox;
-
- private global::Gtk.Label packageCreatedByLabel;
-
- private global::Gtk.Label packageCreatedByTextBox;
-
- private global::Gtk.HBox packageIdHBox;
-
- private global::Gtk.Label packageIdLabel;
-
- private global::MonoDevelop.PackageManagement.HyperlinkWidget packageIdButton;
-
- private global::Gtk.Label packageIdTextBox;
-
- private global::Gtk.HBox packageVersionHBox;
-
- private global::Gtk.Label packageVersionLabel;
-
- private global::Gtk.Label packageVersionTextBox;
-
- private global::Gtk.HBox packageLastUpdatedHBox;
-
- private global::Gtk.Label packageLastUpdatedLabel;
-
- private global::Gtk.Label packageLastUpdatedTextBox;
-
- private global::Gtk.HBox packageDownloadsHBox;
-
- private global::Gtk.Label packageDownloadsLabel;
-
- private global::Gtk.Label packageDownloadsTextBox;
-
- private global::Gtk.HBox viewLicenseTermsHBox;
-
- private global::MonoDevelop.PackageManagement.HyperlinkWidget viewLicenseTermsButton;
-
- private global::Gtk.HBox moreInformationHBox;
-
- private global::MonoDevelop.PackageManagement.HyperlinkWidget moreInformationButton;
-
- private global::Gtk.TextView packageDescriptionTextView;
-
- private global::Gtk.HBox packageDependenciesHBox;
-
- private global::Gtk.Label packageDependenciesLabel;
-
- private global::Gtk.Label packageDependenciesNoneLabel;
-
- private global::Gtk.HBox packageDependenciesListHBox;
-
- private global::Gtk.Label packageDependenciesListLabel;
-
- private global::Gtk.Label packageDependenciesListFillerLabel;
-
- private global::Gtk.HButtonBox managePackageButtonBox;
-
- private global::Gtk.Button addPackageButton;
-
- private global::Gtk.Button removePackageButton;
-
- private global::Gtk.Button managePackageButton;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.PackageManagement.PackagesWidget
- global::Stetic.BinContainer.Attach (this);
- this.Name = "MonoDevelop.PackageManagement.PackagesWidget";
- // Container child MonoDevelop.PackageManagement.PackagesWidget.Gtk.Container+ContainerChild
- this.mainPane = new global::Gtk.HPaned ();
- this.mainPane.CanFocus = true;
- this.mainPane.Name = "mainPane";
- this.mainPane.Position = 322;
- // Container child mainPane.Gtk.Paned+PanedChild
- this.packagesListVBox = new global::Gtk.VBox ();
- this.packagesListVBox.Name = "packagesListVBox";
- this.packagesListVBox.Spacing = 6;
- // Container child packagesListVBox.Gtk.Box+BoxChild
- this.packagesTreeScrolledWindow = new global::Gtk.ScrolledWindow ();
- this.packagesTreeScrolledWindow.Name = "packagesTreeScrolledWindow";
- this.packagesTreeScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
- // Container child packagesTreeScrolledWindow.Gtk.Container+ContainerChild
- this.packagesTreeView = new global::Gtk.TreeView ();
- this.packagesTreeView.CanFocus = true;
- this.packagesTreeView.Name = "packagesTreeView";
- this.packagesTreeView.EnableSearch = false;
- this.packagesTreeView.HeadersVisible = false;
- this.packagesTreeScrolledWindow.Add (this.packagesTreeView);
- this.packagesListVBox.Add (this.packagesTreeScrolledWindow);
- global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.packagesListVBox [this.packagesTreeScrolledWindow]));
- w2.Position = 0;
- // Container child packagesListVBox.Gtk.Box+BoxChild
- this.pagedResultsHBox = new global::Gtk.HBox ();
- this.pagedResultsHBox.Name = "pagedResultsHBox";
- this.pagedResultsHBox.Spacing = 6;
- // Container child pagedResultsHBox.Gtk.Box+BoxChild
- this.pagedResultsLeftLabel = new global::Gtk.Label ();
- this.pagedResultsLeftLabel.Name = "pagedResultsLeftLabel";
- this.pagedResultsHBox.Add (this.pagedResultsLeftLabel);
- global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.pagedResultsHBox [this.pagedResultsLeftLabel]));
- w3.Position = 0;
- // Container child pagedResultsHBox.Gtk.Box+BoxChild
- this.pagedResultsWidget = null;
- this.pagedResultsHBox.Add (this.pagedResultsWidget);
- global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.pagedResultsHBox [this.pagedResultsWidget]));
- w4.Position = 1;
- w4.Expand = false;
- w4.Fill = false;
- // Container child pagedResultsHBox.Gtk.Box+BoxChild
- this.pagedResultsRightLabel = new global::Gtk.Label ();
- this.pagedResultsRightLabel.Name = "pagedResultsRightLabel";
- this.pagedResultsHBox.Add (this.pagedResultsRightLabel);
- global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.pagedResultsHBox [this.pagedResultsRightLabel]));
- w5.Position = 2;
- this.packagesListVBox.Add (this.pagedResultsHBox);
- global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.packagesListVBox [this.pagedResultsHBox]));
- w6.Position = 1;
- w6.Expand = false;
- w6.Fill = false;
- this.mainPane.Add (this.packagesListVBox);
- global::Gtk.Paned.PanedChild w7 = ((global::Gtk.Paned.PanedChild)(this.mainPane [this.packagesListVBox]));
- w7.Resize = false;
- // Container child mainPane.Gtk.Paned+PanedChild
- this.packageInfoVBox = new global::Gtk.VBox ();
- this.packageInfoVBox.Name = "packageInfoVBox";
- this.packageInfoVBox.Spacing = 6;
- // Container child packageInfoVBox.Gtk.Box+BoxChild
- this.packageSourceComboBox = global::Gtk.ComboBox.NewText ();
- this.packageSourceComboBox.Name = "packageSourceComboBox";
- this.packageInfoVBox.Add (this.packageSourceComboBox);
- global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.packageInfoVBox [this.packageSourceComboBox]));
- w8.Position = 0;
- w8.Expand = false;
- w8.Fill = false;
- // Container child packageInfoVBox.Gtk.Box+BoxChild
- this.packageSearchHBox = new global::Gtk.HBox ();
- this.packageSearchHBox.Name = "packageSearchHBox";
- this.packageSearchHBox.Spacing = 6;
- // Container child packageSearchHBox.Gtk.Box+BoxChild
- this.packageSearchEntry = new global::Gtk.Entry ();
- this.packageSearchEntry.CanFocus = true;
- this.packageSearchEntry.Name = "packageSearchEntry";
- this.packageSearchEntry.IsEditable = true;
- this.packageSearchEntry.InvisibleChar = '●';
- this.packageSearchHBox.Add (this.packageSearchEntry);
- global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.packageSearchHBox [this.packageSearchEntry]));
- w9.Position = 0;
- // Container child packageSearchHBox.Gtk.Box+BoxChild
- this.packageSearchButton = new global::Gtk.Button ();
- this.packageSearchButton.CanFocus = true;
- this.packageSearchButton.Name = "packageSearchButton";
- // Container child packageSearchButton.Gtk.Container+ContainerChild
- this.imageSearch = new global::MonoDevelop.Components.ImageView ();
- this.imageSearch.Name = "imageSearch";
- this.imageSearch.IconId = "gtk-find";
- this.imageSearch.IconSize = ((global::Gtk.IconSize)(1));
- this.packageSearchButton.Add (this.imageSearch);
- this.packageSearchHBox.Add (this.packageSearchButton);
- global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.packageSearchHBox [this.packageSearchButton]));
- w11.Position = 1;
- w11.Expand = false;
- w11.Fill = false;
- this.packageInfoVBox.Add (this.packageSearchHBox);
- global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.packageInfoVBox [this.packageSearchHBox]));
- w12.Position = 1;
- w12.Expand = false;
- w12.Fill = false;
- // Container child packageInfoVBox.Gtk.Box+BoxChild
- this.includePrereleaseCheckButton = new global::Gtk.CheckButton ();
- this.includePrereleaseCheckButton.CanFocus = true;
- this.includePrereleaseCheckButton.Name = "includePrereleaseCheckButton";
- this.includePrereleaseCheckButton.Label = global::Mono.Unix.Catalog.GetString ("Include Prerelease");
- this.includePrereleaseCheckButton.DrawIndicator = true;
- this.includePrereleaseCheckButton.UseUnderline = true;
- this.packageInfoVBox.Add (this.includePrereleaseCheckButton);
- global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.packageInfoVBox [this.includePrereleaseCheckButton]));
- w13.Position = 2;
- w13.Expand = false;
- w13.Fill = false;
- // Container child packageInfoVBox.Gtk.Box+BoxChild
- this.updateAllPackagesButtonBox = new global::Gtk.HButtonBox ();
- this.updateAllPackagesButtonBox.Name = "updateAllPackagesButtonBox";
- this.updateAllPackagesButtonBox.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
- // Container child updateAllPackagesButtonBox.Gtk.ButtonBox+ButtonBoxChild
- this.updateAllPackagesButton = new global::Gtk.Button ();
- this.updateAllPackagesButton.CanFocus = true;
- this.updateAllPackagesButton.Name = "updateAllPackagesButton";
- this.updateAllPackagesButton.UseUnderline = true;
- this.updateAllPackagesButton.Label = global::Mono.Unix.Catalog.GetString ("Update All");
- this.updateAllPackagesButtonBox.Add (this.updateAllPackagesButton);
- global::Gtk.ButtonBox.ButtonBoxChild w14 = ((global::Gtk.ButtonBox.ButtonBoxChild)(this.updateAllPackagesButtonBox [this.updateAllPackagesButton]));
- w14.Expand = false;
- w14.Fill = false;
- this.packageInfoVBox.Add (this.updateAllPackagesButtonBox);
- global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.packageInfoVBox [this.updateAllPackagesButtonBox]));
- w15.Position = 3;
- w15.Expand = false;
- w15.Fill = false;
- // Container child packageInfoVBox.Gtk.Box+BoxChild
- this.packageInfoFrame = new global::Gtk.Frame ();
- this.packageInfoFrame.Name = "packageInfoFrame";
- this.packageInfoFrame.ShadowType = ((global::Gtk.ShadowType)(0));
- this.packageInfoFrame.LabelYalign = 0F;
- // Container child packageInfoFrame.Gtk.Container+ContainerChild
- this.packageInfoFrameAlignment = new global::Gtk.Alignment (0F, 0F, 1F, 1F);
- this.packageInfoFrameAlignment.Name = "packageInfoFrameAlignment";
- // Container child packageInfoFrameAlignment.Gtk.Container+ContainerChild
- this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
- this.GtkScrolledWindow.Name = "GtkScrolledWindow";
- this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
- // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
- global::Gtk.Viewport w16 = new global::Gtk.Viewport ();
- w16.ShadowType = ((global::Gtk.ShadowType)(0));
- // Container child GtkViewport.Gtk.Container+ContainerChild
- this.packageInfoFrameVBox = new global::Gtk.VBox ();
- this.packageInfoFrameVBox.Name = "packageInfoFrameVBox";
- this.packageInfoFrameVBox.Spacing = 6;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageCreatedByHBox = new global::Gtk.HBox ();
- this.packageCreatedByHBox.Name = "packageCreatedByHBox";
- this.packageCreatedByHBox.Spacing = 6;
- // Container child packageCreatedByHBox.Gtk.Box+BoxChild
- this.packageCreatedByLabel = new global::Gtk.Label ();
- this.packageCreatedByLabel.Name = "packageCreatedByLabel";
- this.packageCreatedByLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<span weight='bold'>Created by:</span>");
- this.packageCreatedByLabel.UseMarkup = true;
- this.packageCreatedByHBox.Add (this.packageCreatedByLabel);
- global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.packageCreatedByHBox [this.packageCreatedByLabel]));
- w17.Position = 0;
- w17.Expand = false;
- w17.Fill = false;
- // Container child packageCreatedByHBox.Gtk.Box+BoxChild
- this.packageCreatedByTextBox = new global::Gtk.Label ();
- this.packageCreatedByTextBox.Name = "packageCreatedByTextBox";
- this.packageCreatedByTextBox.Selectable = true;
- this.packageCreatedByHBox.Add (this.packageCreatedByTextBox);
- global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.packageCreatedByHBox [this.packageCreatedByTextBox]));
- w18.Position = 1;
- w18.Expand = false;
- w18.Fill = false;
- this.packageInfoFrameVBox.Add (this.packageCreatedByHBox);
- global::Gtk.Box.BoxChild w19 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageCreatedByHBox]));
- w19.Position = 0;
- w19.Expand = false;
- w19.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageIdHBox = new global::Gtk.HBox ();
- this.packageIdHBox.Name = "packageIdHBox";
- this.packageIdHBox.Spacing = 6;
- // Container child packageIdHBox.Gtk.Box+BoxChild
- this.packageIdLabel = new global::Gtk.Label ();
- this.packageIdLabel.Name = "packageIdLabel";
- this.packageIdLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<span weight='bold'>Id:</span>");
- this.packageIdLabel.UseMarkup = true;
- this.packageIdHBox.Add (this.packageIdLabel);
- global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.packageIdHBox [this.packageIdLabel]));
- w20.Position = 0;
- w20.Expand = false;
- w20.Fill = false;
- // Container child packageIdHBox.Gtk.Box+BoxChild
- this.packageIdButton = null;
- this.packageIdHBox.Add (this.packageIdButton);
- global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.packageIdHBox [this.packageIdButton]));
- w21.Position = 1;
- // Container child packageIdHBox.Gtk.Box+BoxChild
- this.packageIdTextBox = new global::Gtk.Label ();
- this.packageIdTextBox.Name = "packageIdTextBox";
- this.packageIdTextBox.Selectable = true;
- this.packageIdHBox.Add (this.packageIdTextBox);
- global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.packageIdHBox [this.packageIdTextBox]));
- w22.Position = 2;
- w22.Expand = false;
- w22.Fill = false;
- this.packageInfoFrameVBox.Add (this.packageIdHBox);
- global::Gtk.Box.BoxChild w23 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageIdHBox]));
- w23.Position = 1;
- w23.Expand = false;
- w23.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageVersionHBox = new global::Gtk.HBox ();
- this.packageVersionHBox.Name = "packageVersionHBox";
- this.packageVersionHBox.Spacing = 6;
- // Container child packageVersionHBox.Gtk.Box+BoxChild
- this.packageVersionLabel = new global::Gtk.Label ();
- this.packageVersionLabel.Name = "packageVersionLabel";
- this.packageVersionLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<span weight='bold'>Version:</span>");
- this.packageVersionLabel.UseMarkup = true;
- this.packageVersionHBox.Add (this.packageVersionLabel);
- global::Gtk.Box.BoxChild w24 = ((global::Gtk.Box.BoxChild)(this.packageVersionHBox [this.packageVersionLabel]));
- w24.Position = 0;
- w24.Expand = false;
- w24.Fill = false;
- // Container child packageVersionHBox.Gtk.Box+BoxChild
- this.packageVersionTextBox = new global::Gtk.Label ();
- this.packageVersionTextBox.Name = "packageVersionTextBox";
- this.packageVersionTextBox.Selectable = true;
- this.packageVersionHBox.Add (this.packageVersionTextBox);
- global::Gtk.Box.BoxChild w25 = ((global::Gtk.Box.BoxChild)(this.packageVersionHBox [this.packageVersionTextBox]));
- w25.Position = 1;
- w25.Expand = false;
- w25.Fill = false;
- this.packageInfoFrameVBox.Add (this.packageVersionHBox);
- global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageVersionHBox]));
- w26.Position = 2;
- w26.Expand = false;
- w26.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageLastUpdatedHBox = new global::Gtk.HBox ();
- this.packageLastUpdatedHBox.Name = "packageLastUpdatedHBox";
- this.packageLastUpdatedHBox.Spacing = 6;
- // Container child packageLastUpdatedHBox.Gtk.Box+BoxChild
- this.packageLastUpdatedLabel = new global::Gtk.Label ();
- this.packageLastUpdatedLabel.Name = "packageLastUpdatedLabel";
- this.packageLastUpdatedLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<span weight='bold'>Last Updated:</span>");
- this.packageLastUpdatedLabel.UseMarkup = true;
- this.packageLastUpdatedHBox.Add (this.packageLastUpdatedLabel);
- global::Gtk.Box.BoxChild w27 = ((global::Gtk.Box.BoxChild)(this.packageLastUpdatedHBox [this.packageLastUpdatedLabel]));
- w27.Position = 0;
- w27.Expand = false;
- w27.Fill = false;
- // Container child packageLastUpdatedHBox.Gtk.Box+BoxChild
- this.packageLastUpdatedTextBox = new global::Gtk.Label ();
- this.packageLastUpdatedTextBox.Name = "packageLastUpdatedTextBox";
- this.packageLastUpdatedTextBox.Selectable = true;
- this.packageLastUpdatedHBox.Add (this.packageLastUpdatedTextBox);
- global::Gtk.Box.BoxChild w28 = ((global::Gtk.Box.BoxChild)(this.packageLastUpdatedHBox [this.packageLastUpdatedTextBox]));
- w28.Position = 1;
- w28.Expand = false;
- w28.Fill = false;
- this.packageInfoFrameVBox.Add (this.packageLastUpdatedHBox);
- global::Gtk.Box.BoxChild w29 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageLastUpdatedHBox]));
- w29.Position = 3;
- w29.Expand = false;
- w29.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageDownloadsHBox = new global::Gtk.HBox ();
- this.packageDownloadsHBox.Name = "packageDownloadsHBox";
- this.packageDownloadsHBox.Spacing = 6;
- // Container child packageDownloadsHBox.Gtk.Box+BoxChild
- this.packageDownloadsLabel = new global::Gtk.Label ();
- this.packageDownloadsLabel.Name = "packageDownloadsLabel";
- this.packageDownloadsLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<span weight='bold'>Downloads:</span>");
- this.packageDownloadsLabel.UseMarkup = true;
- this.packageDownloadsHBox.Add (this.packageDownloadsLabel);
- global::Gtk.Box.BoxChild w30 = ((global::Gtk.Box.BoxChild)(this.packageDownloadsHBox [this.packageDownloadsLabel]));
- w30.Position = 0;
- w30.Expand = false;
- w30.Fill = false;
- // Container child packageDownloadsHBox.Gtk.Box+BoxChild
- this.packageDownloadsTextBox = new global::Gtk.Label ();
- this.packageDownloadsTextBox.Name = "packageDownloadsTextBox";
- this.packageDownloadsTextBox.Selectable = true;
- this.packageDownloadsHBox.Add (this.packageDownloadsTextBox);
- global::Gtk.Box.BoxChild w31 = ((global::Gtk.Box.BoxChild)(this.packageDownloadsHBox [this.packageDownloadsTextBox]));
- w31.Position = 1;
- w31.Expand = false;
- w31.Fill = false;
- this.packageInfoFrameVBox.Add (this.packageDownloadsHBox);
- global::Gtk.Box.BoxChild w32 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageDownloadsHBox]));
- w32.Position = 4;
- w32.Expand = false;
- w32.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.viewLicenseTermsHBox = new global::Gtk.HBox ();
- this.viewLicenseTermsHBox.Name = "viewLicenseTermsHBox";
- this.viewLicenseTermsHBox.Spacing = 6;
- // Container child viewLicenseTermsHBox.Gtk.Box+BoxChild
- this.viewLicenseTermsButton = null;
- this.viewLicenseTermsHBox.Add (this.viewLicenseTermsButton);
- global::Gtk.Box.BoxChild w33 = ((global::Gtk.Box.BoxChild)(this.viewLicenseTermsHBox [this.viewLicenseTermsButton]));
- w33.Position = 0;
- this.packageInfoFrameVBox.Add (this.viewLicenseTermsHBox);
- global::Gtk.Box.BoxChild w34 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.viewLicenseTermsHBox]));
- w34.Position = 5;
- w34.Expand = false;
- w34.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.moreInformationHBox = new global::Gtk.HBox ();
- this.moreInformationHBox.Name = "moreInformationHBox";
- // Container child moreInformationHBox.Gtk.Box+BoxChild
- this.moreInformationButton = null;
- this.moreInformationHBox.Add (this.moreInformationButton);
- global::Gtk.Box.BoxChild w35 = ((global::Gtk.Box.BoxChild)(this.moreInformationHBox [this.moreInformationButton]));
- w35.Position = 0;
- this.packageInfoFrameVBox.Add (this.moreInformationHBox);
- global::Gtk.Box.BoxChild w36 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.moreInformationHBox]));
- w36.Position = 6;
- w36.Expand = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageDescriptionTextView = new global::Gtk.TextView ();
- this.packageDescriptionTextView.CanFocus = true;
- this.packageDescriptionTextView.Name = "packageDescriptionTextView";
- this.packageDescriptionTextView.Editable = false;
- this.packageDescriptionTextView.CursorVisible = false;
- this.packageDescriptionTextView.WrapMode = ((global::Gtk.WrapMode)(2));
- this.packageInfoFrameVBox.Add (this.packageDescriptionTextView);
- global::Gtk.Box.BoxChild w37 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageDescriptionTextView]));
- w37.Position = 7;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageDependenciesHBox = new global::Gtk.HBox ();
- this.packageDependenciesHBox.Name = "packageDependenciesHBox";
- this.packageDependenciesHBox.Spacing = 6;
- // Container child packageDependenciesHBox.Gtk.Box+BoxChild
- this.packageDependenciesLabel = new global::Gtk.Label ();
- this.packageDependenciesLabel.Name = "packageDependenciesLabel";
- this.packageDependenciesLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<span weight='bold'>Dependencies:</span>");
- this.packageDependenciesLabel.UseMarkup = true;
- this.packageDependenciesHBox.Add (this.packageDependenciesLabel);
- global::Gtk.Box.BoxChild w38 = ((global::Gtk.Box.BoxChild)(this.packageDependenciesHBox [this.packageDependenciesLabel]));
- w38.Position = 0;
- w38.Expand = false;
- w38.Fill = false;
- // Container child packageDependenciesHBox.Gtk.Box+BoxChild
- this.packageDependenciesNoneLabel = new global::Gtk.Label ();
- this.packageDependenciesNoneLabel.Name = "packageDependenciesNoneLabel";
- this.packageDependenciesNoneLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("None");
- this.packageDependenciesNoneLabel.Selectable = true;
- this.packageDependenciesHBox.Add (this.packageDependenciesNoneLabel);
- global::Gtk.Box.BoxChild w39 = ((global::Gtk.Box.BoxChild)(this.packageDependenciesHBox [this.packageDependenciesNoneLabel]));
- w39.Position = 1;
- w39.Expand = false;
- w39.Fill = false;
- this.packageInfoFrameVBox.Add (this.packageDependenciesHBox);
- global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageDependenciesHBox]));
- w40.Position = 8;
- w40.Expand = false;
- w40.Fill = false;
- // Container child packageInfoFrameVBox.Gtk.Box+BoxChild
- this.packageDependenciesListHBox = new global::Gtk.HBox ();
- this.packageDependenciesListHBox.Name = "packageDependenciesListHBox";
- this.packageDependenciesListHBox.Spacing = 6;
- this.packageDependenciesListHBox.BorderWidth = ((uint)(2));
- // Container child packageDependenciesListHBox.Gtk.Box+BoxChild
- this.packageDependenciesListLabel = new global::Gtk.Label ();
- this.packageDependenciesListLabel.Name = "packageDependenciesListLabel";
- this.packageDependenciesListLabel.UseMarkup = true;
- this.packageDependenciesListHBox.Add (this.packageDependenciesListLabel);
- global::Gtk.Box.BoxChild w41 = ((global::Gtk.Box.BoxChild)(this.packageDependenciesListHBox [this.packageDependenciesListLabel]));
- w41.Position = 0;
- w41.Expand = false;
- w41.Fill = false;
- // Container child packageDependenciesListHBox.Gtk.Box+BoxChild
- this.packageDependenciesListFillerLabel = new global::Gtk.Label ();
- this.packageDependenciesListFillerLabel.Name = "packageDependenciesListFillerLabel";
- this.packageDependenciesListFillerLabel.Selectable = true;
- this.packageDependenciesListHBox.Add (this.packageDependenciesListFillerLabel);
- global::Gtk.Box.BoxChild w42 = ((global::Gtk.Box.BoxChild)(this.packageDependenciesListHBox [this.packageDependenciesListFillerLabel]));
- w42.Position = 1;
- this.packageInfoFrameVBox.Add (this.packageDependenciesListHBox);
- global::Gtk.Box.BoxChild w43 = ((global::Gtk.Box.BoxChild)(this.packageInfoFrameVBox [this.packageDependenciesListHBox]));
- w43.Position = 9;
- w43.Expand = false;
- w43.Fill = false;
- w16.Add (this.packageInfoFrameVBox);
- this.GtkScrolledWindow.Add (w16);
- this.packageInfoFrameAlignment.Add (this.GtkScrolledWindow);
- this.packageInfoFrame.Add (this.packageInfoFrameAlignment);
- this.packageInfoVBox.Add (this.packageInfoFrame);
- global::Gtk.Box.BoxChild w48 = ((global::Gtk.Box.BoxChild)(this.packageInfoVBox [this.packageInfoFrame]));
- w48.Position = 4;
- // Container child packageInfoVBox.Gtk.Box+BoxChild
- this.managePackageButtonBox = new global::Gtk.HButtonBox ();
- this.managePackageButtonBox.Name = "managePackageButtonBox";
- this.managePackageButtonBox.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(3));
- // Container child managePackageButtonBox.Gtk.ButtonBox+ButtonBoxChild
- this.addPackageButton = new global::Gtk.Button ();
- this.addPackageButton.CanFocus = true;
- this.addPackageButton.Name = "addPackageButton";
- this.addPackageButton.UseUnderline = true;
- this.addPackageButton.Label = global::Mono.Unix.Catalog.GetString ("Add");
- this.managePackageButtonBox.Add (this.addPackageButton);
- global::Gtk.ButtonBox.ButtonBoxChild w49 = ((global::Gtk.ButtonBox.ButtonBoxChild)(this.managePackageButtonBox [this.addPackageButton]));
- w49.Expand = false;
- w49.Fill = false;
- // Container child managePackageButtonBox.Gtk.ButtonBox+ButtonBoxChild
- this.removePackageButton = new global::Gtk.Button ();
- this.removePackageButton.CanFocus = true;
- this.removePackageButton.Name = "removePackageButton";
- this.removePackageButton.UseUnderline = true;
- this.removePackageButton.Label = global::Mono.Unix.Catalog.GetString ("Remove");
- this.managePackageButtonBox.Add (this.removePackageButton);
- global::Gtk.ButtonBox.ButtonBoxChild w50 = ((global::Gtk.ButtonBox.ButtonBoxChild)(this.managePackageButtonBox [this.removePackageButton]));
- w50.Position = 1;
- w50.Expand = false;
- w50.Fill = false;
- // Container child managePackageButtonBox.Gtk.ButtonBox+ButtonBoxChild
- this.managePackageButton = new global::Gtk.Button ();
- this.managePackageButton.CanFocus = true;
- this.managePackageButton.Name = "managePackageButton";
- this.managePackageButton.UseUnderline = true;
- this.managePackageButton.Label = global::Mono.Unix.Catalog.GetString ("Manage");
- this.managePackageButtonBox.Add (this.managePackageButton);
- global::Gtk.ButtonBox.ButtonBoxChild w51 = ((global::Gtk.ButtonBox.ButtonBoxChild)(this.managePackageButtonBox [this.managePackageButton]));
- w51.Position = 2;
- w51.Expand = false;
- w51.Fill = false;
- this.packageInfoVBox.Add (this.managePackageButtonBox);
- global::Gtk.Box.BoxChild w52 = ((global::Gtk.Box.BoxChild)(this.packageInfoVBox [this.managePackageButtonBox]));
- w52.PackType = ((global::Gtk.PackType)(1));
- w52.Position = 5;
- w52.Expand = false;
- w52.Fill = false;
- this.mainPane.Add (this.packageInfoVBox);
- this.Add (this.mainPane);
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.packageInfoFrameVBox.Hide ();
- this.addPackageButton.Hide ();
- this.removePackageButton.Hide ();
- this.managePackageButton.Hide ();
- this.Hide ();
- this.packageSourceComboBox.Changed += new global::System.EventHandler (this.PackageSourceChanged);
- this.packageSearchEntry.Activated += new global::System.EventHandler (this.PackageSearchEntryActivated);
- this.packageSearchButton.Clicked += new global::System.EventHandler (this.SearchButtonClicked);
- this.updateAllPackagesButton.Clicked += new global::System.EventHandler (this.UpdateAllPackagesButtonClicked);
- this.addPackageButton.Clicked += new global::System.EventHandler (this.OnAddPackageButtonClicked);
- this.removePackageButton.Clicked += new global::System.EventHandler (this.RemovePackageButtonClicked);
- this.managePackageButton.Clicked += new global::System.EventHandler (this.ManagePackagesButtonClicked);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PagedResultsWidget.cs b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PagedResultsWidget.cs deleted file mode 100644 index 620fb8dba1..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.PagedResultsWidget.cs +++ /dev/null @@ -1,145 +0,0 @@ -
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.PackageManagement
-{
- internal partial class PagedResultsWidget
- {
- private global::Gtk.HBox mainHBox;
-
- private global::Gtk.Button backButton;
-
- private global::MonoDevelop.Components.ImageView imageBack;
-
- private global::Gtk.Button firstButton;
-
- private global::Gtk.Button secondButton;
-
- private global::Gtk.Button thirdButton;
-
- private global::Gtk.Button fourthButton;
-
- private global::Gtk.Button fifthButton;
-
- private global::Gtk.Button forwardButton;
-
- private global::MonoDevelop.Components.ImageView imageForward;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.PackageManagement.PagedResultsWidget
- global::Stetic.BinContainer.Attach (this);
- this.Name = "MonoDevelop.PackageManagement.PagedResultsWidget";
- // Container child MonoDevelop.PackageManagement.PagedResultsWidget.Gtk.Container+ContainerChild
- this.mainHBox = new global::Gtk.HBox ();
- this.mainHBox.Name = "mainHBox";
- // Container child mainHBox.Gtk.Box+BoxChild
- this.backButton = new global::Gtk.Button ();
- this.backButton.CanFocus = true;
- this.backButton.Name = "backButton";
- this.backButton.FocusOnClick = false;
- this.backButton.Relief = ((global::Gtk.ReliefStyle)(2));
- // Container child backButton.Gtk.Container+ContainerChild
- this.imageBack = new global::MonoDevelop.Components.ImageView ();
- this.imageBack.Name = "imageBack";
- this.imageBack.IconId = "gtk-go-back";
- this.imageBack.IconSize = ((global::Gtk.IconSize)(1));
- this.backButton.Add (this.imageBack);
- this.mainHBox.Add (this.backButton);
- global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.backButton]));
- w2.Position = 0;
- w2.Expand = false;
- w2.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.firstButton = new global::Gtk.Button ();
- this.firstButton.CanFocus = true;
- this.firstButton.Name = "firstButton";
- this.firstButton.UseUnderline = true;
- this.firstButton.FocusOnClick = false;
- this.firstButton.Relief = ((global::Gtk.ReliefStyle)(2));
- this.firstButton.Label = global::Mono.Unix.Catalog.GetString ("1");
- this.mainHBox.Add (this.firstButton);
- global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.firstButton]));
- w3.Position = 1;
- w3.Expand = false;
- w3.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.secondButton = new global::Gtk.Button ();
- this.secondButton.CanFocus = true;
- this.secondButton.Name = "secondButton";
- this.secondButton.FocusOnClick = false;
- this.secondButton.Relief = ((global::Gtk.ReliefStyle)(2));
- this.secondButton.Label = global::Mono.Unix.Catalog.GetString ("2");
- this.mainHBox.Add (this.secondButton);
- global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.secondButton]));
- w4.Position = 2;
- w4.Expand = false;
- w4.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.thirdButton = new global::Gtk.Button ();
- this.thirdButton.CanFocus = true;
- this.thirdButton.Name = "thirdButton";
- this.thirdButton.FocusOnClick = false;
- this.thirdButton.Relief = ((global::Gtk.ReliefStyle)(2));
- this.thirdButton.Label = global::Mono.Unix.Catalog.GetString ("3");
- this.mainHBox.Add (this.thirdButton);
- global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.thirdButton]));
- w5.Position = 3;
- w5.Expand = false;
- w5.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.fourthButton = new global::Gtk.Button ();
- this.fourthButton.CanFocus = true;
- this.fourthButton.Name = "fourthButton";
- this.fourthButton.FocusOnClick = false;
- this.fourthButton.Relief = ((global::Gtk.ReliefStyle)(2));
- this.fourthButton.Label = global::Mono.Unix.Catalog.GetString ("4");
- this.mainHBox.Add (this.fourthButton);
- global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.fourthButton]));
- w6.Position = 4;
- w6.Expand = false;
- w6.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.fifthButton = new global::Gtk.Button ();
- this.fifthButton.CanFocus = true;
- this.fifthButton.Name = "fifthButton";
- this.fifthButton.FocusOnClick = false;
- this.fifthButton.Relief = ((global::Gtk.ReliefStyle)(2));
- this.fifthButton.Label = global::Mono.Unix.Catalog.GetString ("5");
- this.mainHBox.Add (this.fifthButton);
- global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.fifthButton]));
- w7.Position = 5;
- w7.Expand = false;
- w7.Fill = false;
- // Container child mainHBox.Gtk.Box+BoxChild
- this.forwardButton = new global::Gtk.Button ();
- this.forwardButton.CanFocus = true;
- this.forwardButton.Name = "forwardButton";
- this.forwardButton.FocusOnClick = false;
- this.forwardButton.Relief = ((global::Gtk.ReliefStyle)(2));
- // Container child forwardButton.Gtk.Container+ContainerChild
- this.imageForward = new global::MonoDevelop.Components.ImageView ();
- this.imageForward.Name = "imageForward";
- this.imageForward.IconId = "gtk-go-forward";
- this.imageForward.IconSize = ((global::Gtk.IconSize)(1));
- this.forwardButton.Add (this.imageForward);
- this.mainHBox.Add (this.forwardButton);
- global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.mainHBox [this.forwardButton]));
- w9.Position = 6;
- w9.Expand = false;
- w9.Fill = false;
- this.Add (this.mainHBox);
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.Hide ();
- this.backButton.Clicked += new global::System.EventHandler (this.BackButtonClicked);
- this.firstButton.Clicked += new global::System.EventHandler (this.PageButtonClicked);
- this.secondButton.Clicked += new global::System.EventHandler (this.PageButtonClicked);
- this.thirdButton.Clicked += new global::System.EventHandler (this.PageButtonClicked);
- this.fourthButton.Clicked += new global::System.EventHandler (this.PageButtonClicked);
- this.fifthButton.Clicked += new global::System.EventHandler (this.PageButtonClicked);
- this.forwardButton.Clicked += new global::System.EventHandler (this.ForwardButtonClicked);
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.SelectProjectsDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.SelectProjectsDialog.cs deleted file mode 100644 index 65295f4e5e..0000000000 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/MonoDevelop.PackageManagement.SelectProjectsDialog.cs +++ /dev/null @@ -1,95 +0,0 @@ -
-// This file has been generated by the GUI designer. Do not modify.
-namespace MonoDevelop.PackageManagement
-{
- internal partial class SelectProjectsDialog
- {
- private global::Gtk.HBox installLabelHBox;
- private global::Gtk.Label installLabel;
- private global::Gtk.ScrolledWindow GtkScrolledWindow;
- private global::Gtk.TreeView projectsTreeView;
- private global::Gtk.Button buttonCancel;
- private global::Gtk.Button buttonOk;
-
- protected virtual void Build ()
- {
- global::Stetic.Gui.Initialize (this);
- // Widget MonoDevelop.PackageManagement.SelectProjectsDialog
- this.Name = "MonoDevelop.PackageManagement.SelectProjectsDialog";
- this.Title = global::Mono.Unix.Catalog.GetString ("Select Projects");
- this.WindowPosition = ((global::Gtk.WindowPosition)(1));
- // Internal child MonoDevelop.PackageManagement.SelectProjectsDialog.VBox
- global::Gtk.VBox w1 = this.VBox;
- w1.Name = "mainVBox";
- w1.BorderWidth = ((uint)(2));
- // Container child mainVBox.Gtk.Box+BoxChild
- this.installLabelHBox = new global::Gtk.HBox ();
- this.installLabelHBox.Name = "installLabelHBox";
- this.installLabelHBox.Spacing = 6;
- // Container child installLabelHBox.Gtk.Box+BoxChild
- this.installLabel = new global::Gtk.Label ();
- this.installLabel.Name = "installLabel";
- this.installLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("Install the package into the following projects:");
- this.installLabelHBox.Add (this.installLabel);
- global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.installLabelHBox [this.installLabel]));
- w2.Position = 0;
- w2.Expand = false;
- w2.Fill = false;
- w1.Add (this.installLabelHBox);
- global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(w1 [this.installLabelHBox]));
- w3.Position = 0;
- w3.Expand = false;
- w3.Fill = false;
- // Container child mainVBox.Gtk.Box+BoxChild
- this.GtkScrolledWindow = new global::Gtk.ScrolledWindow ();
- this.GtkScrolledWindow.Name = "GtkScrolledWindow";
- this.GtkScrolledWindow.ShadowType = ((global::Gtk.ShadowType)(1));
- // Container child GtkScrolledWindow.Gtk.Container+ContainerChild
- this.projectsTreeView = new global::Gtk.TreeView ();
- this.projectsTreeView.CanFocus = true;
- this.projectsTreeView.Name = "projectsTreeView";
- this.projectsTreeView.HeadersVisible = false;
- this.GtkScrolledWindow.Add (this.projectsTreeView);
- w1.Add (this.GtkScrolledWindow);
- global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(w1 [this.GtkScrolledWindow]));
- w5.Position = 1;
- // Internal child MonoDevelop.PackageManagement.SelectProjectsDialog.ActionArea
- global::Gtk.HButtonBox w6 = this.ActionArea;
- w6.Name = "buttonActionArea";
- w6.Spacing = 10;
- w6.BorderWidth = ((uint)(5));
- w6.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
- // Container child buttonActionArea.Gtk.ButtonBox+ButtonBoxChild
- this.buttonCancel = new global::Gtk.Button ();
- this.buttonCancel.CanDefault = true;
- this.buttonCancel.CanFocus = true;
- this.buttonCancel.Name = "buttonCancel";
- this.buttonCancel.UseStock = true;
- this.buttonCancel.UseUnderline = true;
- this.buttonCancel.Label = "gtk-cancel";
- this.AddActionWidget (this.buttonCancel, -6);
- global::Gtk.ButtonBox.ButtonBoxChild w7 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w6 [this.buttonCancel]));
- w7.Expand = false;
- w7.Fill = false;
- // Container child buttonActionArea.Gtk.ButtonBox+ButtonBoxChild
- this.buttonOk = new global::Gtk.Button ();
- this.buttonOk.CanDefault = true;
- this.buttonOk.CanFocus = true;
- this.buttonOk.Name = "buttonOk";
- this.buttonOk.UseStock = true;
- this.buttonOk.UseUnderline = true;
- this.buttonOk.Label = "gtk-ok";
- this.AddActionWidget (this.buttonOk, -5);
- global::Gtk.ButtonBox.ButtonBoxChild w8 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w6 [this.buttonOk]));
- w8.Position = 1;
- w8.Expand = false;
- w8.Fill = false;
- if ((this.Child != null)) {
- this.Child.ShowAll ();
- }
- this.DefaultWidth = 400;
- this.DefaultHeight = 300;
- this.Show ();
- }
- }
-}
diff --git a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/gui.stetic b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/gui.stetic index 9a7a6284dc..185d4fa1c2 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/gui.stetic +++ b/main/src/addins/MonoDevelop.PackageManagement/gtk-gui/gui.stetic @@ -9,788 +9,6 @@ <widget-library name="../../../../build/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll" /> <widget-library name="../../../../build/AddIns/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.dll" internal="true" /> </import> - <widget class="Gtk.Dialog" id="MonoDevelop.PackageManagement.ManagePackagesDialog" design-size="581 446"> - <property name="MemberName" /> - <property name="Title" translatable="yes">Manage Packages</property> - <property name="WindowPosition">Center</property> - <property name="DefaultWidth">640</property> - <property name="DefaultHeight">480</property> - <property name="Buttons">1</property> - <property name="HelpButton">False</property> - <child internal-child="VBox"> - <widget class="Gtk.VBox" id="mainVBox"> - <property name="MemberName" /> - <property name="BorderWidth">2</property> - <child> - <widget class="Gtk.Notebook" id="notebook"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="CurrentPage">0</property> - <child> - <widget class="MonoDevelop.PackageManagement.PackagesWidget" id="availablePackagesWidget"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - </widget> - </child> - <child> - <widget class="Gtk.Label" id="availablePackagesLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Available</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - <child> - <widget class="MonoDevelop.PackageManagement.PackagesWidget" id="installedPackagesWidget"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - </widget> - <packing> - <property name="Position">1</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="installedPackagesLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Installed</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - <child> - <widget class="MonoDevelop.PackageManagement.PackagesWidget" id="UpdatedPackagesWidget"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - </widget> - <packing> - <property name="Position">2</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="updatedPackagesLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Updated</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - <child> - <widget class="MonoDevelop.PackageManagement.PackagesWidget" id="recentPackagesWidget"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - </widget> - <packing> - <property name="Position">3</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="recentPackagesLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Recent</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - </packing> - </child> - <child> - <widget class="Gtk.Expander" id="messagesExpander"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <signal name="Activated" handler="MessagesExpanderActivated" /> - <child> - <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow8"> - <property name="MemberName" /> - <property name="ShadowType">In</property> - <child> - <widget class="Gtk.TextView" id="messagesTextView"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="ShowScrollbars">True</property> - <property name="Editable">False</property> - <property name="CursorVisible">False</property> - <property name="Text" translatable="yes" /> - </widget> - </child> - </widget> - </child> - <child> - <widget class="Gtk.Label" id="messagesExpanderLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Messages</property> - <property name="UseUnderline">True</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">False</property> - <property name="Expand">False</property> - </packing> - </child> - </widget> - </child> - <child internal-child="ActionArea"> - <widget class="Gtk.HButtonBox" id="buttonArea"> - <property name="MemberName" /> - <property name="Spacing">10</property> - <property name="BorderWidth">5</property> - <property name="Size">1</property> - <property name="LayoutStyle">End</property> - <child> - <widget class="Gtk.Button" id="buttonClose"> - <property name="MemberName" /> - <property name="CanDefault">True</property> - <property name="CanFocus">True</property> - <property name="UseStock">True</property> - <property name="Type">StockItem</property> - <property name="StockId">gtk-close</property> - <property name="ResponseId">-7</property> - <property name="label">gtk-close</property> - </widget> - <packing> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - <widget class="Gtk.Bin" id="MonoDevelop.PackageManagement.PackagesWidget" design-size="641 371"> - <property name="MemberName" /> - <property name="Visible">False</property> - <child> - <widget class="Gtk.HPaned" id="mainPane"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Position">322</property> - <child> - <widget class="Gtk.VBox" id="packagesListVBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.ScrolledWindow" id="packagesTreeScrolledWindow"> - <property name="MemberName" /> - <property name="ShadowType">In</property> - <child> - <widget class="Gtk.TreeView" id="packagesTreeView"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="ShowScrollbars">True</property> - <property name="EnableSearch">False</property> - <property name="HeadersVisible">False</property> - </widget> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="pagedResultsHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="pagedResultsLeftLabel"> - <property name="MemberName" /> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">False</property> - </packing> - </child> - <child> - <widget class="MonoDevelop.PackageManagement.PagedResultsWidget" id="pagedResultsWidget"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="pagedResultsRightLabel"> - <property name="MemberName" /> - </widget> - <packing> - <property name="Position">2</property> - <property name="AutoSize">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Resize">False</property> - </packing> - </child> - <child> - <widget class="Gtk.VBox" id="packageInfoVBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.ComboBox" id="packageSourceComboBox"> - <property name="MemberName" /> - <property name="IsTextCombo">True</property> - <property name="Items" translatable="yes" /> - <signal name="Changed" handler="PackageSourceChanged" /> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageSearchHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Entry" id="packageSearchEntry"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="IsEditable">True</property> - <property name="InvisibleChar">●</property> - <signal name="Activated" handler="PackageSearchEntryActivated" after="yes" /> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="packageSearchButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">Custom</property> - <signal name="Clicked" handler="SearchButtonClicked" /> - <child> - <widget class="MonoDevelop.Components.ImageView" id="imageSearch"> - <property name="MemberName" /> - <property name="IconId">gtk-find</property> - <property name="IconSize">Menu</property> - </widget> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.CheckButton" id="includePrereleaseCheckButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Label" translatable="yes">Include Prerelease</property> - <property name="DrawIndicator">True</property> - <property name="HasLabel">True</property> - <property name="UseUnderline">True</property> - </widget> - <packing> - <property name="Position">2</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HButtonBox" id="updateAllPackagesButtonBox"> - <property name="MemberName" /> - <property name="Size">1</property> - <property name="LayoutStyle">End</property> - <child> - <widget class="Gtk.Button" id="updateAllPackagesButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">Update All</property> - <property name="UseUnderline">True</property> - <signal name="Clicked" handler="UpdateAllPackagesButtonClicked" /> - </widget> - <packing> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">3</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Frame" id="packageInfoFrame"> - <property name="MemberName" /> - <property name="ShadowType">None</property> - <property name="LabelYalign">0</property> - <child> - <widget class="Gtk.Alignment" id="packageInfoFrameAlignment"> - <property name="MemberName" /> - <property name="Xalign">0</property> - <property name="Yalign">0</property> - <child> - <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow"> - <property name="MemberName" /> - <property name="ShadowType">In</property> - <child> - <widget class="Gtk.Viewport" id="GtkViewport"> - <property name="MemberName" /> - <property name="ShadowType">None</property> - <child> - <widget class="Gtk.VBox" id="packageInfoFrameVBox"> - <property name="MemberName" /> - <property name="Visible">False</property> - <property name="ShowScrollbars">True</property> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.HBox" id="packageCreatedByHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageCreatedByLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes"><span weight='bold'>Created by:</span></property> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageCreatedByTextBox"> - <property name="MemberName" /> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageIdHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageIdLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes"><span weight='bold'>Id:</span></property> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="MonoDevelop.PackageManagement.HyperlinkWidget" id="packageIdButton"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageIdTextBox"> - <property name="MemberName" /> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">2</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageVersionHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageVersionLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes"><span weight='bold'>Version:</span></property> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageVersionTextBox"> - <property name="MemberName" /> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">2</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageLastUpdatedHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageLastUpdatedLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes"><span weight='bold'>Last Updated:</span></property> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageLastUpdatedTextBox"> - <property name="MemberName" /> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">3</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageDownloadsHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageDownloadsLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes"><span weight='bold'>Downloads:</span></property> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageDownloadsTextBox"> - <property name="MemberName" /> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">4</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="viewLicenseTermsHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="MonoDevelop.PackageManagement.HyperlinkWidget" id="viewLicenseTermsButton"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - <property name="Uri" /> - <property name="Label">View License Terms</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">5</property> - <property name="AutoSize">False</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="moreInformationHBox"> - <property name="MemberName" /> - <child> - <widget class="MonoDevelop.PackageManagement.HyperlinkWidget" id="moreInformationButton"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - <property name="Uri" /> - <property name="Label">More Information</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">6</property> - <property name="AutoSize">False</property> - <property name="Expand">False</property> - </packing> - </child> - <child> - <widget class="Gtk.TextView" id="packageDescriptionTextView"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Editable">False</property> - <property name="CursorVisible">False</property> - <property name="Text" translatable="yes" /> - <property name="WrapMode">Word</property> - </widget> - <packing> - <property name="Position">7</property> - <property name="AutoSize">True</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageDependenciesHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageDependenciesLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes"><span weight='bold'>Dependencies:</span></property> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageDependenciesNoneLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">None</property> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">8</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HBox" id="packageDependenciesListHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <property name="BorderWidth">2</property> - <child> - <widget class="Gtk.Label" id="packageDependenciesListLabel"> - <property name="MemberName" /> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="packageDependenciesListFillerLabel"> - <property name="MemberName" /> - <property name="Selectable">True</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">9</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="Position">4</property> - <property name="AutoSize">False</property> - </packing> - </child> - <child> - <widget class="Gtk.HButtonBox" id="managePackageButtonBox"> - <property name="MemberName" /> - <property name="Size">3</property> - <property name="LayoutStyle">Start</property> - <child> - <widget class="Gtk.Button" id="addPackageButton"> - <property name="MemberName" /> - <property name="Visible">False</property> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">Add</property> - <property name="UseUnderline">True</property> - <signal name="Clicked" handler="OnAddPackageButtonClicked" /> - </widget> - <packing> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="removePackageButton"> - <property name="MemberName" /> - <property name="Visible">False</property> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">Remove</property> - <property name="UseUnderline">True</property> - <signal name="Clicked" handler="RemovePackageButtonClicked" /> - </widget> - <packing> - <property name="Position">1</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="managePackageButton"> - <property name="MemberName" /> - <property name="Visible">False</property> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">Manage</property> - <property name="UseUnderline">True</property> - <signal name="Clicked" handler="ManagePackagesButtonClicked" /> - </widget> - <packing> - <property name="Position">2</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="PackType">End</property> - <property name="Position">5</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <widget class="Gtk.Bin" id="MonoDevelop.PackageManagement.HyperlinkWidget" design-size="300 121"> - <property name="MemberName" /> - <property name="Visible">False</property> - <child> - <placeholder /> - </child> - </widget> <widget class="Gtk.Dialog" id="MonoDevelop.PackageManagement.LicenseAcceptanceDialog" design-size="494 365"> <property name="MemberName" /> <property name="Title" translatable="yes">License Acceptance</property> @@ -964,197 +182,6 @@ If you do not agree to the license terms click Decline.</property> </widget> </child> </widget> - <widget class="Gtk.Bin" id="MonoDevelop.PackageManagement.PackageLicenseWidget" design-size="461 77"> - <property name="MemberName" /> - <property name="Visible">False</property> - <child> - <widget class="Gtk.HBox" id="mainHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.VBox" id="packageIdVBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.HBox" id="packageIdHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="packageIdLabel"> - <property name="MemberName" /> - <property name="UseMarkup">True</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <placeholder /> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="MonoDevelop.PackageManagement.HyperlinkWidget" id="licenseHyperlinkWidget"> - <property name="MemberName" /> - <property name="Events">ButtonPressMask</property> - <property name="Label">View License Terms</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">False</property> - <property name="Expand">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Label" id="fillerLabel"> - <property name="MemberName" /> - </widget> - <packing> - <property name="Position">2</property> - <property name="AutoSize">False</property> - </packing> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">False</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow"> - <property name="MemberName" /> - <property name="ShadowType">In</property> - <child> - <widget class="Gtk.TextView" id="packageSummaryTextView"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="ShowScrollbars">True</property> - <property name="Editable">False</property> - <property name="CursorVisible">False</property> - <property name="Text" translatable="yes" /> - <property name="WrapMode">Word</property> - </widget> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">False</property> - </packing> - </child> - </widget> - </child> - </widget> - <widget class="Gtk.Dialog" id="MonoDevelop.PackageManagement.SelectProjectsDialog" design-size="400 300"> - <property name="MemberName" /> - <property name="Title" translatable="yes">Select Projects</property> - <property name="WindowPosition">Center</property> - <property name="Buttons">2</property> - <property name="HelpButton">False</property> - <child internal-child="VBox"> - <widget class="Gtk.VBox" id="mainVBox"> - <property name="MemberName" /> - <property name="BorderWidth">2</property> - <child> - <widget class="Gtk.HBox" id="installLabelHBox"> - <property name="MemberName" /> - <property name="Spacing">6</property> - <child> - <widget class="Gtk.Label" id="installLabel"> - <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Install the package into the following projects:</property> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <placeholder /> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.ScrolledWindow" id="GtkScrolledWindow"> - <property name="MemberName" /> - <property name="ShadowType">In</property> - <child> - <widget class="Gtk.TreeView" id="projectsTreeView"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="ShowScrollbars">True</property> - <property name="HeadersVisible">False</property> - </widget> - </child> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - </packing> - </child> - </widget> - </child> - <child internal-child="ActionArea"> - <widget class="Gtk.HButtonBox" id="buttonActionArea"> - <property name="MemberName" /> - <property name="Spacing">10</property> - <property name="BorderWidth">5</property> - <property name="Size">2</property> - <property name="LayoutStyle">End</property> - <child> - <widget class="Gtk.Button" id="buttonCancel"> - <property name="MemberName" /> - <property name="CanDefault">True</property> - <property name="CanFocus">True</property> - <property name="UseStock">True</property> - <property name="Type">StockItem</property> - <property name="StockId">gtk-cancel</property> - <property name="ResponseId">-6</property> - <property name="label">gtk-cancel</property> - </widget> - <packing> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="buttonOk"> - <property name="MemberName" /> - <property name="CanDefault">True</property> - <property name="CanFocus">True</property> - <property name="UseStock">True</property> - <property name="Type">StockItem</property> - <property name="StockId">gtk-ok</property> - <property name="ResponseId">-5</property> - <property name="label">gtk-ok</property> - </widget> - <packing> - <property name="Position">1</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> <widget class="Gtk.Bin" id="MonoDevelop.PackageManagement.PackageSourcesWidget" design-size="452 300"> <property name="MemberName" /> <property name="Visible">False</property> @@ -1368,145 +395,4 @@ If you do not agree to the license terms click Decline.</property> </widget> </child> </widget> - <widget class="Gtk.Bin" id="MonoDevelop.PackageManagement.PagedResultsWidget" design-size="181 30"> - <property name="MemberName" /> - <property name="Visible">False</property> - <child> - <widget class="Gtk.HBox" id="mainHBox"> - <property name="MemberName" /> - <child> - <widget class="Gtk.Button" id="backButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">Custom</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="BackButtonClicked" /> - <child> - <widget class="MonoDevelop.Components.ImageView" id="imageBack"> - <property name="MemberName" /> - <property name="IconId">gtk-go-back</property> - <property name="IconSize">Menu</property> - </widget> - </child> - </widget> - <packing> - <property name="Position">0</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="firstButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">1</property> - <property name="UseUnderline">True</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="PageButtonClicked" /> - </widget> - <packing> - <property name="Position">1</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="secondButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">2</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="PageButtonClicked" /> - </widget> - <packing> - <property name="Position">2</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="thirdButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">3</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="PageButtonClicked" /> - </widget> - <packing> - <property name="Position">3</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="fourthButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">4</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="PageButtonClicked" /> - </widget> - <packing> - <property name="Position">4</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="fifthButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">TextOnly</property> - <property name="Label" translatable="yes">5</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="PageButtonClicked" /> - </widget> - <packing> - <property name="Position">5</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - <child> - <widget class="Gtk.Button" id="forwardButton"> - <property name="MemberName" /> - <property name="CanFocus">True</property> - <property name="Type">Custom</property> - <property name="FocusOnClick">False</property> - <property name="Relief">None</property> - <signal name="Clicked" handler="ForwardButtonClicked" /> - <child> - <widget class="MonoDevelop.Components.ImageView" id="imageForward"> - <property name="MemberName" /> - <property name="IconId">gtk-go-forward</property> - <property name="IconSize">Menu</property> - </widget> - </child> - </widget> - <packing> - <property name="Position">6</property> - <property name="AutoSize">True</property> - <property name="Expand">False</property> - <property name="Fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> </stetic-interface>
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.PackageManagement/packages.config b/main/src/addins/MonoDevelop.PackageManagement/packages.config new file mode 100644 index 0000000000..27ac881e50 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
+</packages>
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs index 0b4a28c8b2..d5a3d7c8a7 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.CodeActions/CodeActionEditorExtension.cs @@ -49,6 +49,7 @@ using Microsoft.CodeAnalysis; using System.Reflection; using MonoDevelop.Ide.Gui; using Microsoft.CodeAnalysis.Diagnostics; +using MonoDevelop.Core.Text; namespace MonoDevelop.CodeActions { @@ -100,6 +101,7 @@ namespace MonoDevelop.CodeActions { CancelMenuCloseTimer (); CancelQuickFixTimer (); + HidePreviewTooltip (); Editor.CaretPositionChanged -= HandleCaretPositionChanged; Editor.SelectionChanged -= HandleSelectionChanged; DocumentContext.DocumentParsed -= HandleDocumentDocumentParsed; @@ -277,6 +279,7 @@ namespace MonoDevelop.CodeActions public readonly string Label; public readonly System.Action Action; + public Action<Xwt.Rectangle> ShowPreviewTooltip; public FixMenuEntry (string label, System.Action action) { @@ -360,9 +363,9 @@ namespace MonoDevelop.CodeActions // Explicitly release the grab because the menu is shown on the mouse position, and the widget doesn't get the mouse release event Gdk.Pointer.Ungrab (Gtk.Global.CurrentEventTime); - var menu = CreateContextMenu (entrySet); - menu.Show (parent, x, y, () => Editor.SuppressTooltips = false, true); + HidePreviewTooltip (); + menu.Show (parent, x, y, () => { Editor.SuppressTooltips = false; HidePreviewTooltip ();}, true); } catch (Exception ex) { LoggingService.LogError ("Error while context menu popup.", ex); } @@ -372,7 +375,6 @@ namespace MonoDevelop.CodeActions ContextMenu CreateContextMenu (FixMenuDescriptor entrySet) { var menu = new ContextMenu (); - foreach (var item in entrySet.Items) { if (item == FixMenuEntry.Separator) { menu.Items.Add (new SeparatorContextMenuItem ()); @@ -384,15 +386,34 @@ namespace MonoDevelop.CodeActions var subMenu = item as FixMenuDescriptor; if (subMenu != null) { menuItem.SubMenu = CreateContextMenu (subMenu); + menuItem.Selected += delegate (object sender, Xwt.Rectangle e) { + HidePreviewTooltip (); + }; + menuItem.Deselected += delegate { HidePreviewTooltip (); }; } else { menuItem.Clicked += (object sender, ContextMenuItemClickedEventArgs e) => ((System.Action)((ContextMenuItem)sender).Context) (); + menuItem.Selected += delegate (object sender, Xwt.Rectangle e) { + HidePreviewTooltip (); + if (item.ShowPreviewTooltip != null) { + item.ShowPreviewTooltip (e); + } + }; + menuItem.Deselected += delegate { HidePreviewTooltip (); }; } menu.Items.Add (menuItem); } - + menu.Closed += delegate { HidePreviewTooltip (); }; return menu; } + void HidePreviewTooltip () + { + if (currentPreviewWindow != null) { + currentPreviewWindow.Destroy (); + currentPreviewWindow = null; + } + } + static string CreateLabel (string title, ref int mnemonic) { var escapedLabel = title.Replace ("_", "__"); @@ -449,6 +470,8 @@ namespace MonoDevelop.CodeActions } } + static RefactoringPreviewTooltipWindow currentPreviewWindow; + void PopulateFixes (FixMenuDescriptor menu, ref int items) { int mnemonic = 1; @@ -468,6 +491,13 @@ namespace MonoDevelop.CodeActions await new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run (); ConfirmUsage (fix.CodeAction.EquivalenceKey); }); + + thisInstanceMenuItem.ShowPreviewTooltip = delegate (Xwt.Rectangle rect) { + HidePreviewTooltip (); + currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix.CodeAction); + currentPreviewWindow.RequestPopup (rect); + }; + menu.Add (thisInstanceMenuItem); items++; } @@ -485,6 +515,13 @@ namespace MonoDevelop.CodeActions await new ContextActionRunner (fix.CodeAction, Editor, DocumentContext).Run (); ConfirmUsage (fix.CodeAction.EquivalenceKey); }); + + thisInstanceMenuItem.ShowPreviewTooltip = delegate (Xwt.Rectangle rect) { + HidePreviewTooltip (); + currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix.CodeAction); + currentPreviewWindow.RequestPopup (rect); + }; + menu.Add (thisInstanceMenuItem); items++; } @@ -496,7 +533,7 @@ namespace MonoDevelop.CodeActions .Where (diag => diag.Severity == DiagnosticSeverity.Warning).ToList (); foreach (var warning in warningsAtCaret) { - var label = GettextCatalog.GetString ("_Options for \"{0}\"", warning.Descriptor.Title); + var label = GettextCatalog.GetString ("_Options for \u2018{0}\u2019", warning.Descriptor.Title); var subMenu = new FixMenuDescriptor (label); if (first) { menu.Add (FixMenuEntry.Separator); @@ -510,6 +547,16 @@ namespace MonoDevelop.CodeActions } } ); + menuItem.ShowPreviewTooltip = async delegate (Xwt.Rectangle rect) { + var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (DocumentContext.AnalysisDocument, new TextSpan (Editor.CaretOffset, 0), new [] { warning }, default (CancellationToken)).ConfigureAwait (false); + HidePreviewTooltip (); + var fix = fixes.FirstOrDefault (); + if (fix == null) + return; + currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix.Action); + currentPreviewWindow.RequestPopup (rect); + }; + subMenu.Add (menuItem); menu.Add (subMenu); items++; @@ -517,7 +564,7 @@ namespace MonoDevelop.CodeActions foreach (var fix_ in GetCurrentFixes ().DiagnosticsAtCaret) { var fix = fix_; - var label = GettextCatalog.GetString ("_Options for \"{0}\"", fix.GetMessage ()); + var label = GettextCatalog.GetString ("_Options for \u2018{0}\u2019", fix.GetMessage ()); var subMenu = new FixMenuDescriptor (label); CodeDiagnosticDescriptor descriptor = BuiltInCodeDiagnosticProvider.GetCodeDiagnosticDescriptor (fix.Id); @@ -541,6 +588,15 @@ namespace MonoDevelop.CodeActions delegate { descriptor.DisableWithPragma (Editor, DocumentContext, fix); }); + menuItem.ShowPreviewTooltip = async delegate (Xwt.Rectangle rect) { + var fixes = await CSharpSuppressionFixProvider.Instance.GetSuppressionsAsync (DocumentContext.AnalysisDocument, new TextSpan (Editor.CaretOffset, 0), new [] { fix }, default (CancellationToken)).ConfigureAwait (false); + HidePreviewTooltip (); + var fix2 = fixes.FirstOrDefault (); + if (fix2 == null) + return; + currentPreviewWindow = new RefactoringPreviewTooltipWindow (this.Editor, this.DocumentContext, fix2.Action); + currentPreviewWindow.RequestPopup (rect); + }; subMenu.Add (menuItem); menuItem = new FixMenuEntry (GettextCatalog.GetString ("_Suppress with file"), delegate { @@ -709,8 +765,24 @@ namespace MonoDevelop.CodeActions return; var info = latestModel.GetSymbolInfo (node); var sym = info.Symbol ?? latestModel.GetDeclaredSymbol (node); - if (sym != null) + if (sym != null) { await new MonoDevelop.Refactoring.Rename.RenameRefactoring ().Rename (sym); + } else { + var links = new List<TextLink> (); + var link = new TextLink ("name"); + link.AddLink (new TextSegment (node.Span.Start, node.Span.Length)); + links.Add (link); + var oldVersion = editor.Version; + editor.StartTextLinkMode (new TextLinkModeOptions (links, (arg) => { + //If user cancel renaming revert changes + if (!arg.Success) { + var textChanges = editor.Version.GetChangesTo (oldVersion).ToList (); + foreach (var v in textChanges) { + editor.ReplaceText (v.Offset, v.RemovalLength, v.InsertedText); + } + } + })); + } } catch (Exception ex) { LoggingService.LogError ("Error while renaming " + renameTokenOpt.Value.Parent, ex); } @@ -869,7 +941,8 @@ namespace MonoDevelop.CodeActions return; } - CurrentSmartTagPopup (); + CancelSmartTagPopupTimeout (); + PopupQuickFixMenu (null, menu => { }); } internal bool HasCurrentFixes { diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml index 80dfdf8a69..855c0ec54a 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.addin.xml @@ -71,11 +71,9 @@ <Command id = "MonoDevelop.Refactoring.RefactoryCommands.FindReferences" _label = "_Find References" shortcut = "Shift|F12" - macShortcut = "Shift|Meta|R"/> + macShortcut = "Shift|Meta|R Shift|F12"/> <Command id = "MonoDevelop.Refactoring.RefactoryCommands.FindAllReferences" _label = "_Find References of All Overloads" /> - <Command id = "MonoDevelop.Refactoring.RefactoryCommands.FindDerivedClasses" - _label = "Find _Derived Symbols" /> </Category> <Category _name = "Refactoring" id = "Refactoring"> @@ -95,6 +93,23 @@ _label = "Export C# Code Rules to a File" _description = "Generates an HTML file that contains a list of all code rules" /> + <Command id = "MonoDevelop.Refactoring.AnalyzeWholeSolution" + defaultHandler = "MonoDevelop.Refactoring.AnalyzeWholeSolutionHandler" + _label = "_Whole Solution" + /> + <Command id = "MonoDevelop.Refactoring.AnalyzeCurrentProject" + defaultHandler = "MonoDevelop.Refactoring.AnalyzeCurrentProjectHandler" + _label = "_Current Project" + /> + <Command id = "MonoDevelop.Refactoring.AnalyzeSource" + defaultHandler = "MonoDevelop.Refactoring.AnalyzeSourceHandler" + _label = "_Analyze Source" + /> + </Category> + + <Category id="Hidden" _name="Hidden"> + <Command id = "MonoDevelop.Refactoring.RefactoryCommands.FindDerivedClasses" + _label = "Find _Derived Symbols" /> </Category> </Extension> @@ -104,7 +119,7 @@ <Extension path = "/MonoDevelop/Ide/MainMenu/Edit"> <CommandItem id = "MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" - insertafter="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" /> + insertafter="MonoDevelop.Ide.Commands.TextEditorCommands.ShowParameterCompletionWindow" /> </Extension> <!-- Quick fix commands --> @@ -159,4 +174,19 @@ <Extension path = "/MonoDevelop/Refactoring/JumpToDeclarationHandler"> <Class id="MidStep" class="MonoDevelop.Refactoring.DummyJumpToDeclarationHandler" /> </Extension> + + <Extension path = "/MonoDevelop/Ide/MainMenu/Project"> + <ItemSet + id = "Analyze" + _label = "_Analyze"> + <CommandItem id = "MonoDevelop.Refactoring.AnalyzeWholeSolution" /> + <CommandItem id = "MonoDevelop.Refactoring.AnalyzeCurrentProject" /> + </ItemSet> + </Extension> + + <Extension path="/MonoDevelop/Ide/ContextMenu/ProjectPad"> + <CommandItem id = "MonoDevelop.Refactoring.AnalyzeSource" insertbefore="MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" /> + </Extension> + + </ExtensionModel> diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj index 36cac0ba56..e48abc21e7 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.csproj @@ -168,6 +168,9 @@ <Compile Include="MonoDevelop.Refactoring\FindReferencesProvider.cs" /> <Compile Include="MonoDevelop.Refactoring\JumpToDeclarationHandler.cs" /> <Compile Include="MonoDevelop.Refactoring\InsertionPointService.cs" /> + <Compile Include="MonoDevelop.Refactoring\AnalyzeWholeSolutionHandler.cs" /> + <Compile Include="MonoDevelop.Refactoring\AnalyzeCurrentProjectHandler.cs" /> + <Compile Include="MonoDevelop.Refactoring\RefactoringPreviewTooltipWindow.cs" /> </ItemGroup> <ItemGroup> <Folder Include="MonoDevelop.Refactoring\" /> diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/AnalyzeCurrentProjectHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/AnalyzeCurrentProjectHandler.cs new file mode 100644 index 0000000000..40a55e7c61 --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/AnalyzeCurrentProjectHandler.cs @@ -0,0 +1,101 @@ +// +// AnalyzeCurrentProjectHandler.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2016 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 MonoDevelop.Components.Commands; +using MonoDevelop.Ide.TypeSystem; +using System.Threading.Tasks; +using System.Threading; +using Microsoft.CodeAnalysis.Diagnostics; +using System.Collections.Generic; +using MonoDevelop.CodeActions; +using MonoDevelop.Ide.Editor; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Options; +using MonoDevelop.Projects; +using GLib; +using MonoDevelop.CodeIssues; +using MonoDevelop.Core; +using System.Linq; +using MonoDevelop.Ide.Tasks; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui.Pads; + +namespace MonoDevelop.Refactoring +{ + class AnalyzeCurrentProjectHandler : CommandHandler + { + + protected override void Update (CommandInfo info) + { + var project = IdeApp.ProjectOperations.CurrentSelectedProject; + if (project == null || TypeSystemService.GetCodeAnalysisProject (project) == null) { + info.Text = GettextCatalog.GetString ("Current Project"); + info.Enabled = false; + return; + } + info.Text = GettextCatalog.GetString ("Project '{0}'", project.Name); + info.Enabled = true; + } + + protected async override void Run () + { + Execute (); + } + + internal static async void Execute () + {
+ var project = IdeApp.ProjectOperations.CurrentSelectedProject; + if (project == null) + return; + var analysisProject = TypeSystemService.GetCodeAnalysisProject (project); + if (analysisProject == null) + return; + try { + using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Analyzing project"), null, false, true, false, null, true)) { + CancellationToken token = monitor.CancellationToken; + var allDiagnostics = await Task.Run (async delegate { + var diagnosticList = new List<Diagnostic> (); + monitor.BeginTask (GettextCatalog.GetString ("Analyzing {0}", project.Name), 1); + var providers = await AnalyzeWholeSolutionHandler.GetProviders (analysisProject); + diagnosticList.AddRange (await AnalyzeWholeSolutionHandler.GetDiagnostics (analysisProject, providers, token)); + monitor.EndTask (); + return diagnosticList; + }).ConfigureAwait (false); + + await Runtime.RunInMainThread (delegate { + AnalyzeWholeSolutionHandler.Report (monitor, allDiagnostics); + }).ConfigureAwait (false); + } + } catch (OperationCanceledException) { + } catch (AggregateException ae) { + ae.Flatten ().Handle (ix => ix is OperationCanceledException); + } catch (Exception e) { + LoggingService.LogError ("Error while running diagnostics.", e); + } + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/AnalyzeWholeSolutionHandler.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/AnalyzeWholeSolutionHandler.cs new file mode 100644 index 0000000000..d0494e48c6 --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/AnalyzeWholeSolutionHandler.cs @@ -0,0 +1,242 @@ +// +// AnalyzeWholeSolutionHandler.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2016 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 MonoDevelop.Components.Commands; +using MonoDevelop.Ide.TypeSystem; +using System.Threading.Tasks; +using System.Threading; +using Microsoft.CodeAnalysis.Diagnostics; +using System.Collections.Generic; +using MonoDevelop.CodeActions; +using MonoDevelop.Ide.Editor; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Options; +using MonoDevelop.CodeIssues; +using MonoDevelop.Core; +using MonoDevelop.Ide.Tasks; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Gui.Pads; +using System.Collections.Immutable; +using System.Linq; +using MonoDevelop.Ide.Gui.Components; + +namespace MonoDevelop.Refactoring +{ + class AnalyzeWholeSolutionHandler : CommandHandler + { + internal static async Task<List<DiagnosticAnalyzer>> GetProviders (Project project) + {
+ var providers = new List<DiagnosticAnalyzer> (); + var alreadyAdded = new HashSet<Type> (); + var diagnostics = await CodeRefactoringService.GetCodeDiagnosticsAsync (new EmptyDocumentContext (project), LanguageNames.CSharp, default (CancellationToken)); + var diagnosticTable = new Dictionary<string, CodeDiagnosticDescriptor> (); + foreach (var diagnostic in diagnostics) { + if (alreadyAdded.Contains (diagnostic.DiagnosticAnalyzerType)) + continue; + if (!diagnostic.IsEnabled) + continue; + alreadyAdded.Add (diagnostic.DiagnosticAnalyzerType); + var provider = diagnostic.GetProvider (); + if (provider == null) + continue; + foreach (var diag in provider.SupportedDiagnostics) + diagnosticTable [diag.Id] = diagnostic; + providers.Add (provider); + } + + return providers; + } + + internal static async Task<ImmutableArray<Diagnostic>> GetDiagnostics (Project project, List<DiagnosticAnalyzer> providers, CancellationToken token) + { + var analyzers = ImmutableArray<DiagnosticAnalyzer>.Empty.AddRange (providers); + try { + var compilation = await project.GetCompilationAsync (token).ConfigureAwait (false); + CompilationWithAnalyzers compilationWithAnalyzer; + var options = new CompilationWithAnalyzersOptions ( + null, + delegate (Exception exception, DiagnosticAnalyzer analyzer, Diagnostic diag) { + LoggingService.LogError ("Exception in diagnostic analyzer " + diag.Id + ":" + diag.GetMessage (), exception); + }, + null, + true, + false + ); + + compilationWithAnalyzer = compilation.WithAnalyzers (analyzers, options); + if (token.IsCancellationRequested) + return ImmutableArray<Diagnostic>.Empty; + + return await compilationWithAnalyzer.GetAnalyzerDiagnosticsAsync ().ConfigureAwait (false); + } catch (Exception) { + return ImmutableArray<Diagnostic>.Empty; + } finally { + CompilationWithAnalyzers.ClearAnalyzerState (analyzers); + } + } + + protected override async void Run () + { + Execute (); + } + + static TaskSeverity GetSeverity (Diagnostic diagnostic) + { + switch (diagnostic.Severity) { + case DiagnosticSeverity.Warning: + return TaskSeverity.Warning; + case DiagnosticSeverity.Error: + return TaskSeverity.Error; + default: + return TaskSeverity.Information; + } + } + + internal static async void Execute () + {
+ var workspace = TypeSystemService.Workspace; + try { + using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Analyzing solution"), null, false, true, false, null, true)) { + CancellationToken token = monitor.CancellationToken; + var allDiagnostics = await Task.Run (async delegate { + var diagnosticList = new List<Diagnostic> (); + monitor.BeginTask ("Analyzing solution", workspace.CurrentSolution.Projects.Count ()); + foreach (var project in workspace.CurrentSolution.Projects) { + var providers = await GetProviders (project); + monitor.BeginStep (GettextCatalog.GetString ("Analyzing {0}", project.Name), 1); + diagnosticList.AddRange (await GetDiagnostics (project, providers, token)); + monitor.EndStep (); + } + monitor.EndTask (); + return diagnosticList; + }).ConfigureAwait (false); + await Runtime.RunInMainThread (delegate { + Report (monitor, allDiagnostics); + }).ConfigureAwait (false); + } + } catch (OperationCanceledException) { + } catch (AggregateException ae) { + ae.Flatten ().Handle (ix => ix is OperationCanceledException); + } catch (Exception e) { + LoggingService.LogError ("Error while running diagnostics.", e); + } + } + + internal static void Report (ProgressMonitor monitor, List<Diagnostic> allDiagnostics) + { + monitor.BeginTask (GettextCatalog.GetString ("Reporting results..."), allDiagnostics.Count); + TaskService.Errors.Clear (); + TaskService.Errors.AddRange (allDiagnostics.Select (diagnostic => { + var startLinePosition = diagnostic.Location.GetLineSpan ().StartLinePosition; + return new TaskListEntry ( + diagnostic.Location.SourceTree.FilePath, + diagnostic.GetMessage (), + startLinePosition.Character + 1, + startLinePosition.Line + 1, + GetSeverity (diagnostic) + ); + })); + + monitor.EndTask (); + ShowAnalyzationResults (); + } + + static void ShowAnalyzationResults () + {
+ TaskService.ShowErrors (); + var errorsPad = IdeApp.Workbench.GetPad<ErrorListPad> ().Content as ErrorListPad; + errorsPad.SetFilter (true, true, true); + } + +#pragma warning disable RECS0083 // Shows NotImplementedException throws in the quick task bar + class EmptyDocumentContext : DocumentContext + { + Project project; + + public EmptyDocumentContext (Project project) + { + this.project = project; + } + + public override Document AnalysisDocument { + get { + throw new NotImplementedException (); + } + } + + public override string Name { + get { + throw new NotImplementedException (); + } + } + + public override ParsedDocument ParsedDocument { + get { + throw new NotImplementedException (); + } + } + + public override Projects.Project Project { + get { + return TypeSystemService.GetMonoProject (project); + } + } + + public override void AttachToProject (Projects.Project project) + { + throw new NotImplementedException (); + } + + public override OptionSet GetOptionSet () + { + throw new NotImplementedException (); + } + + public override void ReparseDocument () + { + throw new NotImplementedException (); + } + + public override Task<ParsedDocument> UpdateParseDocument () + { + throw new NotImplementedException (); + } + } +#pragma warning restore RECS0083 // Shows NotImplementedException throws in the quick task bar + } + + class AnalyzeSourceHandler : CommandHandler + { + protected override void Run () + { + if (IdeApp.ProjectOperations.CurrentSelectedProject == null){ + AnalyzeWholeSolutionHandler.Execute (); + } else { + AnalyzeCurrentProjectHandler.Execute (); + } + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs new file mode 100644 index 0000000000..7165ca9c9b --- /dev/null +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringPreviewTooltipWindow.cs @@ -0,0 +1,335 @@ +// +// RefactoringPreviewTooltipWindow.cs +// +// Author: +// Mike Krüger <mkrueger@xamarin.com> +// +// Copyright (c) 2016 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 Microsoft.CodeAnalysis.CodeActions; +using MonoDevelop.Components; +using MonoDevelop.Ide; +using MonoDevelop.Ide.Editor; +using System.Threading; +using MonoDevelop.Core.Text; +using Gtk; +using System.Threading.Tasks; +using System.Collections.Generic; +using MonoDevelop.Ide.Editor.Util; +using System.Linq; +using MonoDevelop.Core; +using Pango; + +namespace MonoDevelop.Refactoring +{ + class RefactoringPreviewTooltipWindow : PopoverWindow + { + TextEditor editor; + CodeAction codeAction; + DocumentContext documentContext; + CancellationTokenSource popupSrc = new CancellationTokenSource (); + ITextDocument changedTextDocument; + + List<DiffHunk> diff; + + int lineHeight; + int indentLength; + FontDescription fontDescription; + + public RefactoringPreviewTooltipWindow (TextEditor editor, DocumentContext documentContext, CodeAction codeAction) + { + this.editor = editor; + this.documentContext = documentContext; + this.codeAction = codeAction; + TransientFor = IdeApp.Workbench.RootWindow; + + fontDescription = Pango.FontDescription.FromString (DefaultSourceEditorOptions.Instance.FontName); + fontDescription.Size = (int)(fontDescription.Size * 0.8f); + + using (var metrics = PangoContext.GetMetrics (fontDescription, PangoContext.Language)) { + lineHeight = (int)Math.Ceiling (0.5 + (metrics.Ascent + metrics.Descent) / Pango.Scale.PangoScale); + } + } + + internal async void RequestPopup (Xwt.Rectangle rect) + { + var token = popupSrc.Token; + + diff = await Task.Run (async delegate { + try { + foreach (var op in await codeAction.GetPreviewOperationsAsync (token)) { + var ac = op as ApplyChangesOperation; + if (ac == null) { + continue; + } + var changedDocument = ac.ChangedSolution.GetDocument (documentContext.AnalysisDocument.Id); + + changedTextDocument = TextEditorFactory.CreateNewDocument (new StringTextSource ((await changedDocument.GetTextAsync (token)).ToString ()), editor.FileName); + try { + var list = new List<DiffHunk> (editor.GetDiff (changedTextDocument, new DiffOptions (false, true))); + if (list.Count > 0) + return list; + } catch (Exception e) { + LoggingService.LogError ("Error while getting preview list diff.", e); + } + + } + } catch (OperationCanceledException) {} + return new List<DiffHunk> (); + }); + if (diff.Count > 0 && !token.IsCancellationRequested) + ShowPopup (rect, PopupPosition.Left); + } + + protected override void OnDestroyed () + { + popupSrc.Cancel (); + base.OnDestroyed (); + } + + // Layout constants + const int verticalTextBorder = 10; + const int verticalTextSpace = 7; + + const int textBorder = 12; + + protected override void OnSizeRequested (ref Gtk.Requisition requisition) + { + base.OnSizeRequested (ref requisition); + int y = verticalTextBorder * 2 - verticalTextSpace + (Core.Platform.IsWindows ? 10 : 2); + + var qh = new Queue<DiffHunk> (); + var he = diff.GetEnumerator (); + he.MoveNext (); + var current = he.Current; + DiffHunk next; + qh.Enqueue (current); + int x = 0; + indentLength = -1; + while (he.MoveNext ()) { + next = he.Current; + + if (current.Overlaps (next)) { + // Change upper bounds. + } else { + MeasureHunks (qh, editor, changedTextDocument, ref x, ref y); + } + qh.Enqueue (next); + + current = next; + } + if (qh.Count != 0) { + MeasureHunks (qh, editor, changedTextDocument, ref x, ref y); + } + requisition.Height = y; + requisition.Width = x + textBorder * 2; + } + + void MeasureHunks (Queue<DiffHunk> qh, IReadonlyTextDocument baseDocument, IReadonlyTextDocument changedDocument, ref int x, ref int y) + { + DiffHunk item; + int remStart; + int insStart; + int distance = 0; + do { + item = qh.Dequeue (); + remStart = System.Math.Max (1, item.RemoveStart - (distance != 0 ? distance : item.Context)); + insStart = System.Math.Max (1, item.InsertStart - (distance != 0 ? distance : item.Context)); + + for (int i = System.Math.Min (remStart, insStart); i < item.RemoveStart; i++) { + MeasureLine (editor, i, ref x, ref y); + } + + for (int i = item.RemoveStart; i < item.RemoveStart + item.Removed; i++) { + MeasureLine (editor, i, ref x, ref y); + } + + for (int i = item.InsertStart; i < item.InsertStart + item.Inserted; i++) { + MeasureLine ( changedDocument, i, ref x, ref y); + } + + if (qh.Count != 0) + distance = item.DistanceTo (qh.Peek ()); + } while (qh.Count != 0); + + int remEnd = System.Math.Min (baseDocument.LineCount, item.RemoveStart + item.Removed + item.Context); + for (int i = item.RemoveStart + item.Removed; i < remEnd; i++) { + MeasureLine (editor, i, ref x, ref y); + } + } + + void MeasureLine (IReadonlyTextDocument document, int lineNumber, ref int x, ref int y) + { + using (var drawingLayout = new Pango.Layout (this.PangoContext)) { + drawingLayout.FontDescription = fontDescription; + var line = document.GetLine (lineNumber); + var indent = line.GetIndentation (document); + var curLineIndent = CalcIndentLength(indent); + if (line.Length == curLineIndent) { + y += lineHeight; + return; + } + if (this.indentLength < 0 || this.indentLength > curLineIndent) + this.indentLength = curLineIndent; + drawingLayout.SetText (document.GetTextAt (line)); + int w, h; + drawingLayout.GetPixelSize (out w, out h); + x = Math.Max (x, w); + y += lineHeight; + } + } + + int CalcIndentLength (string indent) + { + int result = 0; + foreach (var ch in indent) { + if (ch == '\t') { + result = result - result % DefaultSourceEditorOptions.Instance.TabSize + DefaultSourceEditorOptions.Instance.TabSize; + } else { + result++; + } + } + return result; + } + + protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context g) + { + var style = editor.Options.GetColorStyle (); + g.Rectangle (0, 0, Allocation.Width, Allocation.Height); + g.SetSourceColor (style.PlainText.Background); + g.Fill (); + + int y = verticalTextSpace / 2; + + var qh = new Queue<DiffHunk> (); + var he = diff.GetEnumerator (); + he.MoveNext (); + var current = he.Current; + DiffHunk next; + qh.Enqueue (current); + while (he.MoveNext ()) { + next = he.Current; + + if (current.Overlaps (next)) { + // Change upper bounds. + } else { + WriteHunks (qh, editor, changedTextDocument, g, ref y); + } + qh.Enqueue (next); + + current = next; + } + if (qh.Count != 0) { + WriteHunks (qh, editor, changedTextDocument, g, ref y); + } + } + + void WriteHunks (Queue<DiffHunk> qh, IReadonlyTextDocument baseDocument, IReadonlyTextDocument changedDocument, Cairo.Context g, ref int y) + { + DiffHunk item; + int remStart; + int insStart; + int distance = 0; + + do { + item = qh.Dequeue (); + remStart = System.Math.Max (1, item.RemoveStart - (distance != 0 ? distance : item.Context)); + insStart = System.Math.Max (1, item.InsertStart - (distance != 0 ? distance : item.Context)); + + for (int i = System.Math.Min (remStart, insStart); i < item.RemoveStart; i++) { + DrawLine (g, editor, i, ref y); + } + + for (int i = item.RemoveStart; i < item.RemoveStart + item.Removed; i++) { + g.Rectangle (0, y, Allocation.Width, lineHeight); + g.SetSourceColor (editor.Options.GetColorStyle ().PreviewDiffRemoved.Background); + g.Fill (); + g.SetSourceColor (editor.Options.GetColorStyle ().PreviewDiffRemoved.Foreground); + DrawTextLine (g, editor, i, ref y); + } + + for (int i = item.InsertStart; i < item.InsertStart + item.Inserted; i++) { + g.Rectangle (0, y, Allocation.Width, lineHeight); + g.SetSourceColor (editor.Options.GetColorStyle ().PreviewDiffAddedd.Background); + g.Fill (); + g.SetSourceColor (editor.Options.GetColorStyle ().PreviewDiffAddedd.Foreground); + DrawTextLine (g, changedDocument, i, ref y); + } + + if (qh.Count != 0) + distance = item.DistanceTo (qh.Peek ()); + } while (qh.Count != 0); + + int remEnd = System.Math.Min (baseDocument.LineCount, item.RemoveStart + item.Removed + item.Context); + for (int i = item.RemoveStart + item.Removed; i < remEnd; i++) { + DrawLine (g, editor, i, ref y); + } + } + + int CorrectIndent (IReadonlyTextDocument document, IDocumentLine line, int indentLength) + { + int result = 0; + int o = line.Offset; + while (indentLength > 0) { + char ch = document [o + result]; + if (ch == '\t') { + indentLength = indentLength + indentLength % DefaultSourceEditorOptions.Instance.TabSize - DefaultSourceEditorOptions.Instance.TabSize; + } else if (ch == ' '){ + indentLength --; + } else { + break; + } + result++; + } + return result; + } + + void DrawLine (Cairo.Context g, TextEditor editor, int lineNumber, ref int y) + { + using (var drawingLayout = new Pango.Layout (this.PangoContext)) { + drawingLayout.FontDescription = fontDescription; + var line = editor.GetLine (lineNumber); + var correctedIndentLength = CorrectIndent (editor, line, indentLength); + drawingLayout.SetMarkup (editor.GetPangoMarkup (line.Offset + Math.Min (correctedIndentLength, line.Length), Math.Max (0, line.Length - correctedIndentLength))); + g.Save (); + g.Translate (textBorder, y); + g.ShowLayout (drawingLayout); + g.Restore (); + y += lineHeight; + } + } + + void DrawTextLine (Cairo.Context g, IReadonlyTextDocument document, int lineNumber, ref int y) + { + using (var drawingLayout = new Pango.Layout (this.PangoContext)) { + drawingLayout.FontDescription = fontDescription; + var line = document.GetLine (lineNumber); + var correctedIndentLength = CorrectIndent (document, line, indentLength); + drawingLayout.SetText (document.GetTextAt (line.Offset + Math.Min (correctedIndentLength, line.Length), Math.Max (0, line.Length - correctedIndentLength))); + g.Save (); + g.Translate (textBorder, y); + g.ShowLayout (drawingLayout); + g.Restore (); + y += lineHeight; + } + } + } +}
\ No newline at end of file diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs index e97a2dbd1b..ae9f1ec7c8 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring/RefactoringService.cs @@ -41,7 +41,7 @@ using MonoDevelop.Ide.TypeSystem; using System.Diagnostics; using MonoDevelop.Core.Instrumentation; using MonoDevelop.Ide.Editor; -using Microsoft.CodeAnalysis.Options;
+using Microsoft.CodeAnalysis.Options; using MonoDevelop.Ide; using MonoDevelop.Projects; using Microsoft.CodeAnalysis; @@ -308,4 +308,4 @@ namespace MonoDevelop.Refactoring return false; } } -}
\ No newline at end of file +} diff --git a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.addin.xml b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.addin.xml index 228bf1151f..ea6da8a825 100644 --- a/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.addin.xml +++ b/main/src/addins/MonoDevelop.RegexToolkit/MonoDevelop.RegexToolkit.addin.xml @@ -2,14 +2,14 @@ <!-- Extensions --> - <Extension path = "/MonoDevelop/Ide/Commands"> + <Extension path = "/MonoDevelop/Ide/Commands/Tools"> <Command id = "MonoDevelop.RegexToolkit.Commands.ShowRegexToolkit" defaultHandler = "MonoDevelop.RegexToolkit.ShowRegexToolkitHandler" - _label = "_Regex Toolkit..." /> + _label = "_Regular Expressions Toolkit" /> </Extension> <Extension path = "/MonoDevelop/Ide/MainMenu/Tools"> - <CommandItem id = "MonoDevelop.RegexToolkit.Commands.ShowRegexToolkit" insertbefore="OptionsSection" /> + <CommandItem id = "MonoDevelop.RegexToolkit.Commands.ShowRegexToolkit" insertafter= "ToolsSection" /> </Extension> </ExtensionModel> diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/CompletionOptionsPanel.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/CompletionOptionsPanel.cs index 86d2a271bc..1b93094ec8 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/CompletionOptionsPanel.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.OptionPanels/CompletionOptionsPanel.cs @@ -42,8 +42,8 @@ namespace MonoDevelop.SourceEditor.OptionPanels insertParenthesesCheckbutton.Toggled += InsertParensToggled; autoCodeCompletionCheckbutton.Toggled += AutomaticCompletionToggled; includeKeywordsCheckbutton.Visible = includeCodeSnippetsCheckbutton.Visible = false; + automaticCompletionModeCheckbutton.Sensitive = false; hbox4.Visible = hbox5.Visible = false; - } void InsertParensToggled (object sender, EventArgs e) @@ -63,6 +63,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels showImportsCheckbutton.Active = IdeApp.Preferences.AddImportedItemsToCompletionList; includeKeywordsCheckbutton.Active = IdeApp.Preferences.IncludeKeywordsInCompletionList; includeCodeSnippetsCheckbutton.Active = IdeApp.Preferences.IncludeCodeSnippetsInCompletionList; + automaticCompletionModeCheckbutton.Active = !IdeApp.Preferences.ForceSuggestionMode; insertParenthesesCheckbutton.Active = IdeApp.Preferences.AddParenthesesAfterCompletion; openingRadiobutton.Active = IdeApp.Preferences.AddOpeningOnly; @@ -76,6 +77,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels void AutomaticCompletionToggled (object sender, EventArgs e) { includeKeywordsCheckbutton.Sensitive = includeCodeSnippetsCheckbutton.Sensitive = !autoCodeCompletionCheckbutton.Active; + automaticCompletionModeCheckbutton.Sensitive = autoCodeCompletionCheckbutton.Active; } bool IOptionsPanel.IsVisible () @@ -94,6 +96,7 @@ namespace MonoDevelop.SourceEditor.OptionPanels IdeApp.Preferences.AddImportedItemsToCompletionList.Value = showImportsCheckbutton.Active; IdeApp.Preferences.IncludeKeywordsInCompletionList.Value = includeKeywordsCheckbutton.Active; IdeApp.Preferences.IncludeCodeSnippetsInCompletionList.Value = includeCodeSnippetsCheckbutton.Active; + IdeApp.Preferences.ForceSuggestionMode.Value = !automaticCompletionModeCheckbutton.Active; IdeApp.Preferences.AddParenthesesAfterCompletion.Value = insertParenthesesCheckbutton.Active; IdeApp.Preferences.AddOpeningOnly.Value = openingRadiobutton.Active; diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml index 112f02c8fb..051233bf04 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.addin.xml @@ -63,7 +63,7 @@ <Command id = "MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" _label = "Next Error" shortcut = "Alt|Shift|Page_Down" - macShortcut = "Alt|Shift|Page_Down" + macShortcut = "Alt|Shift|Page_Down Shift|Meta|F12" /> <Command id = "MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" _label = "Previous Error" @@ -73,7 +73,7 @@ </Category> </Extension> - <Extension path = "/MonoDevelop/Ide/Commands/TextEditor"> + <Extension path = "/MonoDevelop/Ide/Commands/Hidden"> <Command id = "MonoDevelop.SourceEditor.QuickTasks.ScrollbarCommand.Top" _label = "_Top"/> <Command id = "MonoDevelop.SourceEditor.QuickTasks.ScrollbarCommand.Bottom" @@ -82,6 +82,9 @@ _label = "_Page Up"/> <Command id = "MonoDevelop.SourceEditor.QuickTasks.ScrollbarCommand.PgDown" _label = "P_age Down"/> + </Extension> + + <Extension path = "/MonoDevelop/Ide/Commands/TextEditor"> <Command id = "MonoDevelop.SourceEditor.QuickTasks.ScrollbarCommand.ShowTasks" _label = "Show _Tasks" type="radio"/> @@ -106,7 +109,9 @@ <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.IndentSelection" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" /> <SeparatorItem id = "Separator4" /> - <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" /> + <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeSurroundingsWindow" _label = "Surround With..." /> + <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" _label = "Insert Template..." /> + <SeparatorItem id = "Separator5" /> </Extension> <Extension path = "/MonoDevelop/SourceEditor2/ContextMenu/Scrollbar"> @@ -152,10 +157,11 @@ <Extension path = "/MonoDevelop/Ide/MainMenu/Search"> <ItemSet id = "Inspect" _label = "Inspect" insertafter="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" insertbefore="Separator3"> - <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" /> - <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" /> - <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" /> <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" /> + <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" /> + <SeparatorItem id = "InspectIssueSeparator" /> + <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" /> + <CommandItem id = "MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" /> </ItemSet> </Extension> diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs index 22f824fa80..7b83c1a4a4 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs @@ -759,6 +759,18 @@ namespace MonoDevelop.SourceEditor RunAction (ScrollActions.PageDown); } + [CommandHandler (MonoDevelop.Ide.Commands.TextEditorCommands.ScrollTop)] + internal void OnScrollTop () + { + RunAction (ScrollActions.Top); + } + + [CommandHandler (MonoDevelop.Ide.Commands.TextEditorCommands.ScrollBottom)] + internal void OnScrollBottom () + { + RunAction (ScrollActions.Bottom); + } + [CommandHandler (MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace)] internal void OnGotoMatchingBrace () { diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs index 2819e612e9..c6c104e8cc 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs @@ -79,6 +79,8 @@ namespace MonoDevelop.SourceEditor DebugMarkerPair currentDebugLineMarker; DebugMarkerPair debugStackLineMarker; BreakpointStore breakpoints; + DebugIconMarker hoverDebugLineMarker; + static readonly Xwt.Drawing.Image hoverBreakpointIcon = Xwt.Drawing.Image.FromResource (typeof (BreakpointPad), "gutter-breakpoint-disabled-15.png"); List<DebugMarkerPair> breakpointSegments = new List<DebugMarkerPair> (); List<PinnedWatchInfo> pinnedWatches = new List<PinnedWatchInfo> (); bool writeAllowed; @@ -203,6 +205,8 @@ namespace MonoDevelop.SourceEditor widget.TextEditor.Caret.PositionChanged += HandlePositionChanged; widget.TextEditor.IconMargin.ButtonPressed += OnIconButtonPress; + widget.TextEditor.IconMargin.MouseMoved += OnIconMarginMouseMoved; + widget.TextEditor.IconMargin.MouseLeave += OnIconMarginMouseLeave; widget.TextEditor.TextArea.FocusOutEvent += TextArea_FocusOutEvent; ClipbardRingUpdated += UpdateClipboardRing; @@ -990,6 +994,8 @@ namespace MonoDevelop.SourceEditor widget.TextEditor.Document.EndUndo -= HandleEndUndo; widget.TextEditor.Caret.PositionChanged -= HandlePositionChanged; widget.TextEditor.IconMargin.ButtonPressed -= OnIconButtonPress; + widget.TextEditor.IconMargin.MouseMoved -= OnIconMarginMouseMoved; + widget.TextEditor.IconMargin.MouseLeave -= OnIconMarginMouseLeave; widget.TextEditor.Document.TextReplacing -= OnTextReplacing; widget.TextEditor.Document.TextReplaced -= OnTextReplaced; widget.TextEditor.Document.ReadOnlyCheckDelegate = null; @@ -1429,6 +1435,31 @@ namespace MonoDevelop.SourceEditor } } + void OnIconMarginMouseMoved (object sender, MarginMouseEventArgs e) + { + if (hoverDebugLineMarker != null) { + if (hoverDebugLineMarker.LineSegment.LineNumber != e.LineSegment.LineNumber) { + e.Editor.Document.RemoveMarker (hoverDebugLineMarker); + hoverDebugLineMarker = null; + } + } + + if (hoverDebugLineMarker == null && e.LineSegment?.Markers.FirstOrDefault (m => m is DebugIconMarker) == null) { + hoverDebugLineMarker = new DebugIconMarker (hoverBreakpointIcon) { + Tooltip = GettextCatalog.GetString ("Insert Breakpoint") + }; + e.Editor.Document.AddMarker (e.LineSegment.LineNumber, hoverDebugLineMarker); + } + } + + void OnIconMarginMouseLeave (object sender, EventArgs e) + { + if (hoverDebugLineMarker != null) { + Document.RemoveMarker (hoverDebugLineMarker); + hoverDebugLineMarker = null; + } + } + #region IEditableTextBuffer public bool EnableUndo { get { @@ -3068,13 +3099,13 @@ namespace MonoDevelop.SourceEditor int end = this.EndOffset; uint curIndex = 0, byteIndex = 0; - TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex); + TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)Math.Min (start - startOffset, metrics.Layout.LineChars.Length), ref curIndex, ref byteIndex); int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; fromX = startXPos + (int)(x_pos / Pango.Scale.PangoScale); - TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex); + TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)Math.Min (end - startOffset, metrics.Layout.LineChars.Length), ref curIndex, ref byteIndex); x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X; toX = startXPos + (int)(x_pos / Pango.Scale.PangoScale); @@ -3509,5 +3540,11 @@ namespace MonoDevelop.SourceEditor { FocusLost?.Invoke (this, EventArgs.Empty); } + + void ITextEditorImpl.GrabFocus () + { + this.TextEditor.GrabFocus (); + } + } } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextMarker/DebugTextMarker.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextMarker/DebugTextMarker.cs index 5fdd3251bc..8057bf99ec 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextMarker/DebugTextMarker.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextMarker/DebugTextMarker.cs @@ -42,6 +42,7 @@ namespace MonoDevelop.SourceEditor class DebugIconMarker : MarginMarker { Image DebugIcon { get; } + public string Tooltip { get; set; } public DebugIconMarker (Image debugIcon) { @@ -66,6 +67,21 @@ namespace MonoDevelop.SourceEditor cr.DrawImage (editor, DebugIcon, Math.Round (x + deltaX), Math.Round (y + deltaY)); } + + public override void InformMouseHover (MonoTextEditor editor, Margin margin, MarginMouseEventArgs args) + { + base.InformMouseHover (editor, margin, args); + if (!string.IsNullOrEmpty (Tooltip)) { + if (CanDrawForeground (margin)) + // update tooltip during the next ui loop run, + // otherwise Gtk will not update the position of the tooltip + Gtk.Application.Invoke (delegate { + args.Editor.TooltipText = Tooltip; + }); + else if (args.Editor.TooltipText == Tooltip) + args.Editor.TooltipText = null; + } + } } class DebugTextMarker : TextSegmentMarker, IChunkMarker diff --git a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel.cs b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel.cs index 2676db7750..c774ef94a0 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel.cs +++ b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel.cs @@ -12,6 +12,12 @@ namespace MonoDevelop.SourceEditor.OptionPanels private global::Gtk.CheckButton autoCodeCompletionCheckbutton; + private global::Gtk.HBox hbox6; + + private global::Gtk.Fixed fixed5; + + private global::Gtk.CheckButton automaticCompletionModeCheckbutton; + private global::Gtk.HBox hbox4; private global::Gtk.Fixed fixed3; @@ -40,185 +46,213 @@ namespace MonoDevelop.SourceEditor.OptionPanels private global::Gtk.RadioButton bothRadiobutton; - protected virtual void Build() + protected virtual void Build () { - global::Stetic.Gui.Initialize(this); + global::Stetic.Gui.Initialize (this); // Widget MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel - global::Stetic.BinContainer.Attach(this); + global::Stetic.BinContainer.Attach (this); this.Name = "MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel"; // Container child MonoDevelop.SourceEditor.OptionPanels.CompletionOptionsPanel.Gtk.Container+ContainerChild - this.vbox1 = new global::Gtk.VBox(); + this.vbox1 = new global::Gtk.VBox (); this.vbox1.Name = "vbox1"; this.vbox1.Spacing = 6; // Container child vbox1.Gtk.Box+BoxChild - this.alignment3 = new global::Gtk.Alignment(0.5F, 0.5F, 1F, 1F); + this.alignment3 = new global::Gtk.Alignment (0.5F, 0.5F, 1F, 1F); this.alignment3.Name = "alignment3"; this.alignment3.LeftPadding = ((uint)(12)); // Container child alignment3.Gtk.Container+ContainerChild - this.vbox5 = new global::Gtk.VBox(); + this.vbox5 = new global::Gtk.VBox (); this.vbox5.Name = "vbox5"; this.vbox5.Spacing = 6; // Container child vbox5.Gtk.Box+BoxChild - this.autoCodeCompletionCheckbutton = new global::Gtk.CheckButton(); + this.autoCodeCompletionCheckbutton = new global::Gtk.CheckButton (); + this.autoCodeCompletionCheckbutton.TooltipMarkup = "Automatic Completion with Enter or Tab keys"; this.autoCodeCompletionCheckbutton.CanFocus = true; this.autoCodeCompletionCheckbutton.Name = "autoCodeCompletionCheckbutton"; - this.autoCodeCompletionCheckbutton.Label = global::Mono.Unix.Catalog.GetString("_Show completion list after a character is typed"); + this.autoCodeCompletionCheckbutton.Label = global::Mono.Unix.Catalog.GetString ("_Show completion list after a character is typed"); this.autoCodeCompletionCheckbutton.DrawIndicator = true; this.autoCodeCompletionCheckbutton.UseUnderline = true; - this.vbox5.Add(this.autoCodeCompletionCheckbutton); - global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.autoCodeCompletionCheckbutton])); + this.vbox5.Add (this.autoCodeCompletionCheckbutton); + global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.autoCodeCompletionCheckbutton])); w1.Position = 0; w1.Expand = false; w1.Fill = false; // Container child vbox5.Gtk.Box+BoxChild - this.hbox4 = new global::Gtk.HBox(); + this.hbox6 = new global::Gtk.HBox (); + this.hbox6.Name = "hbox6"; + this.hbox6.Spacing = 6; + // Container child hbox6.Gtk.Box+BoxChild + this.fixed5 = new global::Gtk.Fixed (); + this.fixed5.Name = "fixed5"; + this.fixed5.HasWindow = false; + this.hbox6.Add (this.fixed5); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.fixed5])); + w2.Position = 0; + w2.Expand = false; + w2.Padding = ((uint)(6)); + // Container child hbox6.Gtk.Box+BoxChild + this.automaticCompletionModeCheckbutton = new global::Gtk.CheckButton (); + this.automaticCompletionModeCheckbutton.TooltipMarkup = "Enables automatic completion with the Space key or Punctation"; + this.automaticCompletionModeCheckbutton.CanFocus = true; + this.automaticCompletionModeCheckbutton.Name = "automaticCompletionModeCheckbutton"; + this.automaticCompletionModeCheckbutton.Label = global::Mono.Unix.Catalog.GetString ("Complete with Space or Punctation"); + this.automaticCompletionModeCheckbutton.DrawIndicator = true; + this.automaticCompletionModeCheckbutton.UseUnderline = true; + this.hbox6.Add (this.automaticCompletionModeCheckbutton); + global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox6 [this.automaticCompletionModeCheckbutton])); + w3.Position = 1; + this.vbox5.Add (this.hbox6); + global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.hbox6])); + w4.Position = 1; + w4.Expand = false; + w4.Fill = false; + // Container child vbox5.Gtk.Box+BoxChild + this.hbox4 = new global::Gtk.HBox (); this.hbox4.Name = "hbox4"; this.hbox4.Spacing = 6; // Container child hbox4.Gtk.Box+BoxChild - this.fixed3 = new global::Gtk.Fixed(); + this.fixed3 = new global::Gtk.Fixed (); this.fixed3.Name = "fixed3"; this.fixed3.HasWindow = false; - this.hbox4.Add(this.fixed3); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox4[this.fixed3])); - w2.Position = 0; - w2.Expand = false; - w2.Padding = ((uint)(6)); + this.hbox4.Add (this.fixed3); + global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.fixed3])); + w5.Position = 0; + w5.Expand = false; + w5.Padding = ((uint)(6)); // Container child hbox4.Gtk.Box+BoxChild - this.includeKeywordsCheckbutton = new global::Gtk.CheckButton(); + this.includeKeywordsCheckbutton = new global::Gtk.CheckButton (); this.includeKeywordsCheckbutton.CanFocus = true; this.includeKeywordsCheckbutton.Name = "includeKeywordsCheckbutton"; - this.includeKeywordsCheckbutton.Label = global::Mono.Unix.Catalog.GetString("Include _keywords in completion list"); + this.includeKeywordsCheckbutton.Label = global::Mono.Unix.Catalog.GetString ("Include _keywords in completion list"); this.includeKeywordsCheckbutton.DrawIndicator = true; this.includeKeywordsCheckbutton.UseUnderline = true; - this.hbox4.Add(this.includeKeywordsCheckbutton); - global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox4[this.includeKeywordsCheckbutton])); - w3.Position = 1; - this.vbox5.Add(this.hbox4); - global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox4])); - w4.Position = 1; - w4.Expand = false; - w4.Fill = false; + this.hbox4.Add (this.includeKeywordsCheckbutton); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox4 [this.includeKeywordsCheckbutton])); + w6.Position = 1; + this.vbox5.Add (this.hbox4); + global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.hbox4])); + w7.Position = 2; + w7.Expand = false; + w7.Fill = false; // Container child vbox5.Gtk.Box+BoxChild - this.hbox5 = new global::Gtk.HBox(); + this.hbox5 = new global::Gtk.HBox (); this.hbox5.Name = "hbox5"; this.hbox5.Spacing = 6; // Container child hbox5.Gtk.Box+BoxChild - this.fixed4 = new global::Gtk.Fixed(); + this.fixed4 = new global::Gtk.Fixed (); this.fixed4.Name = "fixed4"; this.fixed4.HasWindow = false; - this.hbox5.Add(this.fixed4); - global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.hbox5[this.fixed4])); - w5.Position = 0; - w5.Expand = false; - w5.Padding = ((uint)(6)); + this.hbox5.Add (this.fixed4); + global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.hbox5 [this.fixed4])); + w8.Position = 0; + w8.Expand = false; + w8.Padding = ((uint)(6)); // Container child hbox5.Gtk.Box+BoxChild - this.includeCodeSnippetsCheckbutton = new global::Gtk.CheckButton(); + this.includeCodeSnippetsCheckbutton = new global::Gtk.CheckButton (); this.includeCodeSnippetsCheckbutton.CanFocus = true; this.includeCodeSnippetsCheckbutton.Name = "includeCodeSnippetsCheckbutton"; - this.includeCodeSnippetsCheckbutton.Label = global::Mono.Unix.Catalog.GetString("Include _code snippets in completion list"); + this.includeCodeSnippetsCheckbutton.Label = global::Mono.Unix.Catalog.GetString ("Include _code snippets in completion list"); this.includeCodeSnippetsCheckbutton.DrawIndicator = true; this.includeCodeSnippetsCheckbutton.UseUnderline = true; - this.hbox5.Add(this.includeCodeSnippetsCheckbutton); - global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox5[this.includeCodeSnippetsCheckbutton])); - w6.Position = 1; - this.vbox5.Add(this.hbox5); - global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox5])); - w7.Position = 2; - w7.Expand = false; - w7.Fill = false; + this.hbox5.Add (this.includeCodeSnippetsCheckbutton); + global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.hbox5 [this.includeCodeSnippetsCheckbutton])); + w9.Position = 1; + this.vbox5.Add (this.hbox5); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.hbox5])); + w10.Position = 3; + w10.Expand = false; + w10.Fill = false; // Container child vbox5.Gtk.Box+BoxChild - this.showImportsCheckbutton = new global::Gtk.CheckButton(); + this.showImportsCheckbutton = new global::Gtk.CheckButton (); this.showImportsCheckbutton.CanFocus = true; this.showImportsCheckbutton.Name = "showImportsCheckbutton"; - this.showImportsCheckbutton.Label = global::Mono.Unix.Catalog.GetString("_Show import items"); + this.showImportsCheckbutton.Label = global::Mono.Unix.Catalog.GetString ("_Show import items"); this.showImportsCheckbutton.DrawIndicator = true; this.showImportsCheckbutton.UseUnderline = true; - this.vbox5.Add(this.showImportsCheckbutton); - global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.showImportsCheckbutton])); - w8.Position = 3; - w8.Expand = false; - w8.Fill = false; + this.vbox5.Add (this.showImportsCheckbutton); + global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.showImportsCheckbutton])); + w11.Position = 4; + w11.Expand = false; + w11.Fill = false; // Container child vbox5.Gtk.Box+BoxChild - this.insertParenthesesCheckbutton = new global::Gtk.CheckButton(); + this.insertParenthesesCheckbutton = new global::Gtk.CheckButton (); this.insertParenthesesCheckbutton.CanFocus = true; this.insertParenthesesCheckbutton.Name = "insertParenthesesCheckbutton"; - this.insertParenthesesCheckbutton.Label = global::Mono.Unix.Catalog.GetString("A_utomatically insert parentheses after completion:"); + this.insertParenthesesCheckbutton.Label = global::Mono.Unix.Catalog.GetString ("A_utomatically insert parentheses after completion:"); this.insertParenthesesCheckbutton.DrawIndicator = true; this.insertParenthesesCheckbutton.UseUnderline = true; - this.vbox5.Add(this.insertParenthesesCheckbutton); - global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.insertParenthesesCheckbutton])); - w9.Position = 4; - w9.Expand = false; - w9.Fill = false; + this.vbox5.Add (this.insertParenthesesCheckbutton); + global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.insertParenthesesCheckbutton])); + w12.Position = 5; + w12.Expand = false; + w12.Fill = false; // Container child vbox5.Gtk.Box+BoxChild - this.hbox2 = new global::Gtk.HBox(); + this.hbox2 = new global::Gtk.HBox (); this.hbox2.Name = "hbox2"; this.hbox2.Spacing = 6; // Container child hbox2.Gtk.Box+BoxChild - this.fixed1 = new global::Gtk.Fixed(); + this.fixed1 = new global::Gtk.Fixed (); this.fixed1.Name = "fixed1"; this.fixed1.HasWindow = false; - this.hbox2.Add(this.fixed1); - global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.fixed1])); - w10.Position = 0; - w10.Expand = false; - w10.Padding = ((uint)(6)); + this.hbox2.Add (this.fixed1); + global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.fixed1])); + w13.Position = 0; + w13.Expand = false; + w13.Padding = ((uint)(6)); // Container child hbox2.Gtk.Box+BoxChild - this.openingRadiobutton = new global::Gtk.RadioButton(global::Mono.Unix.Catalog.GetString("_Opening only")); + this.openingRadiobutton = new global::Gtk.RadioButton (global::Mono.Unix.Catalog.GetString ("_Opening only")); this.openingRadiobutton.CanFocus = true; this.openingRadiobutton.Name = "openingRadiobutton"; - this.openingRadiobutton.Active = true; this.openingRadiobutton.DrawIndicator = true; this.openingRadiobutton.UseUnderline = true; - this.openingRadiobutton.Group = new global::GLib.SList(global::System.IntPtr.Zero); - this.hbox2.Add(this.openingRadiobutton); - global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.openingRadiobutton])); - w11.Position = 1; - this.vbox5.Add(this.hbox2); - global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox2])); - w12.Position = 5; - w12.Expand = false; - w12.Fill = false; + this.openingRadiobutton.Group = new global::GLib.SList (global::System.IntPtr.Zero); + this.hbox2.Add (this.openingRadiobutton); + global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.openingRadiobutton])); + w14.Position = 1; + this.vbox5.Add (this.hbox2); + global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.hbox2])); + w15.Position = 6; + w15.Expand = false; + w15.Fill = false; // Container child vbox5.Gtk.Box+BoxChild - this.hbox3 = new global::Gtk.HBox(); + this.hbox3 = new global::Gtk.HBox (); this.hbox3.Name = "hbox3"; this.hbox3.Spacing = 6; // Container child hbox3.Gtk.Box+BoxChild - this.fixed2 = new global::Gtk.Fixed(); + this.fixed2 = new global::Gtk.Fixed (); this.fixed2.Name = "fixed2"; this.fixed2.HasWindow = false; - this.hbox3.Add(this.fixed2); - global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.fixed2])); - w13.Position = 0; - w13.Expand = false; - w13.Padding = ((uint)(6)); + this.hbox3.Add (this.fixed2); + global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.fixed2])); + w16.Position = 0; + w16.Expand = false; + w16.Padding = ((uint)(6)); // Container child hbox3.Gtk.Box+BoxChild - this.bothRadiobutton = new global::Gtk.RadioButton(global::Mono.Unix.Catalog.GetString("_Both opening and closing")); + this.bothRadiobutton = new global::Gtk.RadioButton (global::Mono.Unix.Catalog.GetString ("_Both opening and closing")); this.bothRadiobutton.CanFocus = true; this.bothRadiobutton.Name = "bothRadiobutton"; this.bothRadiobutton.DrawIndicator = true; this.bothRadiobutton.UseUnderline = true; this.bothRadiobutton.Group = this.openingRadiobutton.Group; - this.hbox3.Add(this.bothRadiobutton); - global::Gtk.Box.BoxChild w14 = ((global::Gtk.Box.BoxChild)(this.hbox3[this.bothRadiobutton])); - w14.Position = 1; - this.vbox5.Add(this.hbox3); - global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.vbox5[this.hbox3])); - w15.Position = 6; - w15.Expand = false; - w15.Fill = false; - this.alignment3.Add(this.vbox5); - this.vbox1.Add(this.alignment3); - global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox1[this.alignment3])); - w17.Position = 0; - w17.Expand = false; - w17.Fill = false; - this.Add(this.vbox1); - if ((this.Child != null)) - { - this.Child.ShowAll(); + this.hbox3.Add (this.bothRadiobutton); + global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.hbox3 [this.bothRadiobutton])); + w17.Position = 1; + this.vbox5.Add (this.hbox3); + global::Gtk.Box.BoxChild w18 = ((global::Gtk.Box.BoxChild)(this.vbox5 [this.hbox3])); + w18.Position = 7; + w18.Expand = false; + w18.Fill = false; + this.alignment3.Add (this.vbox5); + this.vbox1.Add (this.alignment3); + global::Gtk.Box.BoxChild w20 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.alignment3])); + w20.Position = 0; + w20.Expand = false; + w20.Fill = false; + this.Add (this.vbox1); + if ((this.Child != null)) { + this.Child.ShowAll (); } - this.Hide(); + this.Hide (); } } } diff --git a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic index 1146b7c21a..ca46c8b910 100644 --- a/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic +++ b/main/src/addins/MonoDevelop.SourceEditor2/gtk-gui/gui.stetic @@ -2156,6 +2156,7 @@ <child> <widget class="Gtk.CheckButton" id="autoCodeCompletionCheckbutton"> <property name="MemberName" /> + <property name="Tooltip" translatable="yes">Automatic Completion with Enter or Tab keys</property> <property name="CanFocus">True</property> <property name="Label" translatable="yes">_Show completion list after a character is typed</property> <property name="DrawIndicator">True</property> @@ -2170,6 +2171,45 @@ </packing> </child> <child> + <widget class="Gtk.HBox" id="hbox6"> + <property name="MemberName" /> + <property name="Spacing">6</property> + <child> + <widget class="Gtk.Fixed" id="fixed5"> + <property name="MemberName" /> + <property name="HasWindow">False</property> + </widget> + <packing> + <property name="Position">0</property> + <property name="AutoSize">False</property> + <property name="Expand">False</property> + <property name="Padding">6</property> + </packing> + </child> + <child> + <widget class="Gtk.CheckButton" id="automaticCompletionModeCheckbutton"> + <property name="MemberName" /> + <property name="Tooltip" translatable="yes">Enables automatic completion with the Space key or Punctation</property> + <property name="CanFocus">True</property> + <property name="Label" translatable="yes">Complete with Space or Punctation</property> + <property name="DrawIndicator">True</property> + <property name="HasLabel">True</property> + <property name="UseUnderline">True</property> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> <widget class="Gtk.HBox" id="hbox4"> <property name="MemberName" /> <property name="Spacing">6</property> @@ -2201,7 +2241,7 @@ </child> </widget> <packing> - <property name="Position">1</property> + <property name="Position">2</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> @@ -2239,7 +2279,7 @@ </child> </widget> <packing> - <property name="Position">2</property> + <property name="Position">3</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> @@ -2255,7 +2295,7 @@ <property name="UseUnderline">True</property> </widget> <packing> - <property name="Position">3</property> + <property name="Position">4</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> @@ -2271,7 +2311,7 @@ <property name="UseUnderline">True</property> </widget> <packing> - <property name="Position">4</property> + <property name="Position">5</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> @@ -2311,7 +2351,7 @@ </child> </widget> <packing> - <property name="Position">5</property> + <property name="Position">6</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> @@ -2350,7 +2390,7 @@ </child> </widget> <packing> - <property name="Position">6</property> + <property name="Position">7</property> <property name="AutoSize">True</property> <property name="Expand">False</property> <property name="Fill">False</property> diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitProjectTestSuite.cs b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitProjectTestSuite.cs index a14d2e4088..78595bc3e0 100644 --- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitProjectTestSuite.cs +++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/NUnitProjectTestSuite.cs @@ -95,7 +95,7 @@ namespace MonoDevelop.UnitTesting.NUnit public static NUnitVersion? GetNUnitVersion (ProjectReference p) { - if (p.Reference.IndexOf ("GuiUnit", StringComparison.OrdinalIgnoreCase) != -1 || p.Reference.IndexOf ("nunitlite", StringComparison.OrdinalIgnoreCase) != -1) + if (p.Reference.IndexOf ("GuiUnit", StringComparison.OrdinalIgnoreCase) != -1 || p.Reference.StartsWith ("nunitlite", StringComparison.OrdinalIgnoreCase)) return NUnitVersion.NUnit2; if (p.Reference.IndexOf ("nunit.framework", StringComparison.OrdinalIgnoreCase) != -1) { var selector = p.Project?.DefaultConfiguration.Selector; diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs index dd42c9e545..05705f8e80 100644 --- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs +++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs @@ -101,7 +101,7 @@ namespace MonoDevelop.UnitTesting.NUnit.External TestPackage package = new TestPackage (assemblyPath); package.Settings ["ShadowCopyFiles"] = false; - package.BasePath = basePath; + package.BasePath = Path.GetDirectoryName(assemblyPath); AppDomain domain = Services.DomainManager.CreateDomain (package); string asm = Path.Combine (basePath, "NUnitRunner.exe"); diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelopNUnit.addin.xml b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelopNUnit.addin.xml index 2e4df980c8..4bff618508 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelopNUnit.addin.xml +++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelopNUnit.addin.xml @@ -31,12 +31,12 @@ <!-- Extensions --> <Extension path = "/MonoDevelop/Ide/Pads"> - <SolutionPad id = "MonoDevelop.UnitTesting.TestPad" defaultLayout="*" defaultPlacement = "Right" defaultStatus="AutoHide" _label = "Unit Tests" icon = "nunit-pad-icon" class = "MonoDevelop.UnitTesting.TestPad"> + <SolutionPad id = "MonoDevelop.UnitTesting.TestPad" defaultLayout="*" defaultPlacement = "Right" defaultStatus="AutoHide" _label = "Unit Tests" icon = "nunit-pad-icon" class = "MonoDevelop.UnitTesting.TestPad" group="Unit Testing"> <PadOption id = "ShowTestTime" _label = "Show Test Time" defaultValue = "False" /> <PadOption id = "ShowTestCounters" _label = "Show Test Counters" defaultValue = "False" /> <NodeBuilder id = "TestNode" class = "MonoDevelop.UnitTesting.TestNodeBuilder"/> </SolutionPad> - <Pad id="MonoDevelop.UnitTesting.TestResultsPad" _label="Test Results" icon="nunit-pad-icon" class="MonoDevelop.UnitTesting.TestResultsPad" defaultPlacement = "Bottom" defaultLayout="UnitTesting" defaultStatus="AutoHide"/> + <Pad id="MonoDevelop.UnitTesting.TestResultsPad" _label="Test Results" icon="nunit-pad-icon" class="MonoDevelop.UnitTesting.TestResultsPad" defaultPlacement = "Bottom" defaultLayout="UnitTesting" defaultStatus="AutoHide" group="Unit Testing"/> </Extension> <Extension path="/MonoDevelop/Ide/WorkbenchLayouts"> diff --git a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs index 210c9d6aa1..0d01cb8abb 100644 --- a/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs +++ b/main/src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences.Commands/WebReferenceCommandHandler.cs @@ -88,7 +88,7 @@ namespace MonoDevelop.WebReferences.Commands return; try { updatingReferences = true; - using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetPluralString ("Updating web reference", "Updating web references", items.Count), MonoDevelop.Ide.Gui.Stock.PadDownload, true)) { + using (var monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetPluralString ("Updating web reference", "Updating web references", items.Count), MonoDevelop.Ide.Gui.Stock.StatusDownload, true)) { monitor.BeginTask (GettextCatalog.GetPluralString ("Updating web reference", "Updating web references", items.Count), items.Count); for (int i = 0; i < items.Count; i++) { diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj index 39a4ab53a3..e078d74d74 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix.csproj @@ -97,6 +97,11 @@ <Name>Mono.Addins</Name> <Private>False</Private> </ProjectReference> + <ProjectReference Include="..\..\..\core\MonoDevelop.Ide\MonoDevelop.Ide.csproj"> + <Project>{27096E7F-C91C-4AC6-B289-6897A701DF21}</Project> + <Name>MonoDevelop.Ide</Name> + <Private>False</Private> + </ProjectReference> </ItemGroup> <ItemGroup> <EmbeddedResource Include="MonoDevelop.VersionControl.Subversion.Unix.addin.xml"> diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs index 7f9cf78189..a53e6bb6f4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Unix/MonoDevelop.VersionControl.Subversion.Unix/SvnClient.cs @@ -13,6 +13,8 @@ using off_t = System.Int64; using MonoDevelop.Projects.Text; using System.Threading; using System.Linq; +using MonoDevelop.Ide; +using System.Diagnostics; namespace MonoDevelop.VersionControl.Subversion.Unix { @@ -114,6 +116,9 @@ namespace MonoDevelop.VersionControl.Subversion.Unix internal static bool CheckInstalled () { + if (IsDependentOnXcodeCLITools.Value) + return true; + // libsvn_client may be linked to libapr-0 or libapr-1, and we need to bind the LibApr class // to the same library. The following code detects the required libapr version and loads it. int aprver = GetLoadAprLib (-1); @@ -198,11 +203,49 @@ namespace MonoDevelop.VersionControl.Subversion.Unix return new UnixSvnBackend (); } + static bool FallbackProbeDirectoryDotSvn (FilePath path) + { + while (!path.IsNullOrEmpty) { + if (Directory.Exists (path.Combine (".svn"))) + return true; + path = path.ParentDirectory; + } + return false; + } + + const string commandLineToolsSvn = "/Library/Developer/CommandLineTools/usr/lib/libsvn_client-1.0.dylib"; + static Lazy<bool> IsDependentOnXcodeCLITools = new Lazy<bool> ( + () => Platform.IsMac && Environment.Is64BitOperatingSystem && !File.Exists (commandLineToolsSvn) + ); + + bool macDisabled; public override string GetDirectoryDotSvn (FilePath path) { + if (macDisabled) + return string.Empty; + if (path.IsNullOrEmpty) return string.Empty; + // For Mac 64bits, we need to have Xcode Command Line Tools installed. + if (IsDependentOnXcodeCLITools.Value) { + if (!FallbackProbeDirectoryDotSvn (path)) + return string.Empty; + + var button = new AlertButton (GettextCatalog.GetString ("Install")); + if (MessageService.AskQuestion ( + GettextCatalog.GetString ("This solution may be using Subversion. Do you want to install Xcode Command Line Tools now?"), + BrandingService.BrandApplicationName ( + GettextCatalog.GetString ("Xcode Command Line Tools are not currently installed, and are required to use Subversion.\nPlease restart MonoDevelop after the installation to enable Subversion support.")), + AlertButton.Cancel, + button) == button) { + var p = Process.Start ("xcode-select", "--install"); + p.WaitForExit (); + } + macDisabled = true; + return string.Empty; + } + if (Pre_1_7) return base.GetDirectoryDotSvn (path); diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs index 540252ad43..57d895c35b 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion/MonoDevelop.VersionControl.Subversion.Gui/WorkingCopyFormatDialog.cs @@ -57,7 +57,7 @@ namespace MonoDevelop.VersionControl.Subversion.Gui }; } - if (MessageDialog.AskQuestion (primary, secondary, commands) != DisableCommand) + if (MessageDialog.AskQuestion (primary, secondary, Xwt.Drawing.Image.FromResource ("question-48.png").WithSize (48), commands) != DisableCommand) action(); }; diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs index d90c3c3a45..caa1f72c96 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/DiffWidget.cs @@ -153,7 +153,38 @@ namespace MonoDevelop.VersionControl.Views return GettextCatalog.GetString ("(base)"); return string.Format (GettextCatalog.GetString ("(revision {0})"), rev.ToString ()); } - + + [Components.Commands.CommandUpdateHandler (Ide.Commands.ViewCommands.ShowNext)] + public void ShowNextUpdateHandler (Components.Commands.CommandInfo info) + { + if (!Visible) + info.Bypass = true; + else { + info.Text = GettextCatalog.GetString ("Show Next (Difference)"); + } + } + + [Components.Commands.CommandHandler (Ide.Commands.ViewCommands.ShowNext)] + public void ShowNextHandler () + { + ComparisonWidget.GotoNext (); + } + + [Components.Commands.CommandUpdateHandler (Ide.Commands.ViewCommands.ShowPrevious)] + public void ShowPreviousUpdateHandler (Components.Commands.CommandInfo info) + { + if (!Visible) + info.Bypass = true; + else { + info.Text = GettextCatalog.GetString ("Show Previous (Difference)"); + } + } + + [Components.Commands.CommandHandler (Ide.Commands.ViewCommands.ShowPrevious)] + public void ShowPreviousHandler () + { + ComparisonWidget.GotoPrev (); + } } } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs index fde7b394d2..b05f6ea56d 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl/VersionControlService.cs @@ -605,18 +605,31 @@ namespace MonoDevelop.VersionControl public static ProgressMonitor GetProgressMonitor (string operation, VersionControlOperationType op) { - IconId icon; + IconId padIcon, statusIcon; + bool cancellable; switch (op) { - case VersionControlOperationType.Pull: icon = Stock.PadDownload; break; - case VersionControlOperationType.Push: icon = Stock.PadUpload; break; - default: icon = "md-version-control"; break; - } - - ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ("MonoDevelop.VersionControlOutput", GettextCatalog.GetString ("Version Control"), "md-version-control", false, true); + case VersionControlOperationType.Pull: + padIcon = Stock.PadDownload; + statusIcon = Stock.StatusDownload; + cancellable = true; + break; + case VersionControlOperationType.Push: + padIcon = Stock.PadUpload; + statusIcon = Stock.StatusUpload; + cancellable = true; + break; + default: + padIcon = "md-version-control"; + statusIcon = "md-version-control"; + cancellable = false; + break; + } + + ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor ("MonoDevelop.VersionControlOutput", GettextCatalog.GetString ("Version Control"), padIcon, false, true); Pad outPad = IdeApp.Workbench.ProgressMonitors.GetPadForMonitor (monitor); AggregatedProgressMonitor mon = new AggregatedProgressMonitor (monitor); - mon.AddFollowerMonitor (IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (operation, icon, true, true, false, outPad)); + mon.AddFollowerMonitor (IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (operation, statusIcon, true, true, false, outPad, cancellable)); return mon; } diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml index ac436f5c45..11f861310e 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/VersionControl.addin.xml @@ -175,23 +175,25 @@ icon = "vc-diff" description = "Create a patch representing local changes."/> <Command id = "MonoDevelop.VersionControl.Commands.Ignore" - _label = "Add to ignore list" + _label = "Add to Ignore List" description = "Add items to version control ignore list"/> <Command id = "MonoDevelop.VersionControl.Commands.Unignore" - _label = "Remove from ignore list" + _label = "Remove from Ignore List" description = "Removes items to version control ignore list"/> <Command id = "MonoDevelop.VersionControl.Commands.ResolveConflicts" _label = "Resolve Conflicts" description = "Resolve conflicts on the project file."/> + </Category> + <Category id="Hidden" _name="Hidden"> <Command id = "MonoDevelop.VersionControl.Views.BlameCommands.CopyRevision" - _label = "_Copy revision"/> + _label = "_Copy Revision"/> <Command id = "MonoDevelop.VersionControl.Views.BlameCommands.ShowDiff" - _label = "_Show diff"/> + _label = "_Show Diff"/> <Command id = "MonoDevelop.VersionControl.Views.BlameCommands.ShowLog" - _label = "S_how log"/> + _label = "S_how Log"/> <Command id = "MonoDevelop.VersionControl.Views.BlameCommands.ShowBlameBefore" - _label = "Show _blame before"/> + _label = "Show _Blame Before"/> </Category> </Extension> diff --git a/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj b/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj index 1488859c6f..73aeab1951 100644 --- a/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj +++ b/main/src/addins/VersionControl/Subversion.Win32/VersionControl.Subversion.Win32.csproj @@ -92,13 +92,6 @@ </BootstrapperPackage> </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> - <Target Name="BeforeBuild"> - <PropertyGroup> - <NuGet>$(SolutionDir)\external\nuget-binary\NuGet.exe</NuGet> - <NuGet Condition="$(OS)=='Unix'">mono $(NuGet)</NuGet> - </PropertyGroup> - <Exec Command="$(NuGet) restore -SolutionDirectory $(SolutionDir)" /> - </Target> <ItemGroup> <ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj"> <Project>{7525BB88-6142-4A26-93B9-A30C6983390A}</Project> diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs index 652b78d1fe..15cf7cac7d 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/StatusBar.xaml.cs @@ -22,7 +22,8 @@ using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Windows.Media.Animation;
using MonoDevelop.Ide.Gui.Components;
-
+using System.Threading; + namespace WindowsPlatform.MainToolbar
{
public enum StatusBarStatus
@@ -305,8 +306,12 @@ namespace WindowsPlatform.MainToolbar {
get { return buildResultPanelVisibility; }
set { buildResultPanelVisibility = value; RaisePropertyChanged (); }
- }
-
+ } + + public void SetCancellationTokenSource (CancellationTokenSource source)
+ {
+ } + void RaisePropertyChanged ([CallerMemberName] string propName = null)
{
if (PropertyChanged != null)
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs index c579ab60f3..7730917f53 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/MainToolbar/TitleMenuItem.cs @@ -130,17 +130,18 @@ namespace WindowsPlatform.MainToolbar int count = 1;
int indexOfThis = parent.Items.IndexOf (this);
- foreach (var child in info.ArrayInfo) {
- Control toAdd;
- if (child.IsArraySeparator) {
- toAdd = new Separator ();
- } else {
- toAdd = new TitleMenuItem (manager, menuEntry, child, menu: menu);
+ if (info.ArrayInfo != null)
+ foreach (var child in info.ArrayInfo) {
+ Control toAdd;
+ if (child.IsArraySeparator) {
+ toAdd = new Separator ();
+ } else {
+ toAdd = new TitleMenuItem (manager, menuEntry, child, menu: menu);
+ }
+
+ toRemoveFromParent.Add (toAdd);
+ parent.Items.Insert (indexOfThis + (count++), toAdd);
}
-
- toRemoveFromParent.Add (toAdd);
- parent.Items.Insert (indexOfThis + (count++), toAdd);
- }
return;
}
}
diff --git a/main/src/addins/Xml/Editor/XmlEditorService.cs b/main/src/addins/Xml/Editor/XmlEditorService.cs index d0dd8584c1..b5fb77e7a5 100644 --- a/main/src/addins/Xml/Editor/XmlEditorService.cs +++ b/main/src/addins/Xml/Editor/XmlEditorService.cs @@ -46,7 +46,7 @@ namespace MonoDevelop.Xml.Editor static class XmlEditorService { #region Task management - public static void AddTask(string fileName, string message, int column, int line, TaskSeverity taskType) + public static void AddTask (string fileName, string message, int column, int line, TaskSeverity taskType, WorkspaceObject workspaceObject) { // HACK: Use a compiler error since we cannot add an error // task otherwise (task type property is read-only and @@ -60,6 +60,8 @@ namespace MonoDevelop.Xml.Editor //Task task = new Task(fileName, message, column, line); TaskListEntry task = new TaskListEntry (error); + task.WorkspaceObject = workspaceObject; + task.Owner = ActiveEditor; TaskService.Errors.Add(task); } #endregion @@ -200,7 +202,7 @@ namespace MonoDevelop.Xml.Editor /// <summary> /// Checks that the xml in this view is well-formed. /// </summary> - public static XmlDocument ValidateWellFormedness (ProgressMonitor monitor, string xml, string fileName) + public static XmlDocument ValidateWellFormedness (ProgressMonitor monitor, string xml, string fileName, WorkspaceObject workspaceObject) { monitor.BeginTask (GettextCatalog.GetString ("Validating XML..."), 1); bool error = false; @@ -211,7 +213,7 @@ namespace MonoDevelop.Xml.Editor doc.LoadXml (xml); } catch (XmlException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); error = true; } @@ -229,7 +231,7 @@ namespace MonoDevelop.Xml.Editor /// <summary> /// Validates the xml against known schemas. /// </summary> - public static XmlDocument ValidateXml (ProgressMonitor monitor, string xml, string fileName) + public static XmlDocument ValidateXml (ProgressMonitor monitor, string xml, string fileName, WorkspaceObject workspaceObject) { monitor.BeginTask (GettextCatalog.GetString ("Validating XML..."), 1); bool error = false; @@ -247,9 +249,9 @@ namespace MonoDevelop.Xml.Editor ValidationEventHandler validationHandler = delegate (object sender, System.Xml.Schema.ValidationEventArgs args) { if (args.Severity == XmlSeverityType.Warning) { monitor.Log.WriteLine (args.Message); - AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Warning); + AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber, TaskSeverity.Warning, workspaceObject); } else { - AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber,TaskSeverity.Error); + AddTask (fileName, args.Exception.Message, args.Exception.LinePosition, args.Exception.LineNumber, TaskSeverity.Error, workspaceObject); monitor.Log.WriteLine (args.Message); error = true; } @@ -267,12 +269,12 @@ namespace MonoDevelop.Xml.Editor } catch (XmlSchemaException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); error = true; } catch (XmlException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); error = true; } finally { @@ -295,7 +297,7 @@ namespace MonoDevelop.Xml.Editor /// <summary> /// Validates the schema. /// </summary> - public static XmlSchema ValidateSchema (ProgressMonitor monitor, string xml, string fileName) + public static XmlSchema ValidateSchema (ProgressMonitor monitor, string xml, string fileName, WorkspaceObject workspaceObject) { monitor.BeginTask (GettextCatalog.GetString ("Validating schema..."), 1); bool error = false; @@ -313,7 +315,7 @@ namespace MonoDevelop.Xml.Editor error = true; } AddTask (fileName, args.Message, args.Exception.LinePosition, args.Exception.LineNumber, - (args.Severity == XmlSeverityType.Warning)? TaskSeverity.Warning : TaskSeverity.Error); + (args.Severity == XmlSeverityType.Warning)? TaskSeverity.Warning : TaskSeverity.Error, workspaceObject); }; schema = XmlSchema.Read (xmlReader, callback); XmlSchemaSet sset = new XmlSchemaSet (); @@ -323,12 +325,12 @@ namespace MonoDevelop.Xml.Editor } catch (XmlSchemaException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); error = true; } catch (XmlException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); error = true; } @@ -343,7 +345,7 @@ namespace MonoDevelop.Xml.Editor return error? null: schema; } - public static XslCompiledTransform ValidateStylesheet (ProgressMonitor monitor, string xml, string fileName) + public static XslCompiledTransform ValidateStylesheet (ProgressMonitor monitor, string xml, string fileName, WorkspaceObject workspaceObject) { monitor.BeginTask (GettextCatalog.GetString ("Validating stylesheet..."), 1); bool error = true; @@ -357,15 +359,15 @@ namespace MonoDevelop.Xml.Editor error = false; } catch (XsltCompileException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); } catch (XsltException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); } catch (XmlException ex) { monitor.ReportError (ex.Message, ex); - AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber,TaskSeverity.Error); + AddTask (fileName, ex.Message, ex.LinePosition, ex.LineNumber, TaskSeverity.Error, workspaceObject); } if (error) { diff --git a/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs b/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs index 6551965815..58fe77e838 100644 --- a/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs +++ b/main/src/addins/Xml/Editor/XmlTextEditorExtension.cs @@ -29,6 +29,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Xml; using System.Xml.Schema; @@ -95,12 +96,24 @@ namespace MonoDevelop.Xml.Editor XmlSchemaManager.UserSchemaAdded -= UserSchemaAdded; XmlSchemaManager.UserSchemaRemoved -= UserSchemaRemoved; + ClearTasksForStandaloneXmlFile (); base.Dispose (); } } - + + void ClearTasksForStandaloneXmlFile () + { + var tasks = TaskService.Errors + .GetOwnerTasks (this) + .Where (t => t.WorkspaceObject == null) + .ToList (); + + if (tasks.Any ()) + TaskService.Errors.RemoveRange (tasks); + } + #region Code completion - + XmlElementPath GetElementPath () { return XmlElementPath.Resolve ( @@ -675,7 +688,7 @@ namespace MonoDevelop.Xml.Editor string xml = Editor.Text; using (ProgressMonitor monitor = XmlEditorService.GetMonitor ()) { - XmlDocument doc = XmlEditorService.ValidateWellFormedness (monitor, xml, FileName); + XmlDocument doc = XmlEditorService.ValidateWellFormedness (monitor, xml, FileName, DocumentContext.Project); if (doc == null) return; monitor.BeginTask (GettextCatalog.GetString ("Creating schema..."), 0); @@ -757,10 +770,9 @@ namespace MonoDevelop.Xml.Editor TaskService.Errors.Clear (); using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) { if (IsSchema) - XmlEditorService.ValidateSchema (monitor, Editor.Text, FileName); + XmlEditorService.ValidateSchema (monitor, Editor.Text, FileName, DocumentContext.Project); else - - XmlEditorService.ValidateXml (monitor, Editor.Text, FileName); + XmlEditorService.ValidateXml (monitor, Editor.Text, FileName, DocumentContext.Project); } } @@ -798,11 +810,11 @@ namespace MonoDevelop.Xml.Editor return; } System.Xml.Xsl.XslCompiledTransform xslt = - XmlEditorService.ValidateStylesheet (monitor, xsltContent, stylesheetFileName); + XmlEditorService.ValidateStylesheet (monitor, xsltContent, stylesheetFileName, DocumentContext.Project); if (xslt == null) return; - XmlDocument doc = XmlEditorService.ValidateXml (monitor, Editor.Text, FileName); + XmlDocument doc = XmlEditorService.ValidateXml (monitor, Editor.Text, FileName, DocumentContext.Project); if (doc == null) return; diff --git a/main/src/addins/Xml/Properties/MonoDevelop.XmlEditor.addin.xml b/main/src/addins/Xml/Properties/MonoDevelop.XmlEditor.addin.xml index 106cc52ce7..0d82726115 100644 --- a/main/src/addins/Xml/Properties/MonoDevelop.XmlEditor.addin.xml +++ b/main/src/addins/Xml/Properties/MonoDevelop.XmlEditor.addin.xml @@ -70,11 +70,13 @@ </Extension>
<!-- XML menu -->
- <Extension path = "/MonoDevelop/Ide/MainMenu/Tools">
- <ItemSet id = "XmlMenu" insertafter = "AddinManagerSeparator" _label = "_XML" >
+ <Extension path = "/MonoDevelop/Ide/MainMenu/Edit">
+ <ItemSet id = "XmlMenu" insertafter = "Insert" _label = "_XML" >
+ <CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.Validate" />
+ <SeparatorItem id = "Separator1" />
<CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.CreateSchema" />
<CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.GoToSchemaDefinition" />
- <CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.Validate" />
+ <SeparatorItem id = "Separator2" />
<CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.AssignStylesheet"/>
<CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.OpenStylesheet"/>
<CommandItem id = "MonoDevelop.Xml.Editor.XmlCommands.RunXslTransform"/>
diff --git a/main/src/addins/Xml/schemas/manifest.xsd b/main/src/addins/Xml/schemas/manifest.xsd index 060dbec5f5..19a1fcf8bb 100755 --- a/main/src/addins/Xml/schemas/manifest.xsd +++ b/main/src/addins/Xml/schemas/manifest.xsd @@ -39,7 +39,7 @@ <xs:element name="file" type="file" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:choice>
- <xs:attribute name="manifestVersion" type="xs:string" default="1.0" use="required"/>
+ <xs:attribute name="manifestVersion" type="xs:string" default="1.0"/>
</xs:complexType>
</xs:element>
@@ -185,7 +185,14 @@ <xs:complexType name="probing">
<xs:attribute name="privatePath" type="xs:string" use="required"/>
- </xs:complexType>
+ </xs:complexType> + + <xs:simpleType name="yesNoEnum"> + <xs:restriction base="xs:string"> + <xs:enumeration value="yes"/> + <xs:enumeration value="no"/> + </xs:restriction> + </xs:simpleType>
<xs:complexType name="publisherPolicy">
<xs:attribute name="apply" type="yesNoEnum" use="required"/>
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs index 58d93b729e..43312f2deb 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor.Highlighting/ColorScheme.cs @@ -562,9 +562,17 @@ namespace Mono.TextEditor.Highlighting public ChunkStyle DiffHeaderNew { get; private set; } public const string DiffLocationKey = "Diff Location"; - [ColorDescription(DiffLocationKey)] //not defined + [ColorDescription (DiffLocationKey)] //not defined public ChunkStyle DiffLocation { get; private set; } + public const string PreviewDiffRemovedKey = "Preview Diff Removed Line"; + [ColorDescription (PreviewDiffRemovedKey)] //not defined + public ChunkStyle PreviewDiffRemoved { get; private set; } + + public const string PreviewDiffAddeddKey = "Preview Diff Added Line"; + [ColorDescription (PreviewDiffAddeddKey)] //not defined + public ChunkStyle PreviewDiffAddedd { get; private set; } + public const string HtmlAttributeNameKey = "Html Attribute Name"; [ColorDescription(HtmlAttributeNameKey, VSSetting="HTML Attribute")] public ChunkStyle HtmlAttributeName { get; private set; } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/ScrollActions.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/ScrollActions.cs index ff33d46e09..f0002f0eb9 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/ScrollActions.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Actions/ScrollActions.cs @@ -58,6 +58,19 @@ namespace Mono.TextEditor if (data.Parent != null) data.Parent.SmoothScrollTo (newValue); } + + public static void Top (TextEditorData data) + { + if (data.Parent != null) + data.Parent.SmoothScrollTo (data.VAdjustment.Lower); + } + + public static void Bottom (TextEditorData data) + { + var newValue = System.Math.Max (data.VAdjustment.Lower, data.VAdjustment.Upper - data.VAdjustment.PageSize); + if (data.Parent != null) + data.Parent.SmoothScrollTo (newValue); + } } }
\ No newline at end of file diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs index 13d37ef823..f7c6e6c66d 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs @@ -226,6 +226,8 @@ namespace Mono.TextEditor return completeText; } set { + if (value == null) + value = ""; var args = new DocumentChangeEventArgs (0, Text, value); textSegmentMarkerTree.Clear (); OnTextReplacing (args); diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/IconMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/IconMargin.cs index f3ab923632..84d7ca406c 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/IconMargin.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/IconMargin.cs @@ -82,9 +82,12 @@ namespace Mono.TextEditor } } + Gdk.Cursor textLinkCursor = new Gdk.Cursor (Gdk.CursorType.Hand1); + internal protected override void MouseHover (MarginMouseEventArgs args) { base.MouseHover (args); + cursor = textLinkCursor; args.Editor.TooltipText = null; DocumentLine lineSegment = args.LineSegment; if (lineSegment != null) { @@ -96,6 +99,13 @@ namespace Mono.TextEditor } } + internal protected override void MouseLeft () + { + if (!string.IsNullOrEmpty (editor.TooltipText)) + editor.TooltipText = null; + base.MouseLeft (); + } + internal protected override void Draw (Cairo.Context ctx, Cairo.Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight) { bool backgroundIsDrawn = false; diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs index 269cfad5d3..6e9662cd94 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextArea.cs @@ -506,7 +506,10 @@ namespace Mono.TextEditor if (Caret.AutoScrollToCaret && HasFocus) ScrollToCaret (); - + + if (textViewMargin.HighlightCaretLine == true) + textViewMargin.HighlightCaretLine = false; + // Rectangle rectangle = textViewMargin.GetCaretRectangle (Caret.Mode); RequestResetCaretBlink (); @@ -2526,6 +2529,7 @@ namespace Mono.TextEditor public void StartCaretPulseAnimation () { StartAnimation (new CaretPulseAnimation (editor)); + textViewMargin.HighlightCaretLine = true; } SearchHighlightPopupWindow popupWindow = null; diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLineMarker.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLineMarker.cs index 0e87da7b3b..1322576b53 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLineMarker.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLineMarker.cs @@ -29,12 +29,12 @@ using Mono.TextEditor.Highlighting; namespace Mono.TextEditor { - public interface IExtendingTextLineMarker + public interface IExtendingTextLineMarker { double GetLineHeight (MonoTextEditor editor); void Draw (MonoTextEditor editor, Cairo.Context cr, int lineNr, Cairo.Rectangle lineArea); } - + public interface IActionTextLineMarker { /// <returns> @@ -45,13 +45,13 @@ namespace Mono.TextEditor void MouseHover (MonoTextEditor editor, MarginMouseEventArgs args, TextLineMarkerHoverResult result); } - - public class TextLineMarkerHoverResult + + public class TextLineMarkerHoverResult { bool isCursorSet; public bool HasCursor { - get { return isCursorSet;} + get { return isCursorSet; } } Gdk.Cursor cursor; @@ -66,11 +66,11 @@ namespace Mono.TextEditor } public string TooltipMarkup { get; set; } } - + [Flags] public enum TextLineMarkerFlags { - None = 0, + None = 0, DrawsSelection = 1 } @@ -106,7 +106,7 @@ namespace Mono.TextEditor public class TextLineMarker { DocumentLine lineSegment; - + public DocumentLine LineSegment { get { return lineSegment; @@ -115,7 +115,7 @@ namespace Mono.TextEditor lineSegment = value; } } - + public virtual TextLineMarkerFlags Flags { get; set; @@ -124,8 +124,8 @@ namespace Mono.TextEditor public object Tag { get; set; - } - + } + bool isVisible = true; public virtual bool IsVisible { get { return isVisible; } @@ -135,11 +135,11 @@ namespace Mono.TextEditor public TextLineMarker () { } - + public virtual void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics) { } - + public virtual ChunkStyle GetStyle (ChunkStyle baseStyle) { return baseStyle; diff --git a/main/src/core/Mono.Texteditor/Styles/DarkStyle.json b/main/src/core/Mono.Texteditor/Styles/DarkStyle.json index 2f3d61b77c..0624585cf9 100644 --- a/main/src/core/Mono.Texteditor/Styles/DarkStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/DarkStyle.json @@ -232,6 +232,9 @@ { "name": "Diff Header(New)", "fore": "chameleon1", "weight": "bold" }, { "name": "Diff Location", "fore": "chameleon1", "weight": "bold" }, + { "name": "Preview Diff Removed Line", "fore": "#5c2c2c", "back": "#dcb4b4" }, + { "name": "Preview Diff Added Line", "fore": "#235423", "back": "#a4d9a4" }, + { "name": "Css Comment", "fore": "aluminium4", "weight": "bold" }, { "name": "Css Property Name", "fore": "aluminium1", "weight": "bold" }, { "name": "Css Property Value", "fore": "butter2", "weight": "bold" }, diff --git a/main/src/core/Mono.Texteditor/Styles/GruvboxStyle.json b/main/src/core/Mono.Texteditor/Styles/GruvboxStyle.json index 5f530cbf8c..b5cb647654 100644 --- a/main/src/core/Mono.Texteditor/Styles/GruvboxStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/GruvboxStyle.json @@ -216,6 +216,9 @@ { "name": "Diff Header(New)", "fore": "#008000", "weight": "bold" }, { "name": "Diff Location", "fore": "#FB8B00", "weight": "bold" }, + { "name": "Preview Diff Removed Line", "fore": "#5c2c2c", "back": "#dcb4b4" }, + { "name": "Preview Diff Added Line", "fore": "#235423", "back": "#a4d9a4" }, + { "name": "Css Comment", "fore": "comment", "weight": "bold" }, { "name": "Css Property Name", "fore": "black", "weight": "bold" }, { "name": "Css Property Value", "fore": "bright-green", "weight": "bold" }, diff --git a/main/src/core/Mono.Texteditor/Styles/LightStyle.json b/main/src/core/Mono.Texteditor/Styles/LightStyle.json index 898e3defa7..03b3821244 100644 --- a/main/src/core/Mono.Texteditor/Styles/LightStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/LightStyle.json @@ -229,6 +229,9 @@ { "name": "Diff Header(New)", "fore": "skyblue2", "weight": "bold" }, { "name": "Diff Location", "fore": "plum2", "weight": "bold" }, + { "name": "Preview Diff Removed Line", "fore": "#a14d4d", "back": "#fcf8f8" }, + { "name": "Preview Diff Added Line", "fore": "#419b41", "back": "#edf8ed" }, + { "name": "Css Comment", "fore": "comment-gray", "weight": "bold" }, { "name": "Css Property Name", "fore": "text-black", "weight": "bold" }, { "name": "Css Property Value", "fore": "literal-orange", "weight": "bold" }, diff --git a/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json b/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json index 0df6f240ab..f5942a7459 100644 --- a/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/MonokaiStyle.json @@ -227,6 +227,9 @@ { "name": "Diff Header(New)", "fore": "#008000", "weight": "bold" }, { "name": "Diff Location", "fore": "#FB8B00", "weight": "bold" }, + { "name": "Preview Diff Removed Line", "fore": "#5c2c2c", "back": "#dcb4b4" }, + { "name": "Preview Diff Added Line", "fore": "#235423", "back": "#a4d9a4" }, + { "name": "Css Comment", "fore": "monokai-comment", "weight": "bold" }, { "name": "Css Property Name", "fore": "black", "weight": "bold" }, { "name": "Css Property Value", "fore": "monokai-string", "weight": "bold" }, diff --git a/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json b/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json index 8d807916e4..00338346c6 100644 --- a/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/NightshadeStyle.json @@ -240,6 +240,9 @@ { "name": "Diff Header(New)", "fore": "chameleon1", "weight": "bold" }, { "name": "Diff Location", "fore": "chameleon1", "weight": "bold" }, + { "name": "Preview Diff Removed Line", "fore": "#5c2c2c", "back": "#dcb4b4" }, + { "name": "Preview Diff Added Line", "fore": "#235423", "back": "#a4d9a4" }, + { "name": "Css Comment", "fore": "CommentVim", "weight": "bold" }, { "name": "Css Property Name", "fore": "NormalVim", "weight": "bold" }, { "name": "Css Property Value", "fore": "StringVim", "weight": "bold" }, diff --git a/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json b/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json index bca141ae50..8cf2b32553 100644 --- a/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json +++ b/main/src/core/Mono.Texteditor/Styles/OblivionStyle.json @@ -231,6 +231,9 @@ { "name": "Diff Header(New)", "fore": "chameleon1", "weight": "bold" }, { "name": "Diff Location", "fore": "chameleon1", "weight": "bold" }, + { "name": "Preview Diff Removed Line", "fore": "#5c2c2c", "back": "#dcb4b4" }, + { "name": "Preview Diff Added Line", "fore": "#235423", "back": "#a4d9a4" }, + { "name": "Css Comment", "fore": "aluminium4", "weight": "bold" }, { "name": "Css Property Name", "fore": "aluminium2", "weight": "bold" }, { "name": "Css Property Value", "fore": "butter2", "weight": "bold" }, diff --git a/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml b/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml index 24bf17ca41..08247ce88b 100644 --- a/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml +++ b/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml @@ -344,11 +344,15 @@ <Group color="User Field Declaration"/> <Group color="Plain Text" /> </Match> + + <Match expression="\b(Some|None)\b" ignorecase="False"> + <Group color="User Types(Enums)"/> + </Match> <Match expression="\b([A-Z][\w]+)\b" ignorecase="False"> <Group color="User Types"/> </Match> - + <Match expression="(:\s*)(['\w]+)\b"> <Group color="Plain Text"/> <Group color="User Types"/> diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProjectSystemFactory.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/BrandingCondition.cs index 5cca970fb0..1db5f5e3b8 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Tests/MonoDevelop.PackageManagement.Tests.Helpers/FakeProjectSystemFactory.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.AddIns/BrandingCondition.cs @@ -1,45 +1,48 @@ -//
-// FakeProjectSystemFactory.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 MonoDevelop.PackageManagement;
-using MonoDevelop.Projects;
-using NuGet;
-
-namespace MonoDevelop.PackageManagement.Tests.Helpers
-{
- public class FakeProjectSystemFactory : IMonoDevelopProjectSystemFactory
- {
- public FakeProjectSystem FakeProjectSystem = new FakeProjectSystem ();
-
- public IProjectSystem CreateProjectSystem (DotNetProject project)
- {
- return FakeProjectSystem;
- }
- }
-}
-
-
+// +// BrandingCondition.cs +// +// Author: +// Vsevolod Kukol <sevoku@xamarin.com> +// +// Copyright (c) 2016 Xamarin Inc +// +// 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 Mono.Addins; + +namespace MonoDevelop.Core.AddIns +{ + public class BrandingCondition: ConditionType + { + public override bool Evaluate (NodeElement conditionNode) + { + string appName = conditionNode.GetAttribute ("value"); + bool negate = false; + if (appName.StartsWith ("!", StringComparison.Ordinal)) { + appName = appName.Substring (1); + negate = true; + } + + bool result = BrandingService.ApplicationName.StartsWith (appName, StringComparison.OrdinalIgnoreCase); + + return negate ? !result : result; + } + } +} + diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs index c46e6dfb26..4a2ed19955 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/SystemAssemblyService.cs @@ -341,6 +341,8 @@ namespace MonoDevelop.Core.Assemblies //FIXME: the fallback is broken since multiple frameworks can have the same corlib public TargetFrameworkMoniker GetTargetFrameworkForAssembly (TargetRuntime tr, string file) { + if (!File.Exists (file)) + return TargetFrameworkMoniker.UNKNOWN; var universe = CreateClosedUniverse (); try { IKVM.Reflection.Assembly assembly = universe.LoadFile (file); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs index adec8d3baf..22a4e2f432 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs @@ -230,22 +230,6 @@ namespace MonoDevelop.Core.Assemblies /// </returns> public virtual Process ExecuteAssembly (ProcessStartInfo pinfo, TargetFramework fx) { - if (fx == null) { - TargetFrameworkMoniker fxId = Runtime.SystemAssemblyService.GetTargetFrameworkForAssembly (this, pinfo.FileName); - fx = Runtime.SystemAssemblyService.GetTargetFramework (fxId); - if (!IsInstalled (fx)) { - // Look for a compatible framework which is installed - foreach (TargetFramework f in Runtime.SystemAssemblyService.GetTargetFrameworks ()) { - if (IsInstalled (f) && f.CanReferenceAssembliesTargetingFramework (fx)) { - fx = f; - break; - } - } - } - if (!IsInstalled (fx)) - throw new InvalidOperationException (string.Format ("No compatible framework found for assembly '{0}' (required framework: {1})", pinfo.FileName, fxId)); - } - ConvertAssemblyProcessStartInfo (pinfo); return Process.Start (pinfo); } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml index d4796fe8cd..c575762361 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.addin.xml @@ -5,6 +5,7 @@ <ConditionType id="Platform" type="MonoDevelop.Core.AddIns.PlatformCondition" /> <ConditionType id="AssemblyInstalled" type="MonoDevelop.Core.AddIns.AssemblyInstalledCondition" /> <ConditionType id="MSBuildTargetIsAvailable" type="MonoDevelop.Projects.MSBuild.TargetsAvailableCondition" /> + <ConditionType id="Branding" type="MonoDevelop.Core.AddIns.BrandingCondition" /> <!-- Extension points --> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj index 236c9e206d..e025833a7f 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.csproj @@ -242,6 +242,7 @@ <Compile Include="MonoDevelop.Core.Logging\RemoteLogger.cs" /> <Compile Include="MonoDevelop.Core.Instrumentation\TimeCounter.cs" /> <Compile Include="MonoDevelop.Core.AddIns\PlatformCondition.cs" /> + <Compile Include="MonoDevelop.Core.AddIns\BrandingCondition.cs" /> <Compile Include="MonoDevelop.Core.Serialization\BinaryDataSerializer.cs" /> <Compile Include="MonoDevelop.Core.Execution\LocalConsole.cs" /> <Compile Include="MonoDevelop.Core\IconId.cs" /> diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Gettext.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Gettext.cs index e844ae12b3..4cdc8a9816 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Gettext.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Gettext.cs @@ -71,28 +71,27 @@ namespace MonoDevelop.Core string catalog = Environment.GetEnvironmentVariable ("MONODEVELOP_LOCALE_PATH");
// Set the user defined language
- string lang = Runtime.Preferences.UserInterfaceLanguage;
- if (!string.IsNullOrEmpty (lang)) {
- if (Platform.IsWindows) {
- string cultureLang;
- if (!localeToCulture.TryGetValue (lang, out cultureLang))
- cultureLang = lang.Replace("_", "-");
- CultureInfo ci = CultureInfo.GetCultureInfo(cultureLang);
- if (ci.IsNeutralCulture) {
- // We need a non-neutral culture
- foreach (CultureInfo c in CultureInfo.GetCultures (CultureTypes.AllCultures & ~CultureTypes.NeutralCultures))
- if (c.Parent != null && c.Parent.Name == ci.Name && c.LCID != LOCALE_CUSTOM_UNSPECIFIED) {
- ci = c;
- break;
- }
- }
- if (!ci.IsNeutralCulture) {
+ UILocale = Runtime.Preferences.UserInterfaceLanguage;
+ if (!string.IsNullOrEmpty (UILocale)) {
+ string cultureLang;
+ if (!localeToCulture.TryGetValue (UILocale, out cultureLang))
+ cultureLang = UILocale.Replace ("_", "-");
+ CultureInfo ci = CultureInfo.GetCultureInfo (cultureLang);
+ if (ci.IsNeutralCulture) {
+ // We need a non-neutral culture
+ foreach (CultureInfo c in CultureInfo.GetCultures (CultureTypes.AllCultures & ~CultureTypes.NeutralCultures))
+ if (c.Parent != null && c.Parent.Name == ci.Name && c.LCID != LOCALE_CUSTOM_UNSPECIFIED) {
+ ci = c;
+ break;
+ }
+ }
+ if (!ci.IsNeutralCulture) {
+ if (Platform.IsWindows)
SetThreadUILanguage (ci.LCID);
- mainThread.CurrentUICulture = ci;
- }
+ mainThread.CurrentUICulture = ci;
}
- else
- Environment.SetEnvironmentVariable ("LANGUAGE", lang);
+ if (!Platform.IsWindows)
+ Environment.SetEnvironmentVariable ("LANGUAGE", UILocale);
}
if (string.IsNullOrEmpty (catalog) || !Directory.Exists (catalog)) {
@@ -122,6 +121,8 @@ namespace MonoDevelop.Core }
}
+ public static string UILocale { get; private set; }
+
public static CultureInfo UICulture {
get { return mainThread.CurrentUICulture; }
}
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs index 5db30ff3e2..505f93a4f3 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs @@ -373,16 +373,9 @@ namespace MonoDevelop.Core return func (); } else { var ts = new TaskCompletionSource<T> (); - MainSynchronizationContext.Post (delegate { + MainSynchronizationContext.Post (async state => { try { - var t = func (); - t.ContinueWith (ta => { - try { - ts.SetResult (ta.Result); - } catch (Exception ex) { - ts.SetException (ex); - } - }); + ts.SetResult (await func ()); } catch (Exception ex) { ts.SetException (ex); } @@ -402,16 +395,10 @@ namespace MonoDevelop.Core return func (); } else { var ts = new TaskCompletionSource<int> (); - MainSynchronizationContext.Post (delegate { + MainSynchronizationContext.Post (async state => { try { - var t = func (); - t.ContinueWith (ta => { - try { - ts.SetResult (0); - } catch (Exception ex) { - ts.SetException (ex); - } - }); + await func (); + ts.SetResult (0); } catch (Exception ex) { ts.SetException (ex); } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs index e980e56fe2..3341684d1a 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/MSBuildEvaluationContext.cs @@ -428,7 +428,7 @@ namespace MonoDevelop.Projects.MSBuild return false; var member = ResolveMember (type, memberName, instance == null); - if (member.Length == 0) + if (member == null || member.Length == 0) return false; if (j < str.Length && str[j] == '(') { @@ -439,7 +439,7 @@ namespace MonoDevelop.Projects.MSBuild return false; // Find a method with a matching number of parameters - var method = FindBestOverload (member.OfType<MethodInfo> (), parameterValues); + var method = FindBestOverload (member.OfType<MethodBase> (), parameterValues); if (method == null) return false; @@ -552,11 +552,11 @@ namespace MonoDevelop.Projects.MSBuild return false; } - MethodInfo FindBestOverload (IEnumerable<MethodInfo> methods, object [] args) + MethodBase FindBestOverload (IEnumerable<MethodBase> methods, object [] args) { - MethodInfo methodWithParams = null; + MethodBase methodWithParams = null; - foreach (var m in methods.OfType<MethodInfo> ()) { + foreach (var m in methods) { var argInfo = m.GetParameters (); // Exclude methods which take a complex object as argument @@ -580,7 +580,7 @@ namespace MonoDevelop.Projects.MSBuild return pi.ParameterType.IsArray && pi.IsDefined (typeof (ParamArrayAttribute)); } - object ConvertArg (MethodInfo method, int argNum, object value, Type parameterType) + object ConvertArg (MethodBase method, int argNum, object value, Type parameterType) { var sval = value as string; if (sval == "null") @@ -640,6 +640,10 @@ namespace MonoDevelop.Projects.MSBuild MemberInfo[] ResolveMember (Type type, string memberName, bool isStatic) { + if (type == typeof (string) && memberName == "new") + memberName = "Copy"; + if (type.IsArray) + type = typeof (Array); var flags = isStatic ? BindingFlags.Static : BindingFlags.Instance; if (type != typeof (Microsoft.Build.Evaluation.IntrinsicFunctions)) { var t = supportedTypeMembers.FirstOrDefault (st => st.Item1 == type); @@ -654,6 +658,7 @@ namespace MonoDevelop.Projects.MSBuild } static Tuple<Type, string []> [] supportedTypeMembers = { + Tuple.Create (typeof(System.Array), (string[]) null), Tuple.Create (typeof(System.Byte), (string[]) null), Tuple.Create (typeof(System.Char), (string[]) null), Tuple.Create (typeof(System.Convert), (string[]) null), diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs index ea5dfd7104..bee8eabeee 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Policies/PolicyService.cs @@ -1241,7 +1241,7 @@ namespace MonoDevelop.Projects.Policies defaultPolicies = pset; } else { // if the policy file does not have a name, use the file name as one - if (!string.IsNullOrEmpty (pset.Name)) { + if (string.IsNullOrEmpty (pset.Name)) { pset.Name = file.FileNameWithoutExtension; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/AssemblyReference.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/AssemblyReference.cs index 78c5ebbd4f..32fd00e97c 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/AssemblyReference.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/AssemblyReference.cs @@ -59,7 +59,7 @@ namespace MonoDevelop.Projects /// </summary> public IEnumerable<string> EnumerateAliases () { - return Aliases.Split (',', ';').Where (a => !string.IsNullOrEmpty (a)); + return Aliases.Split (new [] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); } } }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs index 87221de9f5..6c49184761 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/CustomCommand.cs @@ -276,7 +276,7 @@ namespace MonoDevelop.Projects oper = context.ExecutionHandler.Execute (cmd, console); } else { if (externalConsole) { - console = context.ExternalConsoleFactory.CreateConsole (!pauseExternalConsole, monitor.CancellationToken); + console = ExternalConsoleFactory.Instance.CreateConsole (!pauseExternalConsole, monitor.CancellationToken); oper = Runtime.ProcessService.StartConsoleProcess (cmd.Command, cmd.Arguments, cmd.WorkingDirectory, console, null); } else { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs index fd533ee086..ce2a64e9e5 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs @@ -562,25 +562,23 @@ namespace MonoDevelop.Projects return evaluatedCompileItemsTask.Task.Result; } - var dependsList = coreCompileDependsOn.Split (new [] { ";" }, StringSplitOptions.RemoveEmptyEntries); - foreach (var dependTarget in dependsList) { - try { - // evaluate the Compile targets - var ctx = new TargetEvaluationContext (); - ctx.ItemsToEvaluate.Add ("Compile"); - - var evalResult = await this.RunTarget (monitor, dependTarget, configuration, ctx); - if (evalResult != null && !evalResult.BuildResult.HasErrors) { - var evalItems = evalResult - .Items - .Select (i => CreateProjectFile (i)) - .ToList (); - - result.AddRange (evalItems); - } - } catch (Exception ex) { - LoggingService.LogInternalError (string.Format ("Error running target {0}", dependTarget), ex); + var dependsList = string.Join (";", coreCompileDependsOn.Split (new [] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select (s => s.Trim ()).Where (s => s.Length > 0)); + try { + // evaluate the Compile targets + var ctx = new TargetEvaluationContext (); + ctx.ItemsToEvaluate.Add ("Compile"); + + var evalResult = await this.RunTarget (monitor, dependsList, configuration, ctx); + if (evalResult != null && !evalResult.BuildResult.HasErrors && evalResult.Items != null) { + var evalItems = evalResult + .Items + .Select (i => CreateProjectFile (i)) + .ToList (); + + result.AddRange (evalItems); } + } catch (Exception ex) { + LoggingService.LogInternalError (string.Format ("Error running target {0}", dependsList), ex); } evaluatedCompileItemsTask.SetResult (result.ToArray ()); } @@ -1128,8 +1126,14 @@ namespace MonoDevelop.Projects else builder.Lock (); + string [] targets; + if (target.IndexOf (';') != -1) + targets = target.Split (new [] { ';' }, StringSplitOptions.RemoveEmptyEntries); + else + targets = new string [] { target }; + try { - result = await builder.Run (configs, logWriter, MSBuildProjectService.DefaultMSBuildVerbosity, new [] { target }, evaluateItems, evaluateProperties, globalProperties, monitor.CancellationToken); + result = await builder.Run (configs, logWriter, MSBuildProjectService.DefaultMSBuildVerbosity, targets, evaluateItems, evaluateProperties, globalProperties, monitor.CancellationToken); } finally { builder.Unlock (); builder.ReleaseReference (); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs index c2c0344107..a4a234ccd5 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/ProjectExtension.cs @@ -119,7 +119,7 @@ namespace MonoDevelop.Projects internal protected virtual void OnReadProject (ProgressMonitor monitor, MSBuildProject msproject) { next.OnReadProject (monitor, msproject); - msproject.GetGlobalPropertyGroup ().ReadObjectProperties (this, GetType (), true); + msproject.EvaluatedProperties.ReadObjectProperties (this, GetType (), true); msproject.ReadExternalProjectProperties (this, GetType (), true); } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceObject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceObject.cs index 65cbfbc2b3..6b4a16a881 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceObject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceObject.cs @@ -380,8 +380,6 @@ namespace MonoDevelop.Projects var ext = node.CreateExtension (); if (ext.SupportsObject (this)) extensions.Add (ext); - else - ext.Dispose (); } } diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml index b256f81ff9..59f82bcc2c 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/Commands.addin.xml @@ -61,12 +61,13 @@ _label = "_Delete" _description = "Delete the selection" defaultHandler = "MonoDevelop.Ide.Commands.DefaultDeleteHandler" - icon = "gtk-delete" /> + icon = "gtk-delete" + macShortcut = "Meta+BackSpace" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.Rename" - _label = "Re_name" + _label = "Re_name..." _description = "Rename the selection" shortcut = "F2" - macShortcut = "Meta|R"/> + macShortcut = "Meta|R F2"/> <Command id = "MonoDevelop.Ide.Commands.EditCommands.Undo" _label = "_Undo" icon = "gtk-undo" @@ -104,23 +105,27 @@ <Command id = "MonoDevelop.Ide.Commands.EditCommands.IndentSelection" shortcut = "Control|Alt|End" _description = "Indent selected lines of code" - _label = "_Indent Selection" + _label = "_Indent" + _displayName = "Indent Selection" macShortcut = "Meta|]" icon = "gtk-indent" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" shortcut = "Control|Alt|Home" _description = "Unindent selected lines of code" macShortcut = "Meta|[" - _label = "_Unindent Selection" + _label = "_Unindent" + _displayName = "Unindent Selection" icon = "gtk-unindent" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" _description = "Convert the selected text to uppercase" - _label = "_Uppercase Selection" /> + _label = "Upper_case" + _displayName = "Uppercase Selection" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" _description = "Convert the selected text to lowercase" - _label = "_Lowercase Selection" /> + _label = "_Lowercase" + _displayName = "Lowercase Selection" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.RemoveTrailingWhiteSpaces" - description = "Remove trailing whitespace" + _description = "Remove trailing whitespace" _label = "_Remove Trailing Whitespace" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.JoinWithNextLine" shortcut = "Control|Shift|J" @@ -130,8 +135,9 @@ _description = "Sort the selected lines" _label = "_Sort Lines" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.InsertGuid" - _label = "_Insert Guid" - description = "Inserts a Guid at caret position"/> + _label = "_GUID (Globally Unique Identifier)" + _displayName = "Insert GUID (Globally Unique Identifier)" + _description = "Inserts a Guid at caret position"/> <Condition id="Platform" value="windows"> <Command id = "MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" defaultHandler = "MonoDevelop.Ide.Commands.MonodevelopPreferencesHandler" @@ -150,26 +156,30 @@ </Condition> <Command id = "MonoDevelop.Ide.Commands.EditCommands.DefaultPolicies" defaultHandler = "MonoDevelop.Ide.Commands.DefaultPoliciesHandler" - _label = "Custom Po_licies..." + _label = "Po_licies..." _description = "Edit custom sets of policies which can be applied to solutions" /> <Command id = "MonoDevelop.Ide.Commands.EditCommands.InsertStandardHeader" - _label = "_Insert Standard Header" + _label = "Standard _Header" + _displayName = "Insert Standard Header" defaultHandler = "MonoDevelop.Ide.Commands.InsertStandardHeaderHandler" _description = "Add the user defined header to the top of the file"/> + <Command id = "MonoDevelop.Ide.Commands.EditCommands.EnableDisableFolding" + _label = "Enable _Folding" + _displayName = "Enable/Disable Code Folding"/> <Command id = "MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" _label = "_Toggle Fold" shortcut = "Control|Shift|M" - macShortcut = "Alt|Meta|Left" + macShortcut = "Alt+Shift+Meta+Left" _description = "Toggles the folding at caret position."/> <Command id = "MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" _label = "Toggle _All Folds" shortcut = "Control|Shift|A" - macShortcut = "Alt|Shift|Meta|Right" + macShortcut = "Alt+Shift+Meta+Up" _description = "Toggles all the foldings in the document."/> <Command id = "MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" _label = "Toggle _Definitions" - macShortcut = "Alt|Shift|Meta|Left" + macShortcut = "Alt+Shift+Meta+Down" _description = "Toggles foldings of all method and property bodies."/> <Command id = "MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" @@ -252,14 +262,14 @@ defaultHandler = "MonoDevelop.Ide.Commands.BuildSolutionHandler" _label = "_Build All" shortcut = "F8" - macShortcut = "Meta|B" + macShortcut = "Meta|B F6" _description = "Build all projects of all solutions" icon = "md-build-combine" /> <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.Build" defaultHandler = "MonoDevelop.Ide.Commands.BuildHandler" _label = "Buil_d" shortcut = "F7" - macShortcut = "Meta|K" + macShortcut = "Meta|K Shift+F6" _description = "Build the current project" icon = "md-build-current-selected-project" /> <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" @@ -280,7 +290,7 @@ defaultHandler = "MonoDevelop.Ide.Commands.RunHandler" icon = "gtk-execute" shortcut = "Control|F5" - macShortcut = "Alt|Meta|Return" + macShortcut = "Alt|Meta|Return Control|F5" _description = "Start program without debugging" _label = "Start Without Debugging" /> <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.RunWithList" @@ -314,7 +324,7 @@ <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.Stop" defaultHandler = "MonoDevelop.Ide.Commands.StopHandler" icon = "gtk-stop" - macShortcut = "Shift|Meta|Return" + macShortcut = "Shift|Meta|Return Shift|F5" shortcut = "Shift|F5" _description = "Stop current build or application execution" _label = "_Stop" /> @@ -338,7 +348,7 @@ <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.ExportSolution" defaultHandler = "MonoDevelop.Ide.Commands.ExportSolutionHandler" _description = "Convert selected solution to another format" - _label = "Convert solution format..." /> + _label = "Convert Solution Format..." /> <Command id = "MonoDevelop.Ide.Commands.ProjectCommands.SelectActiveConfiguration" type = "radio|array" defaultHandler = "MonoDevelop.Ide.Commands.SelectActiveConfigurationHandler" @@ -374,7 +384,7 @@ icon = "gtk-open" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.NewFile" defaultHandler = "MonoDevelop.Ide.Commands.NewFileHandler" - _label = "_File..." + _label = "New _File..." shortcut = "Control|N" macShortcut = "Meta|N" _description = "Create a new file" @@ -394,14 +404,14 @@ _label = "Save A_ll" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.NewProject" defaultHandler = "MonoDevelop.Ide.Commands.NewProjectHandler" - _label = "_Solution..." + _label = "New _Solution..." icon = "md-new-solution" _description = "Create a new solution" macShortcut = "Meta|Shift|N" shortcut = "Control|Shift|N" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.NewWorkspace" defaultHandler = "MonoDevelop.Ide.Commands.NewWorkspaceHandler" - _label = "_Workspace..." + _label = "New _Workspace..." _description = "Create a new workspace" icon = "md-new-workspace" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.CloseFile" @@ -429,6 +439,7 @@ <Command id = "MonoDevelop.Ide.Commands.FileCommands.CloseWorkspaceItem" defaultHandler = "MonoDevelop.Ide.Commands.CloseWorkspaceHandler" _label = "C_lose" + _displayName = "Close Workspace Item" _description = "Close the active solution or workspace item" icon = "md-close-combine-icon" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.ReloadFile" @@ -461,8 +472,9 @@ <Command id = "MonoDevelop.Ide.Commands.FileCommands.ClearRecentFiles" defaultHandler = "MonoDevelop.Ide.Commands.ClearRecentFilesHandler" _label = "_Clear" + _displayName="Clear Recent Files" icon = "gtk-clear" - _description = "Clear recent files" /> + _description = "Clear recent files list" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.RecentProjectList" defaultHandler = "MonoDevelop.Ide.Commands.RecentProjectListHandler" type="array" @@ -470,8 +482,9 @@ <Command id = "MonoDevelop.Ide.Commands.FileCommands.ClearRecentProjects" defaultHandler = "MonoDevelop.Ide.Commands.ClearRecentProjectsHandler" _label = "_Clear" + _displayName="Clear Recent Solutions" icon = "gtk-clear" - _description = "Clear recent solutions" /> + _description = "Clear recent solutions list" /> <Command id = "MonoDevelop.Ide.Commands.FileCommands.Exit" defaultHandler = "MonoDevelop.Ide.Commands.ExitHandler" _label = "_Quit" @@ -518,9 +531,6 @@ defaultHandler = "MonoDevelop.Ide.Commands.CopyPathNameHandler" _description = "Copy the file path to the clipboard" _label = "C_opy File Path"/> - <Command id = "MonoDevelop.Ide.Commands.FileTabCommands.ToggleMaximize" - defaultHandler = "MonoDevelop.Ide.Commands.ToggleMaximizeHandler" - _label = "S_witch Maximized/Normal View"/> <Command id = "MonoDevelop.Ide.Commands.FileTabCommands.ReopenClosedTab" defaultHandler = "MonoDevelop.Ide.Commands.ReopenClosedTabHandler" _label = "Reopen Closed Tab" @@ -540,7 +550,7 @@ _label = "Layout List" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.NewLayout" defaultHandler = "MonoDevelop.Ide.Commands.NewLayoutHandler" - _label = "_New Layout..." + _label = "Save Curre_nt Layout..." icon = "gtk-add" _description = "Create new layout" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.DeleteCurrentLayout" @@ -558,7 +568,11 @@ defaultHandler = "MonoDevelop.Ide.Commands.FullScreenHandler" _label = "_Full Screen" icon = "gtk-fullscreen" - _description = "Set full screen mode" /> + _description = "Set full screen mode" + macShortcut="Control+Meta+F" /> + <Command id = "MonoDevelop.Ide.Commands.FileTabCommands.ToggleMaximize" + defaultHandler = "MonoDevelop.Ide.Commands.ToggleMaximizeHandler" + _label = "S_witch Maximized/Normal View"/> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.Open" _description = "Open selected document" _label = "_Open" /> @@ -579,13 +593,13 @@ defaultHandler = "MonoDevelop.Ide.Commands.ShowNextHandler" _label = "Show Next" _description = "Move cursor to next error or search match" - macShortcut = "Alt|Meta|Down" + macShortcut = "Alt|Meta|Down F8" shortcut = "F4" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" defaultHandler = "MonoDevelop.Ide.Commands.ShowPreviousHandler" _label = "Show Previous" _description = "Move cursor to previous error or search match" - macShortcut = "Alt|Meta|Up" + macShortcut = "Alt|Meta|Up Shift+F8" shortcut = "Shift|F4" /> <Command id = "MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" @@ -635,13 +649,15 @@ _description = "Resets zoom to default" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" defaultHandler = "MonoDevelop.Ide.Commands.SideBySideModeHandler" - _label = "2 Columns" + _label = "Two Columns" + _displayName = "Two Editor Columns" shortcut = "Control|Shift|2" macShortcut = "Alt|Meta|2" icon = "md-columns-two" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.SingleMode" defaultHandler = "MonoDevelop.Ide.Commands.SingleModeHandler" - _label = "1 Column" + _label = "One Column" + _displayName = "One Editor Column" shortcut = "Control|Shift|1" macShortcut = "Alt|Meta|1" icon = "md-columns-one" /> @@ -659,11 +675,14 @@ defaultHandler = "MonoDevelop.Ide.Commands.FocusCurrentDocumentHandler" _label = "_Focus Document" shortcut = "Alt|C" + macShortcut = "F7" _description = "Focus current document" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" defaultHandler = "MonoDevelop.Ide.Commands.CenterAndFocusCurrentDocumentHandler" - _label = "Center and F_ocus Document" - shortcut = "Alt|Shift|C" + _displayName = "Center and Focus Document" + _label = "_Cursor Position" + shortcut = "Control|L" + macShortcut = "Control|L" _description = "Focus and center current document" /> <Command id = "MonoDevelop.Ide.Commands.ViewCommands.ShowWelcomePage" defaultHandler = "MonoDevelop.Ide.WelcomePage.ShowWelcomePageHandler" @@ -683,6 +702,9 @@ defaultHandler = "MonoDevelop.Ide.Commands.ToolListHandler" type="array" _label = "Tool List" /> + <Command id = "MonoDevelop.Ide.Commands.ToolCommands.EditCustomTools" + defaultHandler = "MonoDevelop.Ide.Commands.EditCustomToolsHandler" + _label = "Edit Custom Tools..." /> <Command id = "MonoDevelop.Ide.Commands.ToolCommands.InstrumentationViewer" defaultHandler = "MonoDevelop.Ide.Commands.InstrumentationViewerHandler" @@ -707,14 +729,14 @@ icon = "gtk-go-forward" _description = "Show next document" shortcut = "Control|Page_Down" - macShortcut = "Meta|}" /> + macShortcut = "Meta|} Meta+F6" /> <Command id = "MonoDevelop.Ide.Commands.WindowCommands.PrevDocument" defaultHandler = "MonoDevelop.Ide.Commands.PrevDocumentHandler" _label = "_Previous Document" icon = "gtk-go-back" _description = "Show previous document" shortcut = "Control|Page_Up" - macShortcut = "Meta|{" /> + macShortcut = "Meta|{ Shift+Meta+F6" /> <Command id = "MonoDevelop.Ide.Commands.WindowCommands.OpenDocumentList" defaultHandler = "MonoDevelop.Ide.Commands.OpenDocumentListHandler" type="radio|array" @@ -768,13 +790,12 @@ _description = "Show tip of the day" /> <Command id = "MonoDevelop.Ide.Commands.HelpCommands.OpenLogDirectory" defaultHandler = "MonoDevelop.Ide.Commands.OpenLogDirectoryHandler" - _label = "Open Log Directory" + _label = "Reveal _Logs" icon = "md-open-folder" _description = "Opens the directory where the diagnostic logs are stored" /> <Command id = "MonoDevelop.Ide.Commands.HelpCommands.About" defaultHandler = "MonoDevelop.Ide.Commands.AboutHandler" _label = "_About" - icon = "md-about" _description = "Show about dialog" /> <Command id = "MonoDevelop.Ide.Updater.UpdateCommands.CheckForUpdates" defaultHandler = "MonoDevelop.Ide.Updater.CheckForUpdatesHandler" @@ -809,13 +830,13 @@ icon = "md-find-next" _description = "Search forwards for the same text" shortcut = "Control|G" - macShortcut = "Meta|G" /> + macShortcut = "Meta|G F3" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" _label = "Find _Previous" icon = "md-find-prev" _description = "Search backwards for the same text" shortcut = "Control|Shift|G" - macShortcut = "Meta|Shift|G" /> + macShortcut = "Meta|Shift|G Shift|F3" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.EmacsFindNext" _label = "Find _Next (Emacs behavior)" @@ -827,14 +848,15 @@ _description = "Search backwards for the same text with emacs behavior"/> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.FindNextSelection" - _label = "Find Next Selection" + _label = "Find Next Like Selection" _description = "Search forwards for the selected text" shortcut = "Control|F3" - macShortcut = "Meta|E" /> + macShortcut = "Meta|E Meta|F3" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.FindPreviousSelection" - _label = "Find _Previous Selection" + _label = "Find Previous Like Selection" _description = "Search backwards for the selected text" - shortcut = "Shift|Control|F3" /> + shortcut = "Shift|Control|F3" + macShortcut = "Shift|Meta|F3" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" defaultHandler = "MonoDevelop.Ide.FindInFiles.FindInFilesHandler" @@ -851,13 +873,15 @@ <Command id = "MonoDevelop.Ide.Commands.SearchCommands.GotoType" defaultHandler = "MonoDevelop.Components.MainToolbar.GotoTypeHandler" - _label = "Go to Type..." + _label = "_Type..." + _displayName = "Go to Type..." _description = "Jump to the declaration of type in the current workspace" shortcut = "Control|Shift|T" macShortcut = "Meta|Shift|T" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.GotoFile" defaultHandler = "MonoDevelop.Components.MainToolbar.GotoFileHandler" - _label = "Go to File..." + _label = "_File..." + _displayName = "Go to File..." shortcut = "Alt|Shift|O" macShortcut = "Meta|Shift|D" _description = "Jump to a file in the current workspace" /> @@ -877,27 +901,30 @@ icon = "md-bookmark-prev" shortcut = "Shift|F2" _description = "Go to previous bookmark" - _label = "Pre_vious Bookmark" /> + _label = "Pre_vious" + _displayName = "Go to Previous Bookmark" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.NextBookmark" icon = "md-bookmark-next" shortcut = "F2" _description = "Go to next bookmark" - _label = "Ne_xt Bookmark" /> + _label = "Ne_xt" + _displayName = "Go to Next Bookmark" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.ClearBookmarks" icon = "md-bookmark-clear-all" _description = "Clear bookmarks" _label = "_Clear Bookmarks" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" - _label = "_Go to Line..." + _label = "_Line..." + _displayName = "Go to Line..." icon = "md-go-to-line" _description = "Go to a specific line" shortcut = "Control|I" macShortcut = "Meta|L" /> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.UseSelectionForFind" - _label = "Use Selection for Find" + _label = "Find Like Selection" _description = "Uses the current selection as find string"/> <Command id = "MonoDevelop.Ide.Commands.SearchCommands.UseSelectionForReplace" - _label = "Use Selection for Replace" + _label = "Replace Like Selection" _description = "Uses the current selection as replace string"/> </Category> @@ -907,35 +934,40 @@ <Category _name = "Text Editor" id = "TextEditor"> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" - _label = "Show Completion Window" + _label = "Show Code Completion" macShortcut="Control|space" shortcut = "Control|space" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ToggleCompletionSuggestionMode" defaultHandler = "MonoDevelop.Ide.Commands.ToggleCompletionSuggestionModeHandler" _label = "Toggle Completion Suggestion Mode" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" - _description="Inserts a template or when something is selected surrounds selection with a template" - _label = "I_nsert Template..."/> + _description="Inserts a template" + _label = "_Template..." + _displayName = "Insert Template..."/> + <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeSurroundingsWindow" + _description="Surrounds selection with a template when something is selected" + _label = "_Surround With..." + _displayName = "Surround Selection With..."/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd" - _label = "Go to end of line" macShortcut = "Meta+Right"/> + _label = "Go to end of line" macShortcut = "Meta+Right Control+E"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.LineStart" - _label = "Go to beginning of line" macShortcut = "Meta+Left"/> + _label = "Go to beginning of line" macShortcut = "Meta+Left Control+A"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar" - _label = "Delete left character" /> + _label = "Delete left character" macShortcut="Control+H" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar" - _label = "Delete right character" /> + _label = "Delete right character" macShortcut="Control+D" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft" - _label = "Go left one character" /> + _label = "Go left one character" macShortcut="Control+B" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.CharRight" - _label = "Go right one character" /> + _label = "Go right one character" macShortcut="Control+F" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.LineUp" - _label = "Go to previous line" /> + _label = "Go to previous line" macShortcut="Control+P" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.LineDown" - _label = "Go to next line" /> + _label = "Go to next line" macShortcut="Control+N" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart" - _label = "Go to beginning of document" /> + _label = "Go to beginning of document" macShortcut="Meta+Up" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd" - _label = "Go to end of document" /> + _label = "Go to end of document" macShortcut="Meta+Down" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.PageUp" _label = "Go up one page" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.PageDown" @@ -947,9 +979,13 @@ _label = "Scroll line down" shortcut = "Control|Down" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageUp" - _label = "Scroll page up"/> + _label = "Scroll page up" macShortcut="Page_Up" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageDown" - _label = "Scroll page down"/> + _label = "Scroll page down" macShortcut="Page_Down"/> + <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ScrollTop" + _label = "Scroll to top"/> + <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ScrollBottom" + _label = "Scroll to bottom"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine" _label = "Delete entire line" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineStart" @@ -972,22 +1008,24 @@ macShortcut = "Control|Shift|space" shortcut = "Control|Shift|space" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" - _label = "Go to Matching _Brace" + _label = "Matching _Brace" + _displayName = "Go to Matching Brace" icon = "md-go-to-matching-brace" - description = "Go to Matching Brace" - shortcut = "Control|B" /> + _description = "Go to Matching Brace" + shortcut = "Control|B" + macShortcut = "Shift+Meta+\" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveLeft" - _label = "Expand selection to the left" /> + _label = "Expand selection to the left" macShortcut="Shift+Left" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveRight" - _label = "Expand selection to the right" /> + _label = "Expand selection to the right" macShortcut="Shift+Right" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevWord" - _label = "Go to previous word" /> + _label = "Go to previous word" macShortcut="Alt+Left" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextWord" - _label = "Go to next word" /> + _label = "Go to next word" macShortcut="Alt+Right" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevWord" - _label = "Expand selection to previous word" /> + _label = "Expand selection to previous word" macShortcut="Alt+Shift+Left" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextWord" - _label = "Expand selection to next word" /> + _label = "Expand selection to next word" macShortcut="Alt+Shift+Right" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevSubword" _label = "Go to previous subword" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextSubword" @@ -997,17 +1035,17 @@ <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextSubword" _label = "Expand selection to next subword" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveUp" - _label = "Expand selection to previous line" /> + _label = "Expand selection to previous line" macShortcut="Shift+Up" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveDown" - _label = "Expand selection to next line" /> + _label = "Expand selection to next line" macShortcut="Shift+Down" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveHome" - _label = "Expand selection to line start" macShortcut = "Shift|Home" /> + _label = "Expand selection to line start" macShortcut = "Shift|Home Shift+Meta+Left" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveEnd" - _label = "Expand selection to line end" macShortcut = "Shift|End"/> + _label = "Expand selection to line end" macShortcut = "Shift|End Shift+Meta+Right"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentStart" - _label = "Expand selection to document start" /> + _label = "Expand selection to document start" macShortcut="Shift+Meta+Up Shift+Meta+Home" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentEnd" - _label = "Expand selection to document end" /> + _label = "Expand selection to document end" macShortcut="Shift+Meta+Down Shift+Meta+End" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ExpandSelectionToLine" _label = "Expand selection to line" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ExpandSelection" @@ -1016,7 +1054,7 @@ _label = "_Expand selection" shortcut = "Alt|Shift|Down" macShortcut = "Alt|Shift|Down"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SwitchCaretMode" _label = "Switch caret mode" - description = "Switch between insert and overwrite caret modes"/> + _description = "Switch between insert and overwrite caret modes"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.InsertTab" _label = "Insert tab" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.RemoveTab" @@ -1027,30 +1065,33 @@ _label = "Insert line break after the caret" macShortcut = "Control|O" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLineAtEnd" - _label = "Move caret to EOL and insert new line" /> + _label = "Move caret to EOL and insert new line" + macShortcut="Shift+Return" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.CompleteStatement" - _label = "Completes the current statement" + _label = "Complete current statement" + _description = "Completes the current statement" shortcut = "Control|Shift|Return" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevWord" - _label = "Delete previous word" /> + _label = "Delete previous word" macShortcut="Alt+BackSpace" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextWord" - _label = "Delete next word" /> + _label = "Delete next word" macShortcut="Alt+Delete" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevSubword" - _label = "Delete previous subword" /> + _label = "Delete previous subword" macShortcut="Control+BackSpace" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextSubword" - _label = "Delete next subword" /> + _label = "Delete next subword" macShortcut="Control+Delete" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageDownAction" - _label = "Expand selection to page down" /> + _label = "Expand selection to page down" macShortcut="Shift+Page_Down" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageUpAction" - _label = "Expand selection to page up" /> + _label = "Expand selection to page up" macShortcut="Shift+Page_Up" /> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.TransposeCharacters" _label = "Transpose characters" _description = "Swaps the characters on either side of the caret" macShortcut="Control|T" /> - <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.RecenterEditor" + <!-- This is a duplicate of CenterAndFocusCurrentDocument but doesn't use ITextEditorImpl --> + <!--<Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.RecenterEditor" _label = "Recenter editor" _description = "Scrolls the editor so that the caret is centered" - macShortcut = "Control|L" /> + macShortcut = "Control|L" />--> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.ToggleBlockSelectionMode" _label = "Toggle Block Selection Mode"/> <Command id = "MonoDevelop.Ide.Commands.TextEditorCommands.DuplicateLine" @@ -1068,15 +1109,20 @@ macShortcut = "Meta||" /> <Command id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.Toggle" - _label = "Toggle message bubble" - _description = "Toggles message bubble on/off"/> + disabledVisible = "false" + _label = "Hide Current Message" + _displayName = "Show/Hide current Inline Message" + _description = "Toggles the visibility of the current Inline Message"/> <Command id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.HideIssues" defaultHandler = "MonoDevelop.Ide.Editor.HideIssuesHandler" - _label = "_Hide Issues"/> + _label = "_None" + _displayName = "Show/Hide Inline Messages" + _description = "Toggles the visibility of Inline Messages" + type="radio"/> <Command id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.ToggleIssues" defaultHandler = "MonoDevelop.Ide.Editor.ToggleIssuesHandler" _label = "Toggle Issues" - type="array"/> + type="radio|array"/> </Category> </Extension> </ExtensionModel> diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/MainMenu.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/MainMenu.addin.xml index 9383f6237a..12e9f5aeee 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/MainMenu.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/MainMenu.addin.xml @@ -17,34 +17,32 @@ <Extension path = "/MonoDevelop/Ide/MainMenu"> <ItemSet id = "File" _label = "_File"> - <ItemSet id = "New" _label = "_New"> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.NewFile" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.NewProject" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.NewWorkspace" /> - </ItemSet> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.NewFile" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.NewProject" /> + <SeparatorItem id = "NewSep" /> <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.OpenFile" /> - <SeparatorItem id = "OpenSep" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.Save" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.SaveAs" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.SaveAll" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.ReloadFile" /> - <SeparatorItem id = "SaveSeparator" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.PrintPageSetup" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.PrintPreviewDocument" /> - <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.PrintDocument" /> - <SeparatorItem id = "RecentSeparator" /> + <ItemSet id = "RecentFiles" _label = "Recent _Files"> <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.RecentFileList" /> <SeparatorItem id = "RecentFilesSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.ClearRecentFiles" /> </ItemSet> - <ItemSet id = "RecentProjects" _label = "Recent Solu_tions"> <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.RecentProjectList" /> <SeparatorItem id = "RecentProjectsSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.ClearRecentProjects" /> </ItemSet> + <SeparatorItem id = "RecentSeparator" /> + + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.Save" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.SaveAs" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.SaveAll" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.ReloadFile" /> + <SeparatorItem id = "SaveSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.PrintPageSetup" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.PrintPreviewDocument" /> + <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.PrintDocument" /> <SeparatorItem id = "ExitSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.FileCommands.CloseWorkspace" /> @@ -63,42 +61,40 @@ <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Copy" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Paste" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Delete" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.Rename" /> <SeparatorItem id = "Separator2" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.SelectAll" /> + <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeSurroundingsWindow" /> <SeparatorItem id = "Separator4" /> <ItemSet id = "Format" _label = "_Format"> <CommandItem id = "MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" /> - <SeparatorItem id ="FormatSeparator" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" /> - <SeparatorItem id = "Separator1" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" /> + <SeparatorItem id ="FormatSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.IndentSelection" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.RemoveTrailingWhiteSpaces" /> + <SeparatorItem id = "Separator1" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" /> <SeparatorItem id = "Separator2" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" /> + <SeparatorItem id = "Separator3" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.JoinWithNextLine" /> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.SortSelectedLines" /> - </ItemSet> - - <ItemSet id = "Folding" _label = "F_olding"> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" /> + <SeparatorItem id = "Separator4" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.RemoveTrailingWhiteSpaces" /> </ItemSet> + <ItemSet id = "Insert" _label = "_Insert"> + <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.InsertStandardHeader" /> + <SeparatorItem id = "InsertSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.InsertGuid" /> + </ItemSet> + <SeparatorItem id = "Separator5" /> <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" /> - <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ToggleCompletionSuggestionMode" /> - <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowParameterCompletionWindow" /> - <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" /> - <SeparatorItem id = "Separator5" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.InsertStandardHeader" /> - <SeparatorItem id = "Separator6" /> - <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.ToggleBlockSelectionMode" /> <SeparatorItem id = "optionssep5" /> <Condition id="Platform" value="linux"> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" /> @@ -107,75 +103,89 @@ </ItemSet> <ItemSet id = "View" _label = "_View"> + <SeparatorItem _label = "Layout"/> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.LayoutList" /> <SeparatorItem id = "ViewSeparator1" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ViewList" /> + <SeparatorItem id = "ViewSeparator2" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.NewLayout" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.DeleteCurrentLayout" /> - <SeparatorItem id = "ViewSeparator2" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ViewList" /> - <ItemSet id = "MessageBubbles" _label = "_Message Bubbles"> - <CommandItem id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.Toggle" /> + <SeparatorItem id = "ViewSeparator3" /> + <ItemSet id = "Editor Columns"> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.SingleMode" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" /> + </ItemSet> + <ItemSet id = "MessageBubbles" _label = "Inline _Messages"> <CommandItem id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.HideIssues" /> - <SeparatorItem id = "Separator1" /> <CommandItem id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.ToggleIssues" /> + <SeparatorItem id = "Separator1" /> + <CommandItem id = "MonoDevelop.Ide.Editor.MessageBubbleCommands.Toggle" /> </ItemSet> - <SeparatorItem id = "ViewSeparator3" /> + <ItemSet id = "Folding" _label = "F_olding"> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.EnableDisableFolding" /> + <SeparatorItem id = "FoldingSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" /> + <SeparatorItem id = "FoldDefinitionsSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" /> + </ItemSet> + <SeparatorItem id = "ViewSeparator4" /> <SeparatorItem id = "ViewItemsSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" /> <SeparatorItem id = "ViewItemsSeparator4" /> - <ItemSet id = "Editor Layout"> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.SingleMode" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" /> - </ItemSet> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.FocusCurrentDocument" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ShowWelcomePage" /> <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.FullScreen" /> </ItemSet> <ItemSet id = "Search" _label = "_Search"> - + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.Find" /> + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.Replace" /> + <SeparatorItem id = "SearchSeparator1" /> <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" /> <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.FindNext" /> <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.FindNextSelection" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.Replace" /> - <SeparatorItem id = "SearchSeparator" /> + <SeparatorItem id = "SearchSeparator2" /> <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" /> <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.ReplaceInFiles" /> <SeparatorItem id = "SearchInFilesSeparator" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.ToggleBookmark" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.PrevBookmark" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.NextBookmark" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.ClearBookmarks" /> + <ItemSet id = "Bookmarks" > + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.ToggleBookmark" /> + <SeparatorItem id = "BookmarksNavigationSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.PrevBookmark" /> + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.NextBookmark" /> + <SeparatorItem id = "BookmarksClearSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.ClearBookmarks" /> + </ItemSet> + <ItemSet id = "Go To" > + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.GotoFile" /> + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.GotoType" /> + <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" /> + <SeparatorItem id = "GoToSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" /> + <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" /> + </ItemSet> <SeparatorItem id = "Separator2" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.GotoFile" /> - <CommandItem id = "MonoDevelop.Ide.Commands.SearchCommands.GotoType" /> - <CommandItem id = "MonoDevelop.Components.MainToolbar.Commands.NavigateTo" /> - - <SeparatorItem id = "ViewItemsSeparator3" /> - <CommandItem id = "MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" /> - <CommandItem id = "MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ShowNext" /> + <SeparatorItem id = "Separator3" /> <ItemSet id = "NavigationList" _label = "Navigation _History" _description = "Select a point from the navigation history" > + <CommandItem id = "MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" /> + <CommandItem id = "MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" /> + <SeparatorItem id = "NavigationHistorySeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.NavigationCommands.NavigateHistory" /> <SeparatorItem id = "NavigationHistoryClearSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.NavigationCommands.ClearNavigationHistory" /> </ItemSet> - <SeparatorItem id = "ViewItemsSeparator4" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ShowNext" /> - <SeparatorItem id = "Separator3" /> - <CommandItem id = "MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" /> + <CommandItem id = "MonoDevelop.Components.MainToolbar.Commands.NavigateTo" /> </ItemSet> <ItemSet id = "Project" _label = "_Project"> - <CommandItem id = "MonoDevelop.Ide.Commands.ProjectCommands.ExportSolution" /> <CommandItem id = "MonoDevelop.Ide.Commands.ProjectCommands.AddReference" /> <SeparatorItem id = "ExportSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.ProjectCommands.CustomCommandList" /> @@ -196,6 +206,8 @@ <SeparatorItem id = "OptionsSeparator" /> <CommandItem id = "MonoDevelop.Ide.Commands.ProjectCommands.SolutionOptions" /> <CommandItem id = "MonoDevelop.Ide.Commands.ProjectCommands.ProjectOptions" /> + <SeparatorItem id = "ProjectToolsSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ProjectCommands.ExportSolution" /> </ItemSet> <ItemSet id = "Build" _label = "_Build"> @@ -223,14 +235,14 @@ <Condition id="Platform" value="!mac"> <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.AddinManager" /> </Condition> - <SeparatorItem id ="AddinManagerSeparator" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.ToolList" /> - <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.InstrumentationViewer" /> - <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.InsertGuid" /> + <SeparatorItem id ="ToolsSection" /> <ItemSet id = "SessionRecorder" _label = "Session Recorder" autohide = "true"> <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.ToggleSessionRecorder" /> <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.ReplaySession" /> </ItemSet> + <SeparatorItem id = "CustomToolsSection" _label = "Custom"/> + <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.ToolList" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.EditCustomTools" /> <SeparatorItem id = "OptionsSection" /> <Condition id="Platform" value="windows"> <CommandItem id = "MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" /> @@ -252,31 +264,29 @@ <CommandItem id = "MonoDevelop.Ide.Commands.WindowCommands.OpenWindowList" /> <SeparatorItem id = "windowDocSep" /> <CommandItem id = "MonoDevelop.Ide.Commands.WindowCommands.OpenDocumentList" /> - <SeparatorItem id = "docMinimizeSep" /> + <SeparatorItem id = "welcomePageSep" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ViewCommands.ShowWelcomePage" /> </ItemSet> <ItemSet id = "Help" _label = "_Help"> <CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.Help" /> - <CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.TipOfTheDay" /> + <!--<CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.TipOfTheDay" />--> <CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.SendFeedback" /> - <Condition id = "Platform" value = "!mac"> - <CommandItem id = "MonoDevelop.Ide.Updater.UpdateCommands.CheckForUpdates" /> - </Condition> - <SeparatorItem id = "Separator2" /> - <ItemSet id = "Web" _label = "_Web"> + <SeparatorItem id = "LinksSeparator" /> + <Condition id = "Branding" value = "MonoDevelop"> <LinkItem id = "MonoDevelop" _label = "MonoDevelop" link = "http://www.monodevelop.com" /> <LinkItem id = "Mono" _label = "Mono Project" description = "A free .NET implementation effort, worth visiting" link = "http://www.mono-project.com" /> - <ItemSet id = "C#" _label = "C#"> - <LinkItem id = "C# Help" _label = "C# Help" link = "http://www.csharphelp.com" /> - <LinkItem id = "C# Corner" _label = "C# Corner" link = "http://www.c-sharpcorner.com" /> - <LinkItem id = "CodePlex" _label = "CodePlex" description = "Open Source Project Community." link = "http://www.codeplex.com" /> - <LinkItem id = "MsCodeGallery" _label = "MSDN Code Gallery" description = "Download and share sample applications, code snippets, and other resources with the developer community." link = "http://code.msdn.microsoft.com" /> - </ItemSet> - </ItemSet> + </Condition> <SeparatorItem id = "Separator3" /> - <CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.OpenLogDirectory" /> - <LinkItem id = "ReportBug" _label = "Report a Bug" link = "http://xamar.in/r/file_studio_bug" /> + <ItemSet id = "Diagnostics"> + <LinkItem id = "ReportBug" _label = "Report Problem..." link = "http://xamar.in/r/file_studio_bug" /> + <SeparatorItem id = "DiagnosticToolsSeparator" /> + <CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.OpenLogDirectory" /> + <CommandItem id = "MonoDevelop.Ide.Commands.ToolCommands.InstrumentationViewer" /> + </ItemSet> <Condition id = "Platform" value = "!mac"> + <SeparatorItem id = "SeparatorAbout" /> + <CommandItem id = "MonoDevelop.Ide.Updater.UpdateCommands.CheckForUpdates" /> <CommandItem id = "MonoDevelop.Ide.Commands.HelpCommands.About" /> </Condition> </ItemSet> diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml index a2a7eb8e0e..4bfe9cb0e4 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/MonoDevelop.Ide.addin.xml @@ -238,8 +238,13 @@ <Extension path = "/MonoDevelop/Ide/KeyBindingSchemes"> <Scheme id="Emacs" _name = "GNU/Emacs" resource="KeyBindingSchemeEmacs.xml"/> <Scheme id="VS05" _name = "Visual Studio" resource="KeyBindingSchemeVisualStudio.xml"/> + <Scheme id="VS14MAC" _name = "Visual Studio" resource="KeyBindingSchemeVisualStudio-mac.xml" forMac="true"/> + <Scheme id="VS14MAC2" _name = "Visual Studio (Windows)" resource="KeyBindingSchemeVisualStudio.xml" forMac="true"/> <Scheme id="MD1" _name = "MonoDevelop 1.0" resource="KeyBindingSchemeMonoDevelop1.xml"/> <Scheme id="MD2" _name = "MonoDevelop 2.0" resource="KeyBindingSchemeMonoDevelop2.xml"/> + <Scheme id="Xcode" _name = "Xcode" resource="KeyBindingSchemeXcode.xml" forMac="true"/> + <Scheme id="VSCodeMAC" _name = "Visual Studio Code" resource="KeyBindingSchemeVSCode-mac.xml" forMac="true"/> + <Scheme id="RiderMAC" _name = "ReSharper / Rider" resource="KeyBindingSchemeRider-mac.xml" forMac="true"/> </Extension> <Extension path = "/MonoDevelop/Ide/TaskList/View"> diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/Pads.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/Pads.addin.xml index 294d0dd946..c10e84970c 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/Pads.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/Pads.addin.xml @@ -24,6 +24,7 @@ <Pad id = "MonoDevelop.Ide.Gui.Pads.ErrorListPad" _label = "Errors" icon="md-errors-list" + group="Logs" class = "MonoDevelop.Ide.Gui.Pads.ErrorListPad" defaultPlacement = "Bottom" defaultStatus="AutoHide" @@ -32,6 +33,7 @@ <Pad id = "MonoDevelop.Ide.Gui.Pads.TaskListPad" _label = "Tasks" icon="md-task-list" + group="Logs" class = "MonoDevelop.Ide.Gui.Pads.TaskListPad" defaultPlacement = "Bottom" defaultStatus="AutoHide" @@ -41,9 +43,10 @@ defaultPlacement = "Left" _label = "Help" icon="md-help-pad" + group="ZHelp" class = "MonoDevelop.Ide.Gui.Pads.HelpTree"/> - <SolutionPad id = "ProjectPad" _label = "Solution" icon = "md-solution-pad" class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectSolutionPad" defaultLayout="*" defaultPlacement = "Left"> + <SolutionPad id = "ProjectPad" _label = "Solution" icon = "md-solution-pad" class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.ProjectSolutionPad" defaultLayout="*" defaultPlacement = "Left" group="1Solution"> <ContextMenu path="/MonoDevelop/Ide/ContextMenu/ProjectPad" /> <PadOption id = "ShowAllFiles" _label = "Show All Files" defaultValue = "False" /> <NodeBuilder class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.WorkspaceNodeBuilder"/> @@ -63,7 +66,7 @@ <NodeBuilder class = "MonoDevelop.Ide.Gui.Pads.ProjectPad.ImplicitFrameworkAssemblyReferenceNodeBuilder"/> </SolutionPad> - <SolutionPad id = "ClassPad" _label = "Classes" icon = "md-classes-pad" class = "MonoDevelop.Ide.Gui.Pads.ClassBrowser.ClassBrowserPad" defaultPlacement = "Left" defaultStatus="AutoHide"> + <SolutionPad id = "ClassPad" _label = "Classes" icon = "md-classes-pad" class = "MonoDevelop.Ide.Gui.Pads.ClassBrowser.ClassBrowserPad" defaultPlacement = "Left" defaultStatus="AutoHide" group="1Solution"> <PadOption id = "NestedNamespaces" _label = "Nested namespaces" defaultValue = "True" /> <PadOption id = "ShowProjects" _label = "Show project structure" defaultValue = "True" /> <PadOption id = "GroupByAccess" _label = "Group members by access" defaultValue = "False" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs index 4a3f6fe307..095ad41887 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs @@ -44,6 +44,9 @@ namespace MonoDevelop.Components.Commands.ExtensionNodes { [NodeAttribute ("_label", true, "Label", Localizable=true)] string label; + + [NodeAttribute ("_displayName", "Display Name of the command, visible in search results or key bindings option panel.", Localizable = true)] + string _displayName; [NodeAttribute ("_description", "Description of the command", Localizable=true)] string _description; @@ -148,6 +151,8 @@ namespace MonoDevelop.Components.Commands.ExtensionNodes cmd.Id = ParseCommandId (this); cmd.Text = StringParserService.Parse (BrandingService.BrandApplicationName (label)); + if (!String.IsNullOrWhiteSpace(_displayName)) + cmd.DisplayName = StringParserService.Parse (BrandingService.BrandApplicationName (_displayName)); if ((_description != null) && (_description.Length > 0)){ cmd.Description = BrandingService.BrandApplicationName (_description); } @@ -161,9 +166,9 @@ namespace MonoDevelop.Components.Commands.ExtensionNodes keyBinding = winShortcut; string[] splittedKeys = (keyBinding ?? "").Split (' '); - cmd.AccelKey = KeyBindingManager.CanonicalizeBinding (splittedKeys[0]); + cmd.AccelKey = KeyBindingManager.FixChordSeparators (KeyBindingManager.CanonicalizeBinding (splittedKeys[0])); if (splittedKeys.Length > 1) { - cmd.AlternateAccelKeys = splittedKeys.Skip (1).ToArray (); + cmd.AlternateAccelKeys = splittedKeys.Skip (1).Select (key => KeyBindingManager.FixChordSeparators (key)).ToArray (); } cmd.DisabledVisible = disabledVisible; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs index c19e9fac86..28154e9f25 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs @@ -40,9 +40,12 @@ namespace MonoDevelop.Components.Commands.ExtensionNodes [ExtensionNode (Description="A separator menu or toolbar item")] internal class SeparatorItemCodon : InstanceExtensionNode { + [NodeAttribute ("_label", "Label of the item.", Localizable = true)] + string label; + public override object CreateInstance () { - return new CommandEntry (Command.Separator); + return new CommandEntry (Command.Separator, label); } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs index 9a0a69b78d..d43d95149b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/Command.cs @@ -39,6 +39,7 @@ namespace MonoDevelop.Components.Commands object id; string text; + string displayName; string description; IconId icon; string accelKey; @@ -133,6 +134,11 @@ namespace MonoDevelop.Components.Commands get { return disabledVisible; } set { disabledVisible = value; } } + + public string DisplayName { + get { return String.IsNullOrWhiteSpace (displayName) ? text.Replace ("_", String.Empty) : displayName; } + set { displayName = value; } + } public string Description { get { return description; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs index b908b5078f..5c41cd976c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandEntry.cs @@ -76,6 +76,11 @@ namespace MonoDevelop.Components.Commands set { disabledVisible = value; } } + public string OverrideLabel { + get { return overrideLabel; } + set { overrideLabel = value; } + } + public CommandEntryDisplayType DisplayType { get; set; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs index 922553141d..d1b87eb4d9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/CommandManager.cs @@ -28,11 +28,14 @@ using System; -using System.Reflection; using System.Collections; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; +using System.Reflection; +using System.Text; +using System.Xml; using MonoDevelop.Components.Commands.ExtensionNodes; using Mono.Addins; @@ -79,6 +82,15 @@ namespace MonoDevelop.Components.Commands internal bool handlerFoundInMulticast; Gtk.Widget lastActiveWidget; + Dictionary<Command, HashSet<Command>> conflicts; + internal Dictionary<Command, HashSet<Command>> Conflicts { + get { + if (conflicts == null) + LoadConflicts (); + return conflicts; + } + } + public CommandManager (): this (null) { } @@ -391,7 +403,12 @@ namespace MonoDevelop.Components.Commands } var toplevelFocus = IdeApp.Workbench.HasToplevelFocus; + + var conflict = new List<Command> (); + bool bypass = false; + var dispatched = false; + for (int i = 0; i < commands.Count; i++) { CommandInfo cinfo = GetCommandInfo (commands[i].Id, new CommandTargetRoute ()); if (cinfo.Bypass) { @@ -399,10 +416,35 @@ namespace MonoDevelop.Components.Commands continue; } - if (cinfo.Enabled && cinfo.Visible && DispatchCommand (commands[i].Id, CommandSource.Keybinding)) - return result; + if (cinfo.Enabled && cinfo.Visible) { + if (!dispatched) + dispatched = DispatchCommand (commands [i].Id, CommandSource.Keybinding); + conflict.Add (commands [i]); + } else + bypass = true; // allow Gtk to handle the event if the command is disabled + } + + if (conflict.Count > 1) { + bool newConflict = false; + foreach (var item in conflict) { + HashSet<Command> itemConflicts; + if (!Conflicts.TryGetValue (item, out itemConflicts)) + Conflicts [item] = itemConflicts = new HashSet<Command> (); + var tmp = conflict.Where (c => c != item); + if (!itemConflicts.IsSupersetOf (tmp)) { + itemConflicts.UnionWith (tmp); + newConflict = true; + } + } + if (newConflict) + SaveConflicts (); + if (KeyBindingFailed != null) + KeyBindingFailed (this, new KeyBindingFailedEventArgs (GettextCatalog.GetString ("The key combination ({0}) has conflicts.", KeyBindingManager.BindingToDisplayLabel (binding.ToString (), false)))); } + if (dispatched) + return result; + // The command has not been handled. // If there is at least a handler that sets the bypass flag, allow gtk to execute the default action @@ -416,6 +458,95 @@ namespace MonoDevelop.Components.Commands chords = null; return result; } + + void LoadConflicts () + { + if (conflicts == null) + conflicts = new Dictionary<Command, HashSet<Command>> (); + + var file = UserProfile.Current.CacheDir.Combine ("CommandConflicts.xml"); + + if (!File.Exists (file)) + return; + + try { + using (var reader = new XmlTextReader (file)) { + bool foundConflicts = false; + conflicts.Clear (); + + while (reader.Read ()) { + if (reader.IsStartElement ("conflicts")) { + foundConflicts = true; + break; + } + } + + if (!foundConflicts || reader.GetAttribute ("version") != "1.0") + return; + + while (reader.Read ()) { + if (reader.IsStartElement ("conflict")) { + var conflictId = reader.GetAttribute ("id"); + var command = GetCommand (conflictId); + if (command == null) + continue; + + var conflict = new HashSet<Command> (); + conflicts.Add (command, conflict); + while (reader.Read ()) { + if (reader.IsStartElement ("command")) { + var cmdId = reader.ReadElementContentAsString (); + var cmd = GetCommand (cmdId); + if (cmd == null) + continue; + conflict.Add (cmd); + } else + break; + } + } + } + } + } catch (Exception e) { + conflicts.Clear (); + LoggingService.LogError ("Loading command conflicts from " + file + " failed.", e); + } + } + + void SaveConflicts () + { + if (!Directory.Exists (UserProfile.Current.CacheDir)) + Directory.CreateDirectory (UserProfile.Current.CacheDir); + + string file = UserProfile.Current.CacheDir.Combine ("CommandConflicts.xml"); + + try { + using (var stream = new FileStream (file + '~', FileMode.Create)) + using (var writer = new XmlTextWriter (stream, Encoding.UTF8)) { + writer.Formatting = Formatting.Indented; + writer.IndentChar = ' '; + writer.Indentation = 2; + + writer.WriteStartElement ("conflicts"); + writer.WriteAttributeString ("version", "1.0"); + + foreach (var conflict in conflicts) { + writer.WriteStartElement ("conflict"); + writer.WriteAttributeString ("id", conflict.Key.Id.ToString ()); + foreach (var cmd in conflict.Value) { + writer.WriteStartElement ("command"); + writer.WriteString (cmd.Id.ToString ()); + writer.WriteEndElement (); + } + writer.WriteEndElement (); + } + + writer.WriteEndElement (); + } + FileService.SystemRename (file + '~', file); + } catch (Exception e) { + LoggingService.LogError ("Saving command conflicts to " + file + " failed.", e); + } + } void NotifyKeyPressed (Gdk.EventKey ev) { @@ -2280,7 +2411,7 @@ namespace MonoDevelop.Components.Commands var sw = Stopwatch.StartNew (); - Method.Invoke (cmdTarget, new object[] {info} );
+ Method.Invoke (cmdTarget, new object[] {info} ); sw.Stop (); if (sw.ElapsedMilliseconds > CommandManager.SlowCommandWarningTime) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs index 3b460a0198..222f163b5c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingManager.cs @@ -559,6 +559,36 @@ namespace MonoDevelop.Components.Commands return Binding (chord, accel); } + + internal static string FixChordSeparators (string binding) + { + // converts old style '|' separators to new scheme with chord detection. + // Examples: + // Control|X -> Control+X + // Alt|| -> Alt+| + // Alt|+ -> Alt++ + // this conversion is required for proper key detection, otherwise + // keys bindings like Control|X and Control+X will not be detected as + // eqal / duplicate bindings. + if (string.IsNullOrEmpty (binding)) + return binding; + var chars = binding.ToCharArray (); + bool foundChordSep = false; + // first and last characters are never separators, skip them + for (int i = 1; i < binding.Length - 1; i++) { + // chords can not start with a '+', therefore all bindings + // whre a '+' occurs before a '|' have already the right style + if (chars [i] == '+' && !foundChordSep) + return binding; + // make sure we don't convert the real '|' key + if (chars [i] == '|' && chars [i - 1] != '|') { + foundChordSep = true; + chars [i] = '+'; + } + } + var result = new string (chars); + return result; + } #endregion @@ -776,9 +806,13 @@ namespace MonoDevelop.Components.Commands case Gdk.Key.Delete: return '⌦'; case Gdk.Key.Home: - return '⇱'; + return '\u2196'; // ↖ + //return '\u21F1'; // ⇱ + //return '⇱'; case Gdk.Key.End: - return '⇲'; + return '\u2198'; // ↘ + //return '\u21F2'; // ⇲ + //return '⇲'; case Gdk.Key.Page_Up: return '⇞'; case Gdk.Key.Page_Down: diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs index 70f16282ab..3d57d0d26c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingService.cs @@ -203,7 +203,12 @@ namespace MonoDevelop.Components.Commands } public string Name { - get { return AddinManager.CurrentLocalizer.GetString ("Default"); } + get { + if (BrandingService.ApplicationName == "MonoDevelop") + return AddinManager.CurrentLocalizer.GetString ("Custom"); + else + return BrandingService.ApplicationName; + } } public KeyBindingSet GetKeyBindingSet () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingSet.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingSet.cs index a9e81423f4..b6aab20069 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingSet.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands/KeyBindingSet.cs @@ -33,6 +33,7 @@ using System.Xml; using System.Text; using MonoDevelop.Core; using Unix = Mono.Unix.Native; +using System.Linq; namespace MonoDevelop.Components.Commands { @@ -58,30 +59,29 @@ namespace MonoDevelop.Components.Commands // Load all bindings foreach (Command cmd in commands) { - string key = GetBinding (cmd); - if (key.Length == 0) - continue; - List<Command> clist; - if (!bindings.TryGetValue (key, out clist)) { - clist = new List<Command> (); - bindings.Add (key, clist); + foreach (var key in GetBindings (cmd)) { + if (key.Length == 0) + continue; + List<Command> clist; + if (!bindings.TryGetValue (key, out clist)) { + clist = new List<Command> (); + bindings.Add (key, clist); + } + clist.Add (cmd); + if (clist.Count == 2) + // We have a conflict + conflicts.Add (new KeyBindingConflict (key, clist)); } - clist.Add (cmd); - if (clist.Count == 2) - // We have a conflict - conflicts.Add (new KeyBindingConflict (key, clist)); } // Check if there are conflicts with key combinations prefixes. // For example, ctrl+X would conflict with ctrl+X|A foreach (Command cmd in commands) { - string key = GetBinding (cmd); - int i = key.IndexOf ('|'); - if (i != -1) { - key = key.Substring (0, i); + foreach (var key in GetBindings (cmd).Where (key => key.Contains ('|')).Select (key => key.Substring (0, key.IndexOf ('|')))) { List<Command> clist; if (bindings.TryGetValue (key, out clist)) { - clist.Add (cmd); + if (!clist.Contains (cmd)) + clist.Add (cmd); if (clist.Count == 2) // We have a conflict conflicts.Add (new KeyBindingConflict (key, clist)); @@ -117,46 +117,59 @@ namespace MonoDevelop.Components.Commands public void StoreBinding (Command cmd) { - SetBinding (cmd, cmd.AccelKey); + if (cmd.AlternateAccelKeys != null) + SetBinding (cmd, new [] { cmd.AccelKey }.Concat (cmd.AlternateAccelKeys).ToArray ()); + else + SetBinding (cmd, cmd.AccelKey); } - public void SetBinding (Command cmd, string accelKey) + public void SetBinding (Command cmd, params string[] accelKeys) { string key = KeyBindingService.GetCommandKey (cmd); - if (accelKey == null) { - bindings.Remove (key); - return; - } - - if (parent == null) - bindings [key] = accelKey; - else { + accelKeys = accelKeys?.Distinct ().ToArray () ?? new string [0]; + if (parent == null) { + if (accelKeys.Length == 0) + bindings.Remove (key); + else + bindings [key] = string.Join (" ", accelKeys); + } else { // If the key is the same as the default, remove it from the scheme - string pbind = parent.GetBinding (cmd); - if ((accelKey == pbind) || (string.IsNullOrEmpty (accelKey) && string.IsNullOrEmpty (pbind))) + var pbind = parent.GetBindings (cmd).Distinct (); + if (new HashSet<string> (accelKeys).SetEquals (pbind)) bindings.Remove (key); else - bindings[key] = accelKey; + bindings [key] = string.Join (" ", accelKeys); } } public void LoadBinding (Command cmd) { - cmd.AccelKey = GetBinding (cmd); + var cmdAccesls = GetBindings (cmd); + if (cmdAccesls == null || cmdAccesls.Length == 0) { + cmd.AccelKey = String.Empty; + cmd.AlternateAccelKeys = null; + return; + } + + cmd.AccelKey = cmdAccesls [0]; + if (cmdAccesls.Length > 1) + cmd.AlternateAccelKeys = cmdAccesls.Skip (1).ToArray (); + else + cmd.AlternateAccelKeys = null; } - public string GetBinding (Command cmd) + public string [] GetBindings (Command cmd) { string key = KeyBindingService.GetCommandKey (cmd); // Schemes use default key bindings when not explicitly overriden string accel; if (bindings.TryGetValue (key, out accel)) - return accel; + return (accel ?? "").Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries); else if (parent != null) - return parent.GetBinding (cmd); + return parent.GetBindings (cmd); else - return string.Empty; + return new string[0]; } const string commandAttr = "command"; @@ -203,7 +216,7 @@ namespace MonoDevelop.Components.Commands binding = reader.GetAttribute (shortcutAttr); if (!string.IsNullOrEmpty (command)) - bindings.Add (command, binding); + bindings.Add (command, KeyBindingManager.FixChordSeparators(binding)); break; } @@ -218,7 +231,15 @@ namespace MonoDevelop.Components.Commands writer.WriteStartElement ("scheme"); writer.WriteAttributeString ("name", id); - foreach (KeyValuePair<string, string> binding in bindings) { + foreach (KeyValuePair<string, string> binding in bindings) { + + string pbind; + if (parent?.bindings != null && parent.bindings.TryGetValue (binding.Key, out pbind)) { + if (binding.Value == pbind) + continue; + } else if (string.IsNullOrEmpty (binding.Value)) + continue; + writer.WriteStartElement ("binding"); writer.WriteAttributeString (commandAttr, binding.Key); writer.WriteAttributeString (shortcutAttr, binding.Value); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs index 602df87d3f..950025348d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Docking/DockItemTitleTab.cs @@ -157,7 +157,10 @@ namespace MonoDevelop.Components.Docking labelWidget.ModifyText (StateType.Normal, (active ? visualStyle.PadTitleLabelColor.Value : visualStyle.InactivePadTitleLabelColor.Value).ToGdkColor ()); } + var r = WidthRequest; + WidthRequest = -1; labelWidth = SizeRequest ().Width + 1; + WidthRequest = r; if (visualStyle != null) HeightRequest = visualStyle.PadTitleHeight != null ? (int)(visualStyle.PadTitleHeight.Value) : -1; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs index bd2f9c96fb..1ed6108fa4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs @@ -48,7 +48,7 @@ namespace MonoDevelop.Components.MainToolbar static CommandSearchCategory () { allCommands = IdeApp.CommandService.GetCommands ().Select(cmd => - Tuple.Create (cmd, cmd.Text.Replace ("_", "")) + Tuple.Create (cmd, cmd.DisplayName) ).ToList(); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainStatusBarContextImpl.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainStatusBarContextImpl.cs index e381a31c65..74cab9f66d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainStatusBarContextImpl.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainStatusBarContextImpl.cs @@ -38,6 +38,7 @@ using MonoDevelop.Components.MainToolbar; using StockIcons = MonoDevelop.Ide.Gui.Stock; using MonoDevelop.Ide; +using System.Threading; namespace MonoDevelop.Components.MainToolbar { @@ -80,6 +81,13 @@ namespace MonoDevelop.Components.MainToolbar if (statusHandler.IsCurrentContext (this)) statusBar.SetMessageSourcePad (pad); } + + public void SetCancellationTokenSource (CancellationTokenSource source) + { + CancellationTokenSource = source; + if (statusHandler.IsCurrentContext (this)) + statusBar.SetCancellationTokenSource (source); + } protected override void OnMessageChanged () { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs index 52cd3422a3..a3ff8ec5b6 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/MainToolbarController.cs @@ -666,8 +666,8 @@ namespace MonoDevelop.Components.MainToolbar text = selected.Substring (0, whitespaceIndex); } - ToolbarView.SearchText = text; ToolbarView.FocusSearchBar (); + ToolbarView.SearchText = text; } public void SetSearchCategory (string category) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs index f1e61b9ec1..13d22454a3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/StatusArea.cs @@ -38,6 +38,7 @@ using MonoDevelop.Ide.Gui.Components; using StockIcons = MonoDevelop.Ide.Gui.Stock; using Xwt.Motion; using MonoDevelop.Ide.Fonts; +using System.Threading; namespace MonoDevelop.Components.MainToolbar { @@ -871,6 +872,10 @@ namespace MonoDevelop.Components.MainToolbar } } } + + public void SetCancellationTokenSource (CancellationTokenSource source) + { + } #endregion } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs index 6cacbc4ff9..56a71a4fac 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenu.cs @@ -99,11 +99,16 @@ namespace MonoDevelop.Components Show (parent, x, y, null); } - - public void Add (ContextMenuItem menuItem) { items.Add (menuItem); } + + public event EventHandler Closed; + + internal void FireClosedEvent () + { + Closed?.Invoke (this, EventArgs.Empty); + } } }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs index 468b09d7d5..f7cc078815 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsGtk.cs @@ -26,6 +26,7 @@ using System; using Xwt.GtkBackend; +using MonoDevelop.Ide; namespace MonoDevelop.Components { @@ -62,11 +63,37 @@ namespace MonoDevelop.Components var gtkMenu = FromMenu (menu, closeHandler); gtkMenu.ShowAll (); - if (selectFirstItem && gtkMenu.Children.Length > 0) - gtkMenu.SelectItem (gtkMenu.Children[0]); + if (selectFirstItem && gtkMenu.Children.Length > 0) { + gtkMenu.SelectItem (gtkMenu.Children [0]); + new PoupHandlerWrapper (menu, gtkMenu); + } ShowContextMenu (parent, x, y, gtkMenu); } + // Gtk.Menu.Popup event seems not to be working correcty + // so doing a work around using the expose event. + class PoupHandlerWrapper + { + ContextMenu menu; + + public PoupHandlerWrapper (ContextMenu menu, Gtk.Menu gtkMenu) + { + this.menu = menu; + gtkMenu.ExposeEvent += HandleExposeEvent; + } + + void HandleExposeEvent (object o, Gtk.ExposeEventArgs args) + { + var gtkMenu = (Gtk.Menu)o; + gtkMenu.ExposeEvent -= HandleExposeEvent; + int ox, oy; + gtkMenu.ParentWindow.GetOrigin (out ox, out oy); + int rx, ry; + IdeApp.Workbench.RootWindow.GdkWindow.GetOrigin (out rx, out ry); + menu.Items [0].FireSelectedEvent (new Xwt.Rectangle (ox - rx, oy - ry, gtkMenu.Allocation.Width, gtkMenu.Allocation.Height)); + } + } + public static void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, Gtk.Menu menu) { if (parent == null) @@ -106,7 +133,20 @@ namespace MonoDevelop.Components } else { menuItem = new Gtk.ImageMenuItem (item.Label); } - + menuItem.Selected += delegate (object sender, EventArgs e) { + var si = sender as Gtk.MenuItem; + if (si == null || si.GdkWindow == null) + return; + int x, y; + si.GdkWindow.GetOrigin (out x, out y); + int rx, ry; + IdeApp.Workbench.RootWindow.GdkWindow.GetOrigin (out rx, out ry); + + item.FireSelectedEvent (new Xwt.Rectangle (x - rx, y - ry, si.Allocation.Width, si.Allocation.Height)); + }; + menuItem.Deselected += delegate { + item.FireDeselectedEvent (); + }; if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu (item.SubMenu, null); } @@ -144,9 +184,11 @@ namespace MonoDevelop.Components result.Append (item); } - if (closeHandler != null) { - result.Hidden += (sender, e) => closeHandler (); - } + result.Hidden += delegate { + if (closeHandler != null) + closeHandler (); + menu.FireClosedEvent (); + }; return result; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs index 5f3223ac92..02c8beafdd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuExtensionsMac.cs @@ -28,6 +28,7 @@ using System; #if MAC using AppKit; using Foundation; +using MonoDevelop.Ide; #endif namespace MonoDevelop.Components @@ -62,6 +63,8 @@ namespace MonoDevelop.Components ShowContextMenu (parent, x, y, menu, null); } + + static CoreGraphics.CGPoint lastOpenPositon; public static void ShowContextMenu (Gtk.Widget parent, int x, int y, NSMenu menu, bool selectFirstItem = false) { if (parent == null) @@ -91,10 +94,11 @@ namespace MonoDevelop.Components if (selectFirstItem) { var pt = new CoreGraphics.CGPoint (x, y); + lastOpenPositon = pt; menu.PopUpMenu (menu.ItemAt (0), pt, nsview); } else { var pt = new CoreGraphics.CGPoint (x, nswindow.Frame.Height - y - titleBarOffset); - + lastOpenPositon = pt; var tmp_event = NSEvent.MouseEvent (NSEventType.LeftMouseDown, pt, 0, 0, @@ -102,8 +106,6 @@ namespace MonoDevelop.Components null, 0, 0, 0); NSMenu.PopUpContextMenu (menu, tmp_event, nsview); } - - }); } @@ -145,21 +147,48 @@ namespace MonoDevelop.Components class ContextMenuDelegate : NSObject { + ContextMenu menu; + ContextMenuItem oldItem; + public ContextMenuDelegate (ContextMenu menu) + { + this.menu = menu; + } + public Action CloseHandler { get; set; } [Export ("menuDidClose:")] void MenuDidClose (NSMenu menu) { + if (menu.Supermenu != null) + return; if (CloseHandler != null) { CloseHandler (); } + this.menu.FireClosedEvent (); + } + + [Export ("menu:willHighlightItem:")] + void MenuWillHighlightItem (NSMenu menu, NSMenuItem willHighlightItem) + { + if (oldItem != null) { + oldItem.FireDeselectedEvent (); + oldItem = null; + } + if (willHighlightItem == null) + return; + int index = (int)menu.IndexOf (willHighlightItem); + if (index < 0) + return; + oldItem = this.menu.Items [index]; + + oldItem.FireSelectedEvent (new Xwt.Rectangle (lastOpenPositon.X, lastOpenPositon.Y, menu.Size.Width, menu.Size.Height)); } } static NSMenu FromMenu (ContextMenu menu, Action closeHandler) { var result = new NSMenu () { AutoEnablesItems = false }; - result.WeakDelegate = new ContextMenuDelegate { CloseHandler = closeHandler }; + result.WeakDelegate = new ContextMenuDelegate (menu) { CloseHandler = closeHandler }; foreach (var menuItem in menu.Items) { var item = CreateMenuItem (menuItem); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs index 37d843cbbd..144ff68c6c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/ContextMenuItem.cs @@ -93,6 +93,21 @@ namespace MonoDevelop.Components public bool Visible { get; set; } + public event EventHandler<Xwt.Rectangle> Selected; + + internal void FireSelectedEvent (Xwt.Rectangle menuArea) + { + Selected?.Invoke (this, menuArea); + } + + public event EventHandler Deselected; + + internal void FireDeselectedEvent () + { + Deselected?.Invoke (this, EventArgs.Empty); + } + + public Xwt.Drawing.Image Image { get { return image; } set { @@ -142,5 +157,6 @@ namespace MonoDevelop.Components if (Clicked != null) Clicked (this, e); } - } + +} }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs index 6ae289dbc6..32560d1acb 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs @@ -227,12 +227,39 @@ namespace MonoDevelop.Components else Xwt.Drawing.Context.ClearGlobalStyle ("dark"); + UpdateXwtDefaults (); + Styles.LoadStyle (); #if MAC UpdateMacWindows (); #endif } + static void UpdateXwtDefaults () + { + // Xwt default dialog icons + Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.InformationIcon = ImageService.GetIcon ("gtk-dialog-info", Gtk.IconSize.Dialog); + Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.WarningIcon = ImageService.GetIcon ("gtk-dialog-warning", Gtk.IconSize.Dialog); + Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.ErrorIcon = ImageService.GetIcon ("gtk-dialog-error", Gtk.IconSize.Dialog); + Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.QuestionIcon = ImageService.GetIcon ("gtk-dialog-question", Gtk.IconSize.Dialog); + Xwt.Toolkit.CurrentEngine.Defaults.MessageDialog.ConfirmationIcon = ImageService.GetIcon ("gtk-dialog-question", Gtk.IconSize.Dialog); + + if (Platform.IsMac && UserInterfaceTheme == Theme.Dark) { + // dark NSAppearance can not handle custom drawn images in dialogs + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.InformationIcon = ImageService.GetIcon ("gtk-dialog-info", Gtk.IconSize.Dialog).ToBitmap (GtkWorkarounds.GetScaleFactor ()); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.WarningIcon = ImageService.GetIcon ("gtk-dialog-warning", Gtk.IconSize.Dialog).ToBitmap (GtkWorkarounds.GetScaleFactor ()); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ErrorIcon = ImageService.GetIcon ("gtk-dialog-error", Gtk.IconSize.Dialog).ToBitmap (GtkWorkarounds.GetScaleFactor ()); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.QuestionIcon = ImageService.GetIcon ("gtk-dialog-question", Gtk.IconSize.Dialog).ToBitmap (GtkWorkarounds.GetScaleFactor ()); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ConfirmationIcon = ImageService.GetIcon ("gtk-dialog-question", Gtk.IconSize.Dialog).ToBitmap (GtkWorkarounds.GetScaleFactor ()); + } else { + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.InformationIcon = ImageService.GetIcon ("gtk-dialog-info", Gtk.IconSize.Dialog); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.WarningIcon = ImageService.GetIcon ("gtk-dialog-warning", Gtk.IconSize.Dialog); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ErrorIcon = ImageService.GetIcon ("gtk-dialog-error", Gtk.IconSize.Dialog); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.QuestionIcon = ImageService.GetIcon ("gtk-dialog-question", Gtk.IconSize.Dialog); + Xwt.Toolkit.NativeEngine.Defaults.MessageDialog.ConfirmationIcon = ImageService.GetIcon ("gtk-dialog-question", Gtk.IconSize.Dialog); + } + } + internal static string[] gtkThemeFallbacks = new string[] { "Xamarin",// the best! "Gilouche", // SUSE diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs index bd15e84f84..eff45798a5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/Mac/MDMenuItem.cs @@ -92,7 +92,7 @@ namespace MonoDevelop.Components.Mac var info = manager.GetCommandInfo (ce.CommandId, new CommandTargetRoute (initialCommandTarget)); if (!isArrayItem) { - SetItemValues (this, info, ce.DisabledVisible); + SetItemValues (this, info, ce.DisabledVisible, ce.OverrideLabel); if (!Hidden) MDMenu.ShowLastSeparator (ref lastSeparator); return; @@ -129,6 +129,7 @@ namespace MonoDevelop.Components.Mac parent.InsertItem (n, index); else parent.AddItem (n); + index++; continue; } @@ -162,9 +163,9 @@ namespace MonoDevelop.Components.Mac public CommandInfo Info; } - void SetItemValues (NSMenuItem item, CommandInfo info, bool disabledVisible) + void SetItemValues (NSMenuItem item, CommandInfo info, bool disabledVisible, string overrideLabel = null) { - item.SetTitleWithMnemonic (GetCleanCommandText (info)); + item.SetTitleWithMnemonic (GetCleanCommandText (info, overrideLabel)); if (!string.IsNullOrEmpty (info.Description) && item.ToolTip != info.Description) item.ToolTip = info.Description; @@ -237,6 +238,10 @@ namespace MonoDevelop.Components.Mac static string GetKeyEquivalent (Gdk.Key key) { + // Gdk.Keyval.ToUnicode returns NULL for TAB, fix it + if (key == Gdk.Key.Tab) + return "\t"; + char c = (char) Gdk.Keyval.ToUnicode ((uint) key); if (c != 0) return c.ToString (); @@ -245,13 +250,13 @@ namespace MonoDevelop.Components.Mac if (fk != 0) return ((char) fk).ToString (); - LoggingService.LogError ("Mac menu cannot display key '{0}", key); + LoggingService.LogError ("Mac menu cannot display key '{0}'", key); return ""; } - static string GetCleanCommandText (CommandInfo ci) + static string GetCleanCommandText (CommandInfo ci, string overrideLabel = null) { - string txt = ci.Text; + string txt = overrideLabel ?? ci.Text; if (txt == null) return ""; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs index 2147c668ca..053ccdeaa6 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/PopoverWindow.cs @@ -40,7 +40,7 @@ namespace MonoDevelop.Components Gtk.Alignment alignment; Gdk.Rectangle currentCaret; - Gdk.Window targetWindow; + Gdk.Point targetWindowOrigin = new Point (-1, -1); Gtk.Widget parent; bool eventProvided; @@ -129,18 +129,32 @@ namespace MonoDevelop.Components ShowPopup (widget, null, caret, position); } + public void ShowPopup (Xwt.Rectangle onScreenArea, PopupPosition position) + { + this.parent = IdeApp.Workbench.RootWindow; + this.currentCaret = new Rectangle ((int)onScreenArea.X, (int)onScreenArea.Y, (int)onScreenArea.Width, (int)onScreenArea.Height); + Theme.TargetPosition = position; + targetWindowOrigin = new Point ((int)onScreenArea.X, (int)onScreenArea.Y); + RepositionWindow (); + } + void ShowPopup (Gtk.Widget parent, Gdk.EventButton evt, Gdk.Rectangle caret, PopupPosition position) { this.parent = parent; this.currentCaret = caret; Theme.TargetPosition = position; - + Gdk.Window targetWindow; if (evt != null) { eventProvided = true; targetWindow = evt.Window; } else targetWindow = parent.GdkWindow; - + + if (targetWindow != null) {
+ int x, y;
+ targetWindow.GetOrigin (out x, out y);
+ targetWindowOrigin = new Point (x, y); + } RepositionWindow (); } @@ -208,19 +222,18 @@ namespace MonoDevelop.Components if (parent == null) return; - int x, y; if (newCaret.HasValue) {//Update caret if parameter is given currentCaret = newCaret.Value; } Gdk.Rectangle caret = currentCaret; - Gdk.Window window = targetWindow; - if (targetWindow == null) + if (targetWindowOrigin.X < 0) return; + int x = targetWindowOrigin.X; + int y = targetWindowOrigin.Y; PopupPosition position = Theme.TargetPosition; this.position = Theme.TargetPosition; UpdatePadding (); - window.GetOrigin (out x, out y); var alloc = parent.Allocation; if (eventProvided) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs index ce54d5e15f..de37f3c706 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/TooltipPopoverWindow.cs @@ -124,7 +124,14 @@ namespace MonoDevelop.Components void UpdateLabel () { + if (label == null) + return; + string msg = hasMarkup ? text : GLib.Markup.EscapeText (text); + if (string.IsNullOrEmpty (msg)) { + label.Markup = String.Empty; + return; + } if (severity.HasValue) { switch (severity.Value) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs index 1f4217dae0..6eec222be8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/CompletionListWindow.cs @@ -440,21 +440,12 @@ namespace MonoDevelop.Ide.CodeCompletion WindowTransparencyDecorator.Attach (this); DataProvider = facade; HideDeclarationView (); - VisibilityNotifyEvent += (object sender, VisibilityNotifyEventArgs e) => { - if (!Visible) - HideDeclarationView (); - }; List.ListScrolled += (object sender, EventArgs e) => { HideDeclarationView (); UpdateDeclarationView (); }; List.WordsFiltered += delegate { - HideDeclarationView (); - UpdateDeclarationView (); - }; - List.VisibilityNotifyEvent += (object sender, VisibilityNotifyEventArgs e) => { - if (!List.Visible) - HideDeclarationView (); + RepositionDeclarationViewWindow (); }; } @@ -813,15 +804,15 @@ namespace MonoDevelop.Ide.CodeCompletion if (item == null) return false; IsInCompletion = true; - try { - // first close the completion list, then insert the text. - // this is required because that's the logical event chain, otherwise things could be messed up + try {
+ // first close the completion list, then insert the text.
+ // this is required because that's the logical event chain, otherwise things could be messed up
CloseCompletionList (); /* var cdItem = (CompletionData)item; cdItem.InsertCompletionText (this, ref ka, closeChar, keyChar, modifier); AddWordToHistory (PartialWord, cdItem.CompletionText); OnWordCompleted (new CodeCompletionContextEventArgs (CompletionWidget, CodeCompletionContext, cdItem.CompletionText)); - */ + */
if (item.HasOverloads && declarationviewwindow.CurrentOverload >= 0 && declarationviewwindow.CurrentOverload < item.OverloadedData.Count) { item.OverloadedData[declarationviewwindow.CurrentOverload].InsertCompletionText (facade, ref ka, descriptor); } else { @@ -956,15 +947,8 @@ namespace MonoDevelop.Ide.CodeCompletion base.GdkWindow.GetOrigin (out ox, out oy); declarationviewwindow.MaximumYTopBound = oy; int y = rect.Y + Theme.Padding - (int)List.vadj.Value; - if (!declarationViewHidden && Visible && List.Visible && completionDataList != null && - List.SelectionFilterIndex < completionDataList.Count && List.SelectionFilterIndex != -1) - declarationviewwindow.ShowPopup ( - this, - new Gdk.Rectangle (0, Math.Min (Allocation.Height, Math.Max (0, y)), Allocation.Width, rect.Height), - PopupPosition.Left); - if (declarationViewHidden || !Visible || !List.Visible || completionDataList == null || - List.SelectionFilterIndex >= completionDataList.Count || List.SelectionFilterIndex == -1) - HideDeclarationView(); + declarationviewwindow.ShowPopup (this, new Gdk.Rectangle (0, Math.Min (Allocation.Height, Math.Max (0, y)), Allocation.Width, rect.Height), PopupPosition.Left); + declarationViewHidden = false; } bool DelayedTooltipShow () @@ -1025,7 +1009,6 @@ namespace MonoDevelop.Ide.CodeCompletion } if (declarationViewHidden && Visible) { - declarationViewHidden = false; RepositionDeclarationViewWindow (); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs index 20d26fdb51..9d25afc9a3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/ListWindow.cs @@ -334,8 +334,6 @@ namespace MonoDevelop.Ide.CodeCompletion UpdateWordSelection (); return KeyActions.Process; } - if (keyChar == '.' && !list.AutoCompleteEmptyMatch && PartialWord == ".") - list.AutoSelect = list.AutoCompleteEmptyMatch = true; lastCommitCharEndoffset = CompletionWidget.CaretOffset - 1; if (list.SelectionEnabled && CompletionCharacters.CompleteOn (keyChar)) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs index 9db0f75515..b7e2b17d0a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeCompletion/TooltipInformationWindow.cs @@ -308,13 +308,14 @@ namespace MonoDevelop.Ide.CodeCompletion IdeApp.Preferences.ColorScheme.Changed += HandleThemeChanged; } - public override void RepositionWindow(Gdk.Rectangle? newCaret = null) + public override void RepositionWindow (Gdk.Rectangle? newCaret = null) { // Setting the opicity delayed to 1 is a hack to ensure smooth animation popup see "Bug 32046 - Janky animations on tooltips" Opacity = 0; base.RepositionWindow(newCaret); GLib.Timeout.Add (50, delegate { - Opacity = 1; + if (Visible) + Opacity = 1; return false; }); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs index 9125e48690..7dce1c43f7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs @@ -455,7 +455,9 @@ namespace MonoDevelop.Ide.CodeTemplates int endOffset = template.InsertPosition + template.Code.Length; var oldVersion = data.Version; prettyPrinter.OnTheFlyFormat (editor, context, TextSegment.FromBounds (template.InsertPosition, editor.CaretOffset)); - prettyPrinter.OnTheFlyFormat (editor, context, TextSegment.FromBounds (editor.CaretOffset, endOffset)); + if (editor.CaretOffset < endOffset) + prettyPrinter.OnTheFlyFormat (editor, context, TextSegment.FromBounds (editor.CaretOffset, endOffset)); + foreach (var textLink in template.TextLinks) { for (int i = 0; i < textLink.Links.Count; i++) { var segment = textLink.Links [i]; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs index d8abe37a83..66a3d52aef 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Codons/PadCodon.cs @@ -56,6 +56,9 @@ namespace MonoDevelop.Ide.Codons [NodeAttribute("icon", "Icon of the pad. It can be a stock icon or a resource icon (use 'res:' as prefix in the last case).")] string icon = null; + + [NodeAttribute ("group", "Name of the group, used to group Pads inside Category menus.")] + string group = null; [NodeAttribute("defaultPlacement", "Default placement of the pad inside the workbench. " + @@ -106,6 +109,10 @@ namespace MonoDevelop.Ide.Codons public IconId Icon { get { return !string.IsNullOrEmpty (icon) ? icon : "md-generic-pad"; } } + + public string Group { + get { return !string.IsNullOrEmpty (group) ? group : "YOther"; } + } public string ClassName { get { return className; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs index 22211b010e..3d0523c9b1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/EditCommands.cs @@ -60,6 +60,7 @@ namespace MonoDevelop.Ide.Commands DefaultPolicies, InsertStandardHeader, + EnableDisableFolding, ToggleFolding, ToggleAllFoldings, FoldDefinitions, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs index 3aa2b74512..eacc488c97 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ProjectCommands.cs @@ -404,10 +404,10 @@ namespace MonoDevelop.Ide.Commands ProgressMonitor monitor = IdeApp.Workbench.ProgressMonitors.GetRunProgressMonitor (); Thread t = new Thread ( - delegate () { + async delegate () { using (monitor) { try { - cmd.Execute (monitor, ce, IdeApp.Workspace.ActiveConfiguration); + await cmd.Execute (monitor, ce, IdeApp.Workspace.ActiveConfiguration); } catch (Exception ex) { monitor.ReportError (GettextCatalog.GetString ("Command execution failed"), ex); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs index f05ad1f3ba..b7a21a1ced 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/TextEditorCommands.cs @@ -34,6 +34,7 @@ namespace MonoDevelop.Ide.Commands { ShowCompletionWindow, ShowCodeTemplateWindow, + ShowCodeSurroundingsWindow, LineEnd, LineStart, DeleteLeftChar, @@ -50,6 +51,8 @@ namespace MonoDevelop.Ide.Commands ScrollLineDown, ScrollPageUp, ScrollPageDown, + ScrollTop, + ScrollBottom, DeleteLine, DeleteToLineStart, DeleteToLineEnd, diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs index 6f22f4170a..b51601453c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ToolsCommands.cs @@ -43,6 +43,7 @@ namespace MonoDevelop.Ide.Commands InstrumentationViewer, ToggleSessionRecorder, ReplaySession, + EditCustomTools, } internal class AddinManagerHandler : CommandHandler @@ -67,6 +68,8 @@ namespace MonoDevelop.Ide.Commands info.Add (commandInfo, externalTool); } + if (info.Count > 0) + info.AddSeparator (); } protected override void Run (object dataItem) @@ -129,6 +132,19 @@ namespace MonoDevelop.Ide.Commands } } + internal class EditCustomToolsHandler : CommandHandler + { + protected override void Update (CommandInfo info) + { + info.Text = ExternalTools.ExternalToolService.Tools.Count > 0 ? GettextCatalog.GetString ("Edit Custom Tools...") : GettextCatalog.GetString ("Add Custom Tool..."); + } + + protected override void Run () + { + IdeApp.Workbench.ShowGlobalPreferencesDialog (IdeApp.Workbench.RootWindow, "ExternalTools"); + } + } + internal class InstrumentationViewerHandler : CommandHandler { protected override void Run () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs index 55b2eccd15..f4a13b65ff 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/ViewCommands.cs @@ -27,6 +27,7 @@ using System; +using System.Linq; using MonoDevelop.Ide.Gui.Dialogs; using MonoDevelop.Core; using MonoDevelop.Ide.Gui; @@ -66,8 +67,10 @@ namespace MonoDevelop.Ide.Commands { protected override void Update (CommandArrayInfo info) { - for (int i = 0; i < IdeApp.Workbench.Pads.Count; i++) { - Pad pad = IdeApp.Workbench.Pads[i]; + string group; + var lastListGroup = new Dictionary <CommandArrayInfo, string>(); + + foreach (Pad pad in IdeApp.Workbench.Pads.OrderBy (p => p.Group, StringComparer.InvariantCultureIgnoreCase)) { CommandInfo ci = new CommandInfo(pad.Title); ci.Icon = pad.Icon; @@ -97,14 +100,25 @@ namespace MonoDevelop.Ide.Commands } } } + + int atIndex = 0; for (int j = list.Count - 1; j >= 0; j--) { - if (!(list[j] is CommandInfoSet)) { - list.Insert (j + 1, ci, pad); - pad = null; + if (!(list [j] is CommandInfoSet)) { + atIndex = j + 1; break; } } - if (pad != null) list.Insert (0, ci, pad); + + list.Insert (atIndex, ci, pad); + lastListGroup.TryGetValue (list, out group); + if (group != pad.Group) { + lastListGroup [list] = pad.Group; + if (atIndex > 0) { + CommandInfo sep = new CommandInfo ("-"); + sep.IsArraySeparator = true; + list.Insert (atIndex, sep, null); + } + } } } @@ -122,10 +136,24 @@ namespace MonoDevelop.Ide.Commands // MonoDevelop.Ide.Commands.ViewCommands.LayoutList public class LayoutListHandler : CommandHandler { + static internal readonly Dictionary<string, string> NameMapping; + + static LayoutListHandler () + { + NameMapping = new Dictionary<string, string> (); + NameMapping ["Solution"] = "Code"; + NameMapping ["Visual Design"] = "Design"; + NameMapping ["Debug"] = "Debug"; + NameMapping ["Unit Testing"] = "Test"; + } + protected override void Update (CommandArrayInfo info) { + string text; foreach (var name in IdeApp.Workbench.Layouts) { - CommandInfo item = new CommandInfo(GettextCatalog.GetString (name)); + if (!NameMapping.TryGetValue (name, out text)) + text = name; + CommandInfo item = new CommandInfo(GettextCatalog.GetString (text)); item.Checked = IdeApp.Workbench.CurrentLayout == name; item.Description = GettextCatalog.GetString ("Switch to layout '{0}'", name); info.Add (item, name); @@ -163,10 +191,20 @@ namespace MonoDevelop.Ide.Commands protected override void Update (CommandInfo info) { info.Enabled = !String.Equals ("Solution", IdeApp.Workbench.CurrentLayout, StringComparison.OrdinalIgnoreCase); + string itemName; + if (!LayoutListHandler.NameMapping.TryGetValue (IdeApp.Workbench.CurrentLayout, out itemName)) + itemName = IdeApp.Workbench.CurrentLayout; + if (info.Enabled) + info.Text = GettextCatalog.GetString ("_Delete \u201C{0}\u201D Layout", itemName); + else + info.Text = GettextCatalog.GetString ("_Delete Current Layout"); } protected override void Run () { - if (MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to delete the active layout?"), AlertButton.Delete)) { + string itemName; + if (!LayoutListHandler.NameMapping.TryGetValue (IdeApp.Workbench.CurrentLayout, out itemName)) + itemName = IdeApp.Workbench.CurrentLayout; + if (MessageService.Confirm (GettextCatalog.GetString ("Are you sure you want to delete the \u201C{0}\u201D layout?", itemName), AlertButton.Delete)) { string clayout = IdeApp.Workbench.CurrentLayout; IdeApp.Workbench.CurrentLayout = "Solution"; IdeApp.Workbench.DeleteLayout (clayout); @@ -291,7 +329,9 @@ namespace MonoDevelop.Ide.Commands { protected override void Update (CommandInfo info) { - info.Enabled = DockNotebook.ActiveNotebook != null && DockNotebook.ActiveNotebook.TabCount > 1 && DockNotebook.ActiveNotebook.Container.AllowRightInsert; + info.Checked = DockNotebook.ActiveNotebook?.Container?.SplitCount > 0; + info.Enabled = (DockNotebook.ActiveNotebook?.TabCount > 1 && + DockNotebook.ActiveNotebook?.Container?.AllowRightInsert == true) || DockNotebook.ActiveNotebook?.Container?.SplitCount > 0; } protected override void Run () @@ -311,7 +351,9 @@ namespace MonoDevelop.Ide.Commands { protected override void Update (CommandInfo info) { - info.Enabled = DockNotebook.ActiveNotebook != null && DockNotebook.ActiveNotebook.Container.SplitCount > 0; + info.Checked = DockNotebook.ActiveNotebook?.Container?.SplitCount < 1; + info.Enabled = (DockNotebook.ActiveNotebook?.TabCount > 1 && + DockNotebook.ActiveNotebook?.Container?.AllowRightInsert == true) || DockNotebook.ActiveNotebook?.Container?.SplitCount > 0; } protected override void Run () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs index fecd08e174..9eb216750e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Commands/WindowCommands.cs @@ -134,12 +134,15 @@ namespace MonoDevelop.Ide.Commands { protected override void Update (CommandArrayInfo info) { + var windows = IdeApp.CommandService.TopLevelWindowStack.ToArray (); // enumerate only once + if (windows.Length <= 1) + return; int i = 0; - foreach (Gtk.Window window in IdeApp.CommandService.TopLevelWindowStack) { + foreach (Gtk.Window window in windows) { //Create CommandInfo object CommandInfo commandInfo = new CommandInfo (); - commandInfo.Text = window.Title.Replace ("_", "__"); + commandInfo.Text = window.Title.Replace ("_", "__").Replace("-","\u2013").Replace(" \u2013 " + BrandingService.ApplicationName, ""); if (window.HasToplevelFocus) commandInfo.Checked = true; commandInfo.Description = GettextCatalog.GetString ("Activate window '{0}'", commandInfo.Text); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index 1a4c3e94d6..6a2e5eafc1 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -507,5 +507,36 @@ namespace MonoDevelop.Ide.Desktop window.Move (x, y); window.Resize (width, height); } + + /// <summary> + /// Restarts MonoDevelop + /// </summary> + /// <param name="reopenWorkspace"> true to reopen current workspace. </param> + internal virtual void RestartIde (bool reopenWorkspace) + { + var reopen = reopenWorkspace && IdeApp.Workspace != null && IdeApp.Workspace.Items.Count > 0; + + FilePath path = Environment.GetCommandLineArgs ()[0]; + if (Platform.IsMac && path.Extension == ".exe") + path = path.ChangeExtension (null); + + if (!File.Exists (path)) + throw new Exception (path + " not found"); + + var proc = new Process (); + + var psi = new ProcessStartInfo (path) { + CreateNoWindow = true, + UseShellExecute = false, + WorkingDirectory = Environment.CurrentDirectory, + }; + + var recentWorkspace = reopen ? DesktopService.RecentFiles.GetProjects ().FirstOrDefault ()?.FileName : string.Empty; + if (!string.IsNullOrEmpty (recentWorkspace)) + psi.Arguments = recentWorkspace; + + proc.StartInfo = psi; + proc.Start (); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs index 6c3e766af6..151e6a52bd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/CompletionTextEditorExtension.cs @@ -125,6 +125,8 @@ namespace MonoDevelop.Ide.Editor.Extension deleteOrBackspaceTriggerChar = Editor.GetCharAt (Editor.CaretOffset - 1); res = base.KeyPress (descriptor); + if (descriptor.KeyChar == (char)16 || descriptor.KeyChar == (char)17) + return res; CompletionWindowManager.PostProcessKeyEvent (descriptor); @@ -351,7 +353,8 @@ namespace MonoDevelop.Ide.Editor.Extension } } - [CommandHandler(TextEditorCommands.ShowCodeTemplateWindow)] + [CommandHandler (TextEditorCommands.ShowCodeTemplateWindow)] + [CommandHandler (TextEditorCommands.ShowCodeSurroundingsWindow)] public virtual void RunShowCodeTemplatesWindow () { ICompletionDataList completionList = null; @@ -375,22 +378,46 @@ namespace MonoDevelop.Ide.Editor.Extension [CommandUpdateHandler(TextEditorCommands.ShowCodeTemplateWindow)] internal void OnUpdateShowCodeTemplatesWindow (CommandInfo info) { - ICompletionDataList completionList = null; - int cpos, wlen; - if (!GetCompletionCommandOffset (out cpos, out wlen)) { - cpos = Editor.CaretOffset; - wlen = 0; + info.Enabled = !Editor.IsSomethingSelected; + info.Bypass = !info.Enabled; + if (info.Enabled) { + int cpos, wlen; + if (!GetCompletionCommandOffset (out cpos, out wlen)) { + cpos = Editor.CaretOffset; + wlen = 0; + } + try { + var ctx = CompletionWidget.CreateCodeCompletionContext (cpos); + ctx.TriggerWordLength = wlen; + + info.Bypass = ShowCodeTemplatesCommand (ctx) == null; + } catch (Exception e) { + LoggingService.LogError ("Error while update show code templates window", e); + info.Bypass = true; + } } - try { - var ctx = CompletionWidget.CreateCodeCompletionContext (cpos); - ctx.TriggerWordLength = wlen; - completionList = Editor.IsSomethingSelected ? ShowCodeSurroundingsCommand (ctx) : ShowCodeTemplatesCommand (ctx); - - info.Bypass = completionList == null; - info.Text = Editor.IsSomethingSelected ? GettextCatalog.GetString ("_Surround With...") : GettextCatalog.GetString ("I_nsert Template..."); - } catch (Exception e) { - LoggingService.LogError ("Error while update show code templates window", e); - info.Bypass = true; + } + + [CommandUpdateHandler (TextEditorCommands.ShowCodeSurroundingsWindow)] + internal void OnUpdateSelectionSurroundWith (CommandInfo info) + { + info.Enabled = Editor.IsSomethingSelected; + info.Bypass = !info.Enabled; + if (info.Enabled) { + int cpos, wlen; + if (!GetCompletionCommandOffset (out cpos, out wlen)) { + cpos = Editor.CaretOffset; + wlen = 0; + } + try { + var ctx = CompletionWidget.CreateCodeCompletionContext (cpos); + ctx.TriggerWordLength = wlen; + + info.Bypass = ShowCodeSurroundingsCommand (ctx) == null; + } catch (Exception e) { + LoggingService.LogError ("Error while update show code surroundings window", e); + info.Bypass = true; + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/DefaultCommandTextEditorExtension.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/DefaultCommandTextEditorExtension.cs index 11f68e1c2e..d377a98b20 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/DefaultCommandTextEditorExtension.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Extension/DefaultCommandTextEditorExtension.cs @@ -27,6 +27,7 @@ using System; using System.Collections.Generic; using System.Linq; using MonoDevelop.Components.Commands; +using MonoDevelop.Core; using MonoDevelop.Core.Text; using MonoDevelop.Ide.Commands; using MonoDevelop.Ide.TypeSystem; @@ -258,6 +259,9 @@ namespace MonoDevelop.Ide.Editor.Extension var marker = (IMessageBubbleLineMarker)Editor.GetLineMarkers (line).FirstOrDefault (m => m is IMessageBubbleLineMarker); info.Visible = marker != null; + + if (info.Visible) + info.Text = marker.IsVisible ? GettextCatalog.GetString ("_Hide Current Message") : GettextCatalog.GetString ("_Show Hidden Message"); } [CommandHandler (MessageBubbleCommands.Toggle)] diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs index 83a9630d7c..24678e6261 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/ColorScheme.cs @@ -551,6 +551,14 @@ namespace MonoDevelop.Ide.Editor.Highlighting [ColorDescription(DiffLocationKey)] //not defined public ChunkStyle DiffLocation { get; private set; } + public const string PreviewDiffRemovedKey = "Preview Diff Removed Line"; + [ColorDescription (PreviewDiffRemovedKey)] //not defined + public ChunkStyle PreviewDiffRemoved { get; private set; } + + public const string PreviewDiffAddeddKey = "Preview Diff Added Line"; + [ColorDescription (PreviewDiffAddeddKey)] //not defined + public ChunkStyle PreviewDiffAddedd { get; private set; } + public const string HtmlAttributeNameKey = "Html Attribute Name"; [ColorDescription(HtmlAttributeNameKey, VSSetting="HTML Attribute")] public ChunkStyle HtmlAttributeName { get; private set; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Util/Diff.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Util/Diff.cs index 364b0f2288..006602055d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Util/Diff.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Util/Diff.cs @@ -249,11 +249,8 @@ namespace MonoDevelop.Ide.Editor.Util { int lineA = 0; int lineB = 0; - while (lineA < baseData.Length || lineB < changedData - .Length) { - if (lineA < baseData.Length && !baseData.Modified[lineA] && lineB < changedData - .Length && !changedData - .Modified[lineB]) { + while (lineA < baseData.Length || lineB < changedData.Length) { + if (lineA < baseData.Length && !baseData.Modified[lineA] && lineB < changedData.Length && !changedData.Modified[lineB]) { // equal lines lineA++; lineB++; @@ -263,14 +260,11 @@ namespace MonoDevelop.Ide.Editor.Util int startA = lineA; int startB = lineB; - while (lineA < baseData.Length && (lineB >= changedData - .Length || baseData.Modified[lineA])) + while (lineA < baseData.Length && (lineB >= changedData.Length || baseData.Modified[lineA])) // while (LineA < DataA.Length && DataA.Modified[LineA]) lineA++; - while (lineB < changedData - .Length && (lineA >= baseData.Length || changedData - .Modified[lineB])) + while (lineB < changedData.Length && (lineA >= baseData.Length || changedData.Modified[lineB])) // while (LineB < DataB.Length && DataB.Modified[LineB]) lineB++; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditSession.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditSession.cs index 8d74eb7971..03becb09be 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditSession.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditSession.cs @@ -73,6 +73,7 @@ namespace MonoDevelop.Ide.Editor if (editor == null) throw new InvalidOperationException ("Session not yet started."); if (StartOffset > editor.CaretOffset || EndOffset < editor.CaretOffset) { + Console.WriteLine ($"session ended !!!! {StartOffset}-{EndOffset}:{editor.CaretOffset}"); editor.EndSession (); return false; } @@ -163,11 +164,12 @@ namespace MonoDevelop.Ide.Editor endOffset = StartOffset + 1; } - public override void AfterBackspace () + public override void BeforeBackspace (out bool handledCommand) { - if (Editor.CaretOffset == StartOffset) { + if (Editor.CaretOffset == StartOffset + 1) { Editor.EndSession (); } + base.BeforeBackspace (out handledCommand); } public override void AfterDelete () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/IReadonlyTextDocument.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/IReadonlyTextDocument.cs index 616e2fd1d1..eab7151462 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/IReadonlyTextDocument.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/IReadonlyTextDocument.cs @@ -55,6 +55,18 @@ namespace MonoDevelop.Ide.Editor IDocumentLine GetLineByOffset (int offset); } + public sealed class DiffOptions + { + public bool IncludeEol { get; private set; } + public bool TrimLines { get; private set; } + + public DiffOptions (bool includeEol = true, bool trimLines = false) + { + IncludeEol = includeEol; + TrimLines = trimLines; + } + } + public static class ReadonlyTextDocumentExtensions { /// <summary> @@ -156,17 +168,19 @@ namespace MonoDevelop.Ide.Editor return document.GetTextAt (includeDelimiter ? line.SegmentIncludingDelimiter : line); } - static int[] GetDiffCodes (IReadonlyTextDocument document, ref int codeCounter, Dictionary<string, int> codeDictionary, bool includeEol) + static int [] GetDiffCodes (IReadonlyTextDocument document, ref int codeCounter, Dictionary<string, int> codeDictionary, DiffOptions options) { int i = 0; - var result = new int[document.LineCount]; + var result = new int [document.LineCount]; foreach (var line in document.GetLinesStartingAt (1)) { - string lineText = document.GetTextAt (line.Offset, includeEol ? line.LengthIncludingDelimiter : line.Length); + string lineText = document.GetTextAt (line.Offset, options.IncludeEol ? line.LengthIncludingDelimiter : line.Length); + if (options.TrimLines) + lineText = lineText.Trim (); int curCode; if (!codeDictionary.TryGetValue (lineText, out curCode)) { - codeDictionary[lineText] = curCode = ++codeCounter; + codeDictionary [lineText] = curCode = ++codeCounter; } - result[i] = curCode; + result [i] = curCode; i++; } return result; @@ -180,8 +194,21 @@ namespace MonoDevelop.Ide.Editor throw new ArgumentNullException ("changedDocument"); var codeDictionary = new Dictionary<string, int> (); int codeCounter = 0; - return Diff.GetDiff<int> (GetDiffCodes (document, ref codeCounter, codeDictionary, includeEol), - GetDiffCodes (changedDocument, ref codeCounter, codeDictionary, includeEol)); + var options = new DiffOptions (includeEol); + return Diff.GetDiff<int> (GetDiffCodes (document, ref codeCounter, codeDictionary, options), + GetDiffCodes (changedDocument, ref codeCounter, codeDictionary, options)); + } + + public static IEnumerable<DiffHunk> GetDiff (this IReadonlyTextDocument document, IReadonlyTextDocument changedDocument, DiffOptions options) + { + if (document == null) + throw new ArgumentNullException ("document"); + if (changedDocument == null) + throw new ArgumentNullException ("changedDocument"); + var codeDictionary = new Dictionary<string, int> (); + int codeCounter = 0; + return Diff.GetDiff<int> (GetDiffCodes (document, ref codeCounter, codeDictionary, options), + GetDiffCodes (changedDocument, ref codeCounter, codeDictionary, options)); } public static string GetDiffAsString (this IReadonlyTextDocument document, IReadonlyTextDocument changedDocument, bool includeEol = true) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs index 01cb63e9ad..e6cb66a54d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs @@ -215,7 +215,10 @@ namespace MonoDevelop.Ide.Editor IEnumerable<IDocumentLine> VisibleLines { get; } + void GrabFocus (); + event EventHandler<LineEventArgs> LineShown; event EventHandler FocusLost; - } + +} }
\ No newline at end of file diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/MessageBubbles/MessageBubbleCommands.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/MessageBubbles/MessageBubbleCommands.cs index 2e81871cff..4e49724834 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/MessageBubbles/MessageBubbleCommands.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/MessageBubbles/MessageBubbleCommands.cs @@ -42,7 +42,7 @@ namespace MonoDevelop.Ide.Editor protected override void Update (CommandInfo info) { base.Update (info); - info.Text = IdeApp.Preferences.DefaultHideMessageBubbles ? GettextCatalog.GetString ("_Show Message Bubbles") : GettextCatalog.GetString ("_Hide Message Bubbles"); + info.Checked = IdeApp.Preferences.DefaultHideMessageBubbles; } protected override void Run (object data) @@ -62,15 +62,17 @@ namespace MonoDevelop.Ide.Editor protected override void Update (CommandArrayInfo ainfo) { - CommandInfo info = ainfo.Add (GettextCatalog.GetString ("_Errors & Warnings"), new Action (delegate { - MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles.Value = MonoDevelop.Ide.ShowMessageBubbles.ForErrorsAndWarnings; + CommandInfo info = ainfo.Add (GettextCatalog.GetString ("E_rrors"), new Action (delegate { + IdeApp.Preferences.ShowMessageBubbles.Value = ShowMessageBubbles.ForErrors; + IdeApp.Preferences.DefaultHideMessageBubbles.Value = false; })); - info.Checked = MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles == MonoDevelop.Ide.ShowMessageBubbles.ForErrorsAndWarnings; - - info = ainfo.Add (GettextCatalog.GetString ("E_rrors only"), new Action (delegate { - MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles.Value = MonoDevelop.Ide.ShowMessageBubbles.ForErrors; + info.Checked = !IdeApp.Preferences.DefaultHideMessageBubbles && IdeApp.Preferences.ShowMessageBubbles.Value == ShowMessageBubbles.ForErrors; + + info = ainfo.Add (GettextCatalog.GetString ("_Errors and Warnings"), new Action (delegate { + IdeApp.Preferences.ShowMessageBubbles.Value = ShowMessageBubbles.ForErrorsAndWarnings; + IdeApp.Preferences.DefaultHideMessageBubbles.Value = false; })); - info.Checked = MonoDevelop.Ide.IdeApp.Preferences.ShowMessageBubbles.Value == MonoDevelop.Ide.ShowMessageBubbles.ForErrors; + info.Checked = !IdeApp.Preferences.DefaultHideMessageBubbles && IdeApp.Preferences.ShowMessageBubbles == ShowMessageBubbles.ForErrorsAndWarnings; } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs index 4fa307c305..1e35a1b4ec 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs @@ -1425,5 +1425,10 @@ namespace MonoDevelop.Ide.Editor internal ITextEditorImpl Implementation { get { return this.textEditorImpl; } } public event EventHandler FocusLost { add { textEditorImpl.FocusLost += value; } remove { textEditorImpl.FocusLost -= value; } } + + public new void GrabFocus () + { + this.textEditorImpl.GrabFocus (); + } } -}
\ No newline at end of file +} diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs index f504105b48..b81f308070 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchProgressMonitor.cs @@ -47,7 +47,7 @@ namespace MonoDevelop.Ide.FindInFiles internal SearchProgressMonitor (Pad pad, CancellationTokenSource cancellationTokenSource = null): base (Runtime.MainSynchronizationContext, cancellationTokenSource) { - AddFollowerMonitor (IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Searching..."), Stock.StatusSearch, false, true, false, pad)); + AddFollowerMonitor (IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (GettextCatalog.GetString ("Searching..."), Stock.StatusSearch, false, true, false, pad, true)); outputPad = (SearchResultPad) pad.Content; outputPad.CancellationTokenSource = CancellationTokenSource; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs index e77549f160..28b3e40988 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.FindInFiles/SearchResultWidget.cs @@ -45,6 +45,7 @@ using MonoDevelop.Ide.Editor; using MonoDevelop.Core.Text; using MonoDevelop.Ide.Editor.Highlighting; using System.Threading.Tasks; +using MonoDevelop.Ide.TypeSystem; namespace MonoDevelop.Ide.FindInFiles { @@ -395,8 +396,6 @@ namespace MonoDevelop.Ide.FindInFiles fileNamePixbufRenderer.Image = DesktopService.GetIconForFile (searchResult.FileName, IconSize.Menu); } - - static string MarkupText (string text, bool didRead) { return string.Format ("<span weight=\"{1}\">{0}</span>", GLib.Markup.EscapeText (text), didRead ? "normal" : "bold"); @@ -543,14 +542,15 @@ namespace MonoDevelop.Ide.FindInFiles return; } string textMarkup = markupCache.FirstOrDefault (t =>t.Item1 == searchResult)?.Item2; - + bool isSelected = treeviewSearchResults.Selection.IterIsSelected (iter); + if (isSelected) + textMarkup = null; if (textMarkup == null) { var doc = GetDocument (searchResult); if (doc == null) { textMarkup = "Can't create document for:" + searchResult.FileName; goto end; } - bool isSelected = treeviewSearchResults.Selection.IterIsSelected (iter); int lineNumber, startIndex = 0, endIndex = 0; try { lineNumber = doc.OffsetToLineNumber (searchResult.Offset); @@ -572,8 +572,13 @@ namespace MonoDevelop.Ide.FindInFiles if (col + searchResult.Length < lineText.Length) lineText = doc.GetTextAt (line.Offset, line.Length); - var markup = doc.GetPangoMarkup (line.Offset + indent, line.Length - indent); - markup = AdjustColors(markup); + string markup; + if (isSelected) { + markup = Ambience.EscapeText (doc.GetTextAt (line.Offset + indent, line.Length - indent)); + } else { + markup = doc.GetPangoMarkup (line.Offset + indent, line.Length - indent); + markup = AdjustColors (markup); + } if (col >= 0) { uint start; @@ -609,15 +614,21 @@ namespace MonoDevelop.Ide.FindInFiles if (startIndex != endIndex) { textMarkup = PangoHelper.ColorMarkupBackground (textMarkup, (int)startIndex, (int)endIndex, searchColor); } + } else { + var searchColor = this.treeviewSearchResults.Style.Base (StateType.Selected); + searchColor = searchColor.AddLight (-0.2); + textMarkup = PangoHelper.ColorMarkupBackground (textMarkup, (int)startIndex, (int)endIndex, searchColor); } } catch (Exception e) { LoggingService.LogError ("Error whil setting the text renderer markup to: " + markup, e); } end: textMarkup = textMarkup.Replace ("\t", new string (' ', doc.Options.TabSize)); - markupCache.Add (Tuple.Create(searchResult, textMarkup)); - if (markupCache.Count > 100) - markupCache.RemoveAt (0); + if (!isSelected) { + markupCache.Add (Tuple.Create (searchResult, textMarkup)); + if (markupCache.Count > 100) + markupCache.RemoveAt (0); + } } textRenderer.Markup = textMarkup; } @@ -926,7 +937,7 @@ namespace MonoDevelop.Ide.FindInFiles markupBuilder.Append (ch); i++; } - if (!closed && !opened) + if (!closed && opened) markupBuilder.Append ("</span>"); return markupBuilder.ToString (); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewLayoutDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewLayoutDialog.cs index 938bd2991c..bfb46c7055 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewLayoutDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/NewLayoutDialog.cs @@ -18,8 +18,11 @@ namespace MonoDevelop.Ide.Gui.Dialogs public NewLayoutDialog () { Build (); - - existingLayouts = IdeApp.Workbench.Layouts; + + existingLayouts = IdeApp.Workbench.Layouts.ToList (); + foreach (var mapping in Commands.LayoutListHandler.NameMapping) + if (existingLayouts.Contains (mapping.Key)) + existingLayouts.Add (mapping.Value); layoutName.Changed += OnNameChanged; OnNameChanged (layoutName, EventArgs.Empty); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs index e749035dee..5811a86f9a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Dialogs/OptionsDialog.cs @@ -424,6 +424,7 @@ namespace MonoDevelop.Ide.Gui.Dialogs TreeIter cit; if (removeEmptySections && page.Panels.Count == 0 && !store.IterChildren (out cit, it)) { store.Remove (ref it); + pages.Remove (section); return TreeIter.Zero; } return it; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/IDEStyleOptionsPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/IDEStyleOptionsPanel.cs index f931d001be..4c2cd3ac9e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/IDEStyleOptionsPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/IDEStyleOptionsPanel.cs @@ -113,6 +113,38 @@ namespace MonoDevelop.Ide.Gui.OptionPanels comboTheme.Active = sel; comboTheme.Changed += ComboThemeChanged; + tableRestart.Visible = separatorRestart.Visible = false; + labelRestart.LabelProp = GettextCatalog.GetString ("These preferences will take effect next time you start {0}", BrandingService.ApplicationName); + btnRestart.Label = GettextCatalog.GetString ("Restart {0}", BrandingService.ApplicationName); + + comboLanguage.Changed += (sender, e) => UpdateRestartMessage(); + comboTheme.Changed += (sender, e) => UpdateRestartMessage (); + UpdateRestartMessage (); + } + + void RestartClicked (object sender, System.EventArgs e) + { + Store (); + IdeApp.Restart (true); + } + + void UpdateRestartMessage () + { + bool restartRequired = false; + + if (currentTheme != IdeApp.Preferences.UserInterfaceThemeName.Value || + ((Platform.IsLinux && Gtk.Settings.Default.ThemeName != IdeApp.Preferences.UserInterfaceThemeName.Value) || + IdeTheme.UserInterfaceTheme != (IdeApp.Preferences.UserInterfaceThemeName == "Dark" ? Theme.Dark : Theme.Light))) + restartRequired = true; + + if (GettextCatalog.UILocale != IdeApp.Preferences.UserInterfaceLanguage || + LocalizationService.CurrentLocaleSet [comboLanguage.Active].Culture != IdeApp.Preferences.UserInterfaceLanguage) + restartRequired = true; + + if (restartRequired) { + tableRestart.Visible = separatorRestart.Visible = true; + } else + tableRestart.Visible = separatorRestart.Visible = false; } void ComboThemeChanged (object sender, EventArgs e) @@ -175,25 +207,11 @@ namespace MonoDevelop.Ide.Gui.OptionPanels public void Store() { string lc = LocalizationService.CurrentLocaleSet [comboLanguage.Active].Culture; - if (lc != IdeApp.Preferences.UserInterfaceLanguage) { + if (lc != IdeApp.Preferences.UserInterfaceLanguage) IdeApp.Preferences.UserInterfaceLanguage.Value = lc; - MessageService.ShowMessage ( - GettextCatalog.GetString ( - "The user interface language change will take effect the next time you start {0}", - BrandingService.ApplicationName - ) - ); - } - if (currentTheme != IdeApp.Preferences.UserInterfaceThemeName.Value) { + if (currentTheme != IdeApp.Preferences.UserInterfaceThemeName.Value) IdeApp.Preferences.UserInterfaceThemeName.Value = currentTheme; - MessageService.ShowMessage ( - GettextCatalog.GetString ( - "The user interface theme change will take effect the next time you start {0}", - BrandingService.ApplicationName - ) - ); - } } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs index 115b78ba70..98e86aba2c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/KeyBindingsPanel.cs @@ -61,6 +61,11 @@ namespace MonoDevelop.Ide.Gui.OptionPanels bool filterChanged; string[] processedFilterTerms; bool filterTimeoutRunning; + + TreeViewColumn bindingTVCol; + + Dictionary<string, HashSet<Command>> duplicates; + Dictionary<string, HashSet<Command>> conflicts; public KeyBindingsPanel () { @@ -83,11 +88,13 @@ namespace MonoDevelop.Ide.Gui.OptionPanels col.AddAttribute (crt, "weight", boldCol); keyTreeView.AppendColumn (col); - TreeViewColumn bindingTVCol = new TreeViewColumn (); + bindingTVCol = new TreeViewColumn (); bindingTVCol.Title = GettextCatalog.GetString ("Key Binding"); - CellRendererText bindingRenderer = new CellRendererText (); + CellRendererKeyButtons bindingRenderer = new CellRendererKeyButtons (this); + bindingRenderer.KeyBindingSelected += BindingRenderer_KeyBindingSelected; bindingTVCol.PackStart (bindingRenderer, false); - bindingTVCol.SetCellDataFunc (bindingRenderer, BindingTVDataFunc); + bindingTVCol.AddAttribute (bindingRenderer, "text", bindingCol); + bindingTVCol.AddAttribute (bindingRenderer, "command", commandCol); keyTreeView.AppendColumn (bindingTVCol); keyTreeView.AppendColumn (GettextCatalog.GetString ("Description"), new CellRendererText (), "text", descCol); @@ -100,14 +107,24 @@ namespace MonoDevelop.Ide.Gui.OptionPanels UpdateWarningLabel (); }; updateButton.Clicked += OnUpdateButtonClick; + addButton.Clicked += OnAddRemoveButtonClick; currentBindings = KeyBindingService.CurrentKeyBindingSet.Clone (); schemes = new List<KeyBindingScheme> (KeyBindingService.Schemes); - schemeCombo.AppendText (GettextCatalog.GetString ("Custom")); foreach (KeyBindingScheme s in schemes) schemeCombo.AppendText (s.Name); + + if (schemes.Count > 0) { + schemeCombo.RowSeparatorFunc = (TreeModel model, TreeIter iter) => { + if (model.GetValue (iter, 0) as string == "---") + return true; + return false; + }; + schemeCombo.AppendText ("---"); + } + schemeCombo.AppendText (GettextCatalog.GetString ("Custom")); SelectCurrentScheme (); schemeCombo.Changed += OnKeyBindingSchemeChanged; @@ -140,14 +157,6 @@ namespace MonoDevelop.Ide.Gui.OptionPanels conflicButton.UseUnderline = true; } - static void BindingTVDataFunc (TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) - { - string binding = (model.GetValue (iter, bindingCol) as string) ?? ""; - ((CellRendererText)cell).Text = binding.Length > 0 - ? KeyBindingManager.BindingToDisplayLabel (binding, false) - : binding; - } - void Refilter () { keyTreeView.Model = null; @@ -206,11 +215,11 @@ namespace MonoDevelop.Ide.Gui.OptionPanels for (int n=0; n<schemes.Count; n++) { KeyBindingScheme s = schemes [n]; if (currentBindings.Equals (s.GetKeyBindingSet ())) { - schemeCombo.Active = n + 1; + schemeCombo.Active = n; return; } } - schemeCombo.Active = 0; + schemeCombo.Active = schemes.Count + 1; } finally { internalUpdate = false; } @@ -255,8 +264,8 @@ namespace MonoDevelop.Ide.Gui.OptionPanels int catCompare = cat1.CompareTo (cat2); if (catCompare != 0) return catCompare; - string t1 = c1.Text.Replace ("_", String.Empty); - string t2 = c2.Text.Replace ("_", String.Empty); + string t1 = c1.DisplayName; + string t2 = c2.DisplayName; return t1.CompareTo (t2); }); @@ -268,10 +277,13 @@ namespace MonoDevelop.Ide.Gui.OptionPanels string name = currentCat.Length == 0? translatedOther : currentCat; icat = keyStore.AppendValues (null, name, String.Empty, String.Empty, (int) Pango.Weight.Bold, null, false, true); } - string label = cmd.Text.Replace ("_", String.Empty); - keyStore.AppendValues (icat, cmd, label, cmd.AccelKey != null ? cmd.AccelKey : String.Empty, cmd.Description, (int) Pango.Weight.Normal, (string)cmd.Icon, true, true); + string label = cmd.DisplayName; + string accels = cmd.AccelKey != null ? cmd.AccelKey : String.Empty; + if (cmd.AlternateAccelKeys != null && cmd.AlternateAccelKeys.Length > 0) + accels += " " + string.Join (" ", cmd.AlternateAccelKeys); + keyStore.AppendValues (icat, cmd, label, accels, cmd.Description, (int) Pango.Weight.Normal, (string)cmd.Icon, true, true); } - UpdateGlobalWarningLabel (); + UpdateConflictsWarning (); Refilter (); return this; } @@ -281,7 +293,7 @@ namespace MonoDevelop.Ide.Gui.OptionPanels if (internalUpdate) return; - if (schemeCombo.Active == 0) + if (schemeCombo.Active == schemes.Count + 1) return; Command command; @@ -300,35 +312,50 @@ namespace MonoDevelop.Ide.Gui.OptionPanels keyStore.IterChildren (out citer, iter); do { command = (Command) keyStore.GetValue (citer, commandCol); - binding = currentBindings.GetBinding (command); + binding = string.Join (" ", currentBindings.GetBindings (command)); keyStore.SetValue (citer, bindingCol, binding); } while (keyStore.IterNext (ref citer)); } while (keyStore.IterNext (ref iter)); - UpdateGlobalWarningLabel (); + UpdateConflictsWarning (); } - + + void BindingRenderer_KeyBindingSelected (object sender, KeyBindingSelectedEventArgs e) + { + accelComplete = false; + + accelEntry.Sensitive = true; + CurrentSelectedBinding = e; + //grab focus AFTER the event, or focus gets screwy + GLib.Timeout.Add (10, delegate { + accelEntry.GrabFocus (); + return false; + }); + accelIncomplete = false; + accelComplete = true; + } + void OnKeysTreeViewSelectionChange (object sender, EventArgs e) { TreeSelection sel = sender as TreeSelection; TreeModel model; TreeIter iter; - - accelComplete = false; - - if (sel.GetSelected (out model, out iter) && model.GetValue (iter,commandCol) != null) { - accelEntry.Sensitive = true; - CurrentBinding = (string) model.GetValue (iter, bindingCol); - //grab focus AFTER the selection event, or focus gets screwy - GLib.Timeout.Add (10, delegate { - accelEntry.GrabFocus (); - return false; - }); + Command selCommand = null; + if (sel.GetSelected (out model, out iter) && model.GetValue (iter, commandCol) != null) { + selCommand = model.GetValue (iter, commandCol) as Command; + if (CurrentSelectedBinding?.Command == selCommand) // command is already selected + return; + + accelComplete = false; + var binding = model.GetValue (iter, bindingCol) as string; + iter = filterModel.ConvertIterToChildIter (iter); + CurrentSelectedBinding = new KeyBindingSelectedEventArgs (binding.Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries), 0, selCommand, iter); accelIncomplete = false; accelComplete = true; + accelEntry.Sensitive = true; } else { - accelEntry.Sensitive = false; - CurrentBinding = string.Empty; + accelEntry.Sensitive = updateButton.Sensitive = addButton.Sensitive = false; + CurrentSelectedBinding = null; } } @@ -341,7 +368,7 @@ namespace MonoDevelop.Ide.Gui.OptionPanels e.RetVal = true; if (accelComplete) { - CurrentBinding = String.Empty; + CurrentKey = String.Empty; accelIncomplete = false; accelComplete = false; chord = null; @@ -354,7 +381,7 @@ namespace MonoDevelop.Ide.Gui.OptionPanels bool combinationComplete; accel = KeyBindingManager.AccelLabelFromKey (e.Event, out combinationComplete); if (combinationComplete) { - CurrentBinding = KeyBindingManager.Binding (chord, accel); + CurrentKey = KeyBindingManager.Binding (chord, accel); accelIncomplete = false; if (chord != null) accelComplete = true; @@ -363,93 +390,148 @@ namespace MonoDevelop.Ide.Gui.OptionPanels } else { accel = (chord != null ? chord + "|" : string.Empty) + accel; accelIncomplete = true; - CurrentBinding = accel; + CurrentKey = accel; } } - - string _realBinding; - string CurrentBinding { + + string currentKey; + string CurrentKey { get { - return _realBinding; + return currentKey ?? string.Empty; } set { - _realBinding = value; - accelEntry.Text = _realBinding == null? "" : KeyBindingManager.BindingToDisplayLabel (_realBinding, false, true); + currentKey = value; + accelEntry.Text = value == null? "" : KeyBindingManager.BindingToDisplayLabel (value, false, true); + UpdateButtons (); + UpdateWarningLabel (); + } + } + + KeyBindingSelectedEventArgs currentSelectedBinding; + KeyBindingSelectedEventArgs CurrentSelectedBinding { + get { return currentSelectedBinding; } + set { + currentSelectedBinding = value; + if (value == null) { + accelEntry.Text = string.Empty; + return; + } + + CurrentKey = currentSelectedBinding.AllKeys.Count > 0 ? currentSelectedBinding.AllKeys [currentSelectedBinding.SelectedKey] : String.Empty; } } void OnAccelEntryKeyRelease (object sender, KeyReleaseEventArgs e) { if (accelIncomplete) - CurrentBinding = chord != null ? chord : string.Empty; + CurrentKey = chord != null ? chord : string.Empty; + } + + void UpdateButtons () + { + if (CurrentSelectedBinding != null) { + + if (CurrentSelectedBinding.AllKeys.Count == 0 && string.IsNullOrEmpty (currentKey)) { + updateButton.Sensitive = false; + addButton.Sensitive = false; + } else { + if (CurrentSelectedBinding.AllKeys.Contains (currentKey)) { + addButton.Sensitive = true; + addButton.Label = GettextCatalog.GetString ("Delete"); + } else { + addButton.Sensitive = true; + addButton.Label = GettextCatalog.GetString ("Add"); + } + updateButton.Sensitive = !CurrentSelectedBinding.AllKeys.Contains (currentKey); + } + } else { + updateButton.Sensitive = addButton.Sensitive = false; + } } void OnUpdateButtonClick (object sender, EventArgs e) { - TreeIter iter; - Command cmd; - if (GetSelectedCommandIter (out iter, out cmd)) { - keyStore.SetValue (iter, bindingCol, CurrentBinding); - currentBindings.SetBinding (cmd, CurrentBinding); + if (CurrentSelectedBinding != null) { + if (string.IsNullOrEmpty (CurrentKey)) + CurrentSelectedBinding.AllKeys.RemoveAt (CurrentSelectedBinding.SelectedKey); + else if (CurrentSelectedBinding.AllKeys.Count == 0) + CurrentSelectedBinding.AllKeys.Add (CurrentKey); + else + CurrentSelectedBinding.AllKeys [CurrentSelectedBinding.SelectedKey] = CurrentKey; + var binding = string.Join (" ", CurrentSelectedBinding.AllKeys); + keyStore.SetValue (currentSelectedBinding.Iter, bindingCol, binding); + currentBindings.SetBinding (currentSelectedBinding.Command, CurrentSelectedBinding.AllKeys.ToArray ()); SelectCurrentScheme (); + keyTreeView.QueueDraw (); + UpdateButtons (); } - UpdateGlobalWarningLabel (); + UpdateConflictsWarning (); } - - bool GetSelectedCommandIter (out TreeIter iter, out Command cmd) + + void OnAddRemoveButtonClick (object sender, EventArgs e) { - TreeSelection sel = keyTreeView.Selection; - if (!sel.GetSelected (out iter)) { - cmd = null; - return false; + if (CurrentSelectedBinding != null) { + if (string.IsNullOrEmpty (CurrentKey) || CurrentSelectedBinding.AllKeys.Contains (CurrentKey)) + CurrentSelectedBinding.AllKeys.RemoveAt (CurrentSelectedBinding.SelectedKey); + else + CurrentSelectedBinding.AllKeys.Add (CurrentKey); + + var binding = string.Join (" ", CurrentSelectedBinding.AllKeys); + keyStore.SetValue (currentSelectedBinding.Iter, bindingCol, binding); + currentBindings.SetBinding (currentSelectedBinding.Command, CurrentSelectedBinding.AllKeys.ToArray ()); + SelectCurrentScheme (); + keyTreeView.QueueDraw (); + UpdateButtons (); } - - cmd = (Command)filterModel.GetValue (iter, commandCol); - if (cmd == null) - return false; - - if (keyStore.GetIterFirst (out iter) && FindIterForCommand (cmd, iter, out iter)) - return true; - - throw new Exception ("Did not find command in underlying model"); + UpdateConflictsWarning (); } - - bool FindIterForCommand (object cmd, TreeIter iter, out TreeIter found) + + void UpdateConflictsWarning () { - do { - TreeIter child; - if (keyStore.IterChildren (out child, iter) && FindIterForCommand (cmd, child, out found)) - return true; - if (keyStore.GetValue (iter, commandCol) == cmd) { - found = iter; - return true; + duplicates = new Dictionary<string, HashSet<Command>> (); + foreach (var conflict in currentBindings.CheckKeyBindingConflicts (IdeApp.CommandService.GetCommands ())) { + HashSet<Command> cmds = null; + if (!duplicates.TryGetValue (conflict.Key, out cmds)) + duplicates [conflict.Key] = cmds = new HashSet<Command> (); + foreach (var cmd in conflict.Commands) + cmds.Add (cmd); + } + conflicts = new Dictionary<string, HashSet<Command>> (); + + foreach (var dup in duplicates) { + foreach (var cmd in dup.Value) { + HashSet<Command> cmdDuplicates; + if (IdeApp.CommandService.Conflicts.TryGetValue (cmd, out cmdDuplicates)) { + cmdDuplicates = new HashSet<Command> (cmdDuplicates.Intersect (dup.Value)); + if (cmdDuplicates.Count > 0) { + HashSet<Command> cmdConflicts; + if (!conflicts.TryGetValue (dup.Key, out cmdConflicts)) + conflicts [dup.Key] = cmdConflicts = new HashSet<Command> (); + conflicts [dup.Key].UnionWith (cmdDuplicates); + } + } } - } while (keyStore.IterNext (ref iter)); - found = TreeIter.Zero; - return false; - } + } - void UpdateGlobalWarningLabel () - { - KeyBindingConflict[] conflicts = currentBindings.CheckKeyBindingConflicts (IdeApp.CommandService.GetCommands ()); - if (conflicts.Length == 0) { + if (conflicts.Count == 0) { globalWarningBox.Hide (); return; } + globalWarningBox.Show (); conflicButton.ContextMenuRequested = delegate { ContextMenu menu = new ContextMenu (); bool first = true; - foreach (KeyBindingConflict conf in conflicts) { + foreach (var conf in conflicts) { if (first == false) { ContextMenuItem item = new SeparatorContextMenuItem (); menu.Items.Add (item); } - foreach (Command cmd in conf.Commands) { - string txt = currentBindings.GetBinding (cmd) + " - " + cmd.Text; + foreach (Command cmd in conf.Value.OrderBy (cmd => cmd.DisplayName)) { + string txt = conf.Key + " \u2013 " + cmd.DisplayName; ContextMenuItem item = new ContextMenuItem (txt); Command localCmd = cmd; @@ -490,26 +572,28 @@ namespace MonoDevelop.Ide.Gui.OptionPanels void UpdateWarningLabel () { - if (CurrentBinding.Length == 0) { + if (CurrentKey.Length == 0 || CurrentSelectedBinding?.Command == null) { labelMessage.Visible = false; return; } - Command cmd = null; - TreeIter iter; - if (keyTreeView.Selection.GetSelected (out iter)) - cmd = (Command) keyTreeView.Model.GetValue (iter, commandCol); - - if (cmd == null) { - labelMessage.Visible = false; - return; - } - - var bindings = FindBindings (CurrentBinding); - bindings.Remove (cmd); + var bindings = FindBindings (CurrentKey); + bindings.Remove (CurrentSelectedBinding.Command); if (bindings.Count > 0) { - labelMessage.Markup = "<b>" + GettextCatalog.GetString ("This key combination is already bound to command '{0}'", bindings [0].Text.Replace ("_","")) + "</b>"; + HashSet<Command> cmdConflicts = null; + if (IdeApp.CommandService.Conflicts.TryGetValue (CurrentSelectedBinding.Command, out cmdConflicts)) { + foreach (var confl in cmdConflicts) { + if (bindings.Contains (confl)) { + var conflName = "<span foreground='" + Styles.ErrorForegroundColor.ToHexString (false) + "'>" + confl.DisplayName + "</span>"; + labelMessage.Markup = "<b>" + GettextCatalog.GetString ("This key combination is already bound to command '{0}' in the same context", conflName) + "</b>"; + labelMessage.Visible = true; + return; + } + } + } + var cmdname = "<span foreground='" + Styles.WarningForegroundColor.ToHexString (false) + "'>" + bindings [0].DisplayName + "</span>"; + labelMessage.Markup = "<b>" + GettextCatalog.GetString ("This key combination is already bound to command '{0}'", cmdname) + "</b>"; labelMessage.Visible = true; } else @@ -569,11 +653,337 @@ namespace MonoDevelop.Ide.Gui.OptionPanels { } - protected override void OnDestroyed ()
- {
- keyStore.Dispose ();
- filterModel.Dispose ();
- base.OnDestroyed ();
+ protected override void OnDestroyed () + { + keyStore.Dispose (); + filterModel.Dispose (); + base.OnDestroyed (); + } + + class KeyBindingSelectedEventArgs : EventArgs + { + public int SelectedKey { get; private set; } + public List<string> AllKeys { get; private set; } + public Command Command { get; private set; } + public TreeIter Iter { get; private set; } + + public KeyBindingSelectedEventArgs (IEnumerable<string> keys, int selectedKey, Command command, TreeIter iter) + { + if (command == null) + throw new ArgumentNullException (nameof (command)); + AllKeys = new List<string> (keys); + if (selectedKey < 0 || ((selectedKey != 0 && AllKeys.Count != 0) && selectedKey >= AllKeys.Count)) + throw new ArgumentOutOfRangeException (nameof (selectedKey)); + SelectedKey = selectedKey; + Command = command; + Iter = iter; + } + } + + struct KeyBindingHitTestResult + { + public int SelectedKey { get; set; } + public List<string> AllKeys { get; set; } + public Command Command { get; set; } + public TreeIter Iter { get; set; } + public Gdk.Rectangle ButtonBounds { get; set; } + } + + class CellRendererKeyButtons : CellRendererText + { + static Pango.FontDescription KeySymbolFont = Styles.DefaultFont.Copy (); + + const int KeyVPadding = 1; + const int KeyHPadding = 6; + const int KeyBgRadius = 3; + const int Spacing = 6; + KeyBindingsPanel keyBindingsPanel; + TreeView keyBindingsTree; + + TooltipPopoverWindow tooltipWindow; + + [GLib.Property ("command")] + public Command Command { get; set; } + + public event EventHandler<KeyBindingSelectedEventArgs> KeyBindingSelected; + + static CellRendererKeyButtons () + { + // only a couple of OSX fonts support the home/end keys + // and only Lucida Grande with an appropriate symbol size + if (Platform.IsMac) + KeySymbolFont.Family = "Lucida Grande"; + KeySymbolFont.Size -= (int) Pango.Scale.PangoScale * 2; + } + + public CellRendererKeyButtons (KeyBindingsPanel panel) + { + keyBindingsPanel = panel; + keyBindingsTree = panel.keyTreeView; + keyBindingsTree.ButtonPressEvent += HandleKeyTreeButtonPressEvent; + keyBindingsTree.MotionNotifyEvent += HandleKeyTreeMotionNotifyEvent; + keyBindingsTree.ScrollEvent += HandleKeyTreeScrollEvent; + keyBindingsTree.LeaveNotifyEvent += HandleKeyTreeLeaveNotifyEvent; + keyBindingsTree.Unrealized += HandleKeyTreeUnrealized; + } + + void HideConflictTooltip () + { + if (tooltipWindow != null) { + tooltipWindow.Destroy (); + tooltipWindow = null; + } + } + + void HandleKeyTreeLeaveNotifyEvent (object o, LeaveNotifyEventArgs args) + { + HideConflictTooltip (); + } + + void HandleKeyTreeUnrealized (object sender, EventArgs e) + { + HideConflictTooltip (); + } + + void HandleKeyTreeScrollEvent (object o, ScrollEventArgs args) + { + HandleKeyTreeMotion (args.Event.X, args.Event.Y); + } + + [GLib.ConnectBefore ()] + void HandleKeyTreeMotionNotifyEvent (object o, MotionNotifyEventArgs args) + { + HandleKeyTreeMotion (args.Event.X, args.Event.Y); + } + + void HandleKeyTreeMotion (double mouseX, double mouseY) + { + if (keyBindingsPanel.duplicates?.Count <= 0) + return; + + var hit = HitTest (mouseX, mouseY); + if (hit.ButtonBounds.IsEmpty) { + HideConflictTooltip (); + return; + } + + if (hit.AllKeys.Count == 0) + return; + + HashSet<Command> keyDuplicates = null; + if (keyBindingsPanel.duplicates.TryGetValue (hit.AllKeys [hit.SelectedKey], out keyDuplicates)) { + + var cmdDuplicates = keyDuplicates.Where (cmd => cmd != hit.Command); + if (tooltipWindow == null) { + tooltipWindow = new TooltipPopoverWindow (); + tooltipWindow.ShowArrow = true; + tooltipWindow.LeaveNotifyEvent += delegate { HideConflictTooltip (); }; + } + + var text = string.Empty; + HashSet<Command> cmdConflicts = null; + bool hasConflict = false; + if (keyBindingsPanel.conflicts != null && keyBindingsPanel.conflicts.TryGetValue (hit.AllKeys [hit.SelectedKey], out cmdConflicts)) + hasConflict = cmdConflicts.Contains (hit.Command); + + if (hasConflict) { + var acmdConflicts = cmdConflicts.Where (cmd => cmd != hit.Command).ToArray (); + text += GettextCatalog.GetPluralString ( + "This shortcut is assigned to another command that is available\nin the same context. Please set a different shortcut.", + "This shortcut is assigned to other commands that are available\nin the same context. Please set a different shortcut.", + acmdConflicts.Length) + "\n\n"; + text += GettextCatalog.GetString ("Conflicts:"); + foreach (var conflict in acmdConflicts) + text += "\n\u2022 " + conflict.Category + " \u2013 " + conflict.DisplayName; + cmdDuplicates = cmdDuplicates.Except (acmdConflicts); + } + if (cmdDuplicates.Count () > 0) { + if (hasConflict) + text += "\n\n"; + text += GettextCatalog.GetString ("Duplicates:"); + + foreach (var cmd in cmdDuplicates) + text += "\n\u2022 " + cmd.Category + " \u2013 " + cmd.DisplayName; + } + + tooltipWindow.Text = text; + tooltipWindow.Severity = hasConflict ? Tasks.TaskSeverity.Error : Tasks.TaskSeverity.Warning; + + tooltipWindow.ShowPopup (keyBindingsTree, hit.ButtonBounds, PopupPosition.Top); + } else + HideConflictTooltip (); + } + + [GLib.ConnectBefore ()] + void HandleKeyTreeButtonPressEvent (object o, ButtonPressEventArgs args) + { + if (KeyBindingSelected == null) + return; + var hit = HitTest (args.Event.X, args.Event.Y); + if (hit.Command == null) + return; + var a = new KeyBindingSelectedEventArgs (hit.AllKeys, hit.SelectedKey, hit.Command, hit.Iter); + KeyBindingSelected (this, a); + } + + KeyBindingHitTestResult HitTest (double mouseX, double mouseY) + { + KeyBindingHitTestResult result = new KeyBindingHitTestResult (); + TreeIter iter; + TreePath path; + int cellx, celly, mx, my; + mx = (int)mouseX; + my = (int)mouseY; + + if (!GetCellPosition (mx, my, out cellx, out celly, out iter, out path)) + return result; + + Text = keyBindingsTree.Model.GetValue (iter, bindingCol) as string ?? string.Empty; + Command = keyBindingsTree.Model.GetValue (iter, commandCol) as Command; + + var filter = keyBindingsTree.Model as TreeModelFilter; + if (filter != null) + iter = filter.ConvertIterToChildIter (iter); + + result.Command = Command; + result.AllKeys = Text.Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList (); + result.Iter = iter; + + using (var layout = new Pango.Layout (keyBindingsTree.PangoContext)) { + + // GetCellArea reports the outer cell bounds, therefore we need to add 2px + var xpad = (int)Xpad + 2; + var cellBounds = keyBindingsTree.GetCellArea (path, keyBindingsPanel.bindingTVCol); + keyBindingsTree.ConvertBinWindowToWidgetCoords (cellBounds.X, cellBounds.Y, out cellBounds.X, out cellBounds.Y); + int i = 0; + foreach (var key in result.AllKeys) { + layout.SetText (KeyBindingManager.BindingToDisplayLabel (key, false)); + layout.FontDescription = KeySymbolFont; + int w, h; + layout.GetPixelSize (out w, out h); + + int buttonWidth = w + (2 * KeyHPadding); + int buttonHeight = h + (2 * KeyVPadding); + var ypad = 2 + ((cellBounds.Height / 2) - (buttonHeight / 2)); + + if (cellx > xpad && cellx <= xpad + buttonWidth && + celly > ypad && celly <= ypad + buttonHeight) { + keyBindingsPanel.bindingTVCol.CellGetPosition (this, out cellx, out w); + cellBounds.X += cellx; + + result.SelectedKey = i; + result.ButtonBounds = new Gdk.Rectangle (cellBounds.X + xpad, cellBounds.Y + ypad, buttonWidth, buttonHeight); + result.ButtonBounds.Inflate (0, 2); + return result; + } + + xpad += buttonWidth + Spacing; + i++; + } + } + return result; + } + + bool GetCellPosition (int mx, int my, out int cellx, out int celly, out TreeIter iter, out TreePath path) + { + TreeViewColumn col; + iter = TreeIter.Zero; + + if (!keyBindingsTree.GetPathAtPos (mx, my, out path, out col, out cellx, out celly)) + return false; + + if (!keyBindingsTree.Model.GetIterFromString (out iter, path.ToString ())) + return false; + + int sp, w; + if (col.CellGetPosition (this, out sp, out w)) { + if (cellx >= sp && cellx < sp + w) + return true; + } + return false; + } + + protected override void Render (Gdk.Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags) + { + if (string.IsNullOrEmpty (Text)) + return; + + using (var cr = Gdk.CairoHelper.Create (window)) { + using (var layout = new Pango.Layout (widget.PangoContext)) { + var xpad = (int)Xpad; + int w, h; + Cairo.Color bgColor, fgColor; + foreach (var key in Text.Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) { + + HashSet<Command> bindingConflicts; + if (keyBindingsPanel.conflicts.TryGetValue (key, out bindingConflicts) && bindingConflicts.Contains (Command)) { + bgColor = Styles.KeyBindingsPanel.KeyConflictBackgroundColor.ToCairoColor (); + fgColor = Styles.KeyBindingsPanel.KeyConflictForegroundColor.ToCairoColor (); + } else if (keyBindingsPanel.duplicates.ContainsKey (key)) { + bgColor = Styles.KeyBindingsPanel.KeyDuplicateBackgroundColor.ToCairoColor (); + fgColor = Styles.KeyBindingsPanel.KeyDuplicateForegroundColor.ToCairoColor (); + } else { + bgColor = Styles.KeyBindingsPanel.KeyBackgroundColor.ToCairoColor (); + fgColor = Styles.KeyBindingsPanel.KeyForegroundColor.ToCairoColor (); + } + + layout.SetText (KeyBindingManager.BindingToDisplayLabel (key, false)); + layout.FontDescription = KeySymbolFont; + layout.GetPixelSize (out w, out h); + + int buttonWidth = w + (2 * KeyHPadding); + int buttonHeight = h + (2 * KeyVPadding); + int x = cell_area.X + xpad; + double y = cell_area.Y + ((cell_area.Height / 2) - (buttonHeight / 2)); + + cr.RoundedRectangle (x, y, buttonWidth, buttonHeight, KeyBgRadius); + cr.LineWidth = 1; + cr.SetSourceColor (bgColor); + cr.FillPreserve (); + cr.SetSourceColor (bgColor); + cr.Stroke (); + + cr.SetSourceColor (fgColor); + cr.MoveTo (x + KeyHPadding, y + KeyVPadding); + cr.ShowLayout (layout); + xpad += buttonWidth + Spacing; + } + } + } + } + + public override void GetSize (Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height) + { + base.GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height); + x_offset = y_offset = 0; + if (string.IsNullOrEmpty (Text)) { + width = 0; + height = 0; + return; + } + + using (var layout = new Pango.Layout (widget.PangoContext)) { + height = 0; + width = (int)Xpad; + int w, h, buttonWidth; + foreach (var key in Text.Split (new char [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) { + layout.SetText (KeyBindingManager.BindingToDisplayLabel (key, false)); + layout.FontDescription = KeySymbolFont; + layout.GetPixelSize (out w, out h); + if (height == 0) + height = h + (KeyVPadding * 2) + 1; + + buttonWidth = w + (2 * KeyHPadding); + width += buttonWidth + Spacing; + } + } + } + + public override void Destroy () + { + HideConflictTooltip (); + base.Destroy (); + } } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs index 6b6f0f0af4..e04b5cd791 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads/ErrorListPad.cs @@ -784,6 +784,14 @@ namespace MonoDevelop.Ide.Gui.Pads filter.Refilter (); } + internal void SetFilter (bool showErrors, bool showWarnings, bool showMessages) + { + errorBtn.Active = showErrors; + warnBtn.Active = showWarnings; + msgBtn.Active = showMessages; + } + + bool FilterTasks (TreeModel model, TreeIter iter) { bool canShow = false; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs index f82cf7ff5b..d9442a1192 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/DefaultWorkbench.cs @@ -474,7 +474,7 @@ namespace MonoDevelop.Ide.Gui string lab = content.Label.Length > 0 ? GettextCatalog.GetString (content.Label) : ""; ActionCommand cmd = new ActionCommand ("Pad|" + content.PadId, lab, null); cmd.DefaultHandler = new PadActivationHandler (this, content); - cmd.Category = GettextCatalog.GetString ("View"); + cmd.Category = GettextCatalog.GetString ("View (Pads)"); cmd.Description = GettextCatalog.GetString ("Show {0}", cmd.Text); IdeApp.CommandService.RegisterCommand (cmd); } @@ -540,9 +540,9 @@ namespace MonoDevelop.Ide.Gui post = "*"; } if (window.ViewContent.Project != null) { - return window.ViewContent.Project.Name + " - " + window.ViewContent.PathRelativeToProject + post + " - " + BrandingService.ApplicationLongName; + return window.ViewContent.Project.Name + " – " + window.ViewContent.PathRelativeToProject + post + " – " + BrandingService.ApplicationLongName; } - return window.ViewContent.ContentName + post + " - " + BrandingService.ApplicationLongName; + return window.ViewContent.ContentName + post + " – " + BrandingService.ApplicationLongName; } void SetWorkbenchTitle () @@ -565,7 +565,7 @@ namespace MonoDevelop.Ide.Gui static string GetDefaultTitle () { if (IdeApp.ProjectOperations.CurrentSelectedProject != null) - return IdeApp.ProjectOperations.CurrentSelectedProject.Name + " - " + BrandingService.ApplicationLongName; + return IdeApp.ProjectOperations.CurrentSelectedProject.Name + " – " + BrandingService.ApplicationLongName; return BrandingService.ApplicationLongName; } @@ -613,8 +613,7 @@ namespace MonoDevelop.Ide.Gui WorkbenchMemento memento = new WorkbenchMemento ((Properties)value); normalBounds = memento.Bounds; - Move (normalBounds.X, normalBounds.Y); - Resize (normalBounds.Width, normalBounds.Height); + DesktopService.PlaceWindow (this, normalBounds.X, normalBounds.Y, normalBounds.Width, normalBounds.Height); // HACK: don't restore Gdk.WindowState.Maximized on OS X, because there's a bug in // GdkWindow.State that means it doesn't reflect the real state, it only reflects values set diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs index fdc5ff2ad0..6adb5b9951 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Document.cs @@ -890,9 +890,11 @@ namespace MonoDevelop.Ide.Gui lock (adhocProjectLock) { if (adhocProject == null) return; - TypeSystemService.Unload (adhocSolution); - adhocSolution.Dispose (); - adhocSolution = null; + if (adhocSolution != null) { + TypeSystemService.Unload (adhocSolution); + adhocSolution.Dispose (); + adhocSolution = null; + } adhocProject = null; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs index 6580f57c50..175558522f 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Pad.cs @@ -96,6 +96,12 @@ namespace MonoDevelop.Ide.Gui return categories; } } + + public string Group { + get { + return content.Group; + } + } public void BringToFront () { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs index ea113e74de..a5c5b8102e 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ProgressMonitors.cs @@ -74,7 +74,7 @@ namespace MonoDevelop.Ide.Gui Pad pad = IdeApp.Workbench.GetPad<ErrorListPad> (); ErrorListPad errorPad = (ErrorListPad) pad.Content; AggregatedProgressMonitor mon = new AggregatedProgressMonitor (errorPad.GetBuildProgressMonitor ()); - mon.AddFollowerMonitor (GetStatusProgressMonitor (statusText, Stock.StatusBuild, false, true, false, pad)); + mon.AddFollowerMonitor (GetStatusProgressMonitor (statusText, Stock.StatusBuild, false, true, false, pad, true)); return mon; } @@ -122,11 +122,14 @@ namespace MonoDevelop.Ide.Gui } /******************************/ - + public ProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs, bool showTaskTitle, bool lockGui, Pad statusSourcePad, bool showCancelButton) + { + return new StatusProgressMonitor (title, icon, showErrorDialogs, showTaskTitle, lockGui, statusSourcePad, showCancelButton); + } public ProgressMonitor GetStatusProgressMonitor (string title, IconId icon, bool showErrorDialogs, bool showTaskTitle = true, bool lockGui = false, Pad statusSourcePad = null) { - return new StatusProgressMonitor (title, icon, showErrorDialogs, showTaskTitle, lockGui, statusSourcePad); + return GetStatusProgressMonitor (title, icon, showErrorDialogs, showTaskTitle, lockGui, statusSourcePad, showCancelButton: false); } public ProgressMonitor GetBackgroundProgressMonitor (string title, IconId icon) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBar.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBar.cs index ab84c3329f..c4d171cec0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBar.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBar.cs @@ -37,6 +37,7 @@ using MonoDevelop.Components; using MonoDevelop.Components.MainToolbar; using StockIcons = MonoDevelop.Ide.Gui.Stock; +using System.Threading; namespace MonoDevelop.Ide { @@ -68,6 +69,12 @@ namespace MonoDevelop.Ide /// status bar, this pad will be activated. This source pad is reset at every ShowMessage call. /// </summary> void SetMessageSourcePad (Pad pad); + + /// <summary> + /// When set, the status bar can be cancelled via this cancellation source. + /// </summary> + /// <value>The cancellation token.</value> + void SetCancellationTokenSource (CancellationTokenSource source); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContext.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContext.cs index fdf782bcf9..11e8fde6f3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContext.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContext.cs @@ -36,6 +36,7 @@ using MonoDevelop.Components; using MonoDevelop.Components.MainToolbar; using StockIcons = MonoDevelop.Ide.Gui.Stock; +using System.Threading; namespace MonoDevelop.Ide { @@ -47,6 +48,12 @@ namespace MonoDevelop.Ide public interface StatusBarContext: StatusBarContextBase { Pad StatusSourcePad { get; set; } + + /// <summary> + /// When set, the status bar can be cancelled via this cancellation source. + /// </summary> + /// <value>The cancellation token.</value> + CancellationTokenSource CancellationTokenSource { get; set; } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContextImpl.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContextImpl.cs index 924e02283e..5fa5dc5c2a 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContextImpl.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusBarContextImpl.cs @@ -36,6 +36,7 @@ using MonoDevelop.Components; using MonoDevelop.Components.MainToolbar; using StockIcons = MonoDevelop.Ide.Gui.Stock; +using System.Threading; namespace MonoDevelop.Ide { @@ -148,6 +149,7 @@ namespace MonoDevelop.Ide return; if (statusHandler.IsCurrentContext (this)) { OnMessageChanged (); + statusBar.SetCancellationTokenSource (CancellationTokenSource); statusBar.BeginProgress (name); statusBar.SetMessageSourcePad (sourcePad); lastMessageIsTransient = true; @@ -166,6 +168,7 @@ namespace MonoDevelop.Ide return; if (statusHandler.IsCurrentContext (this)) { OnMessageChanged (); + statusBar.SetCancellationTokenSource (CancellationTokenSource); statusBar.BeginProgress (name); statusBar.SetMessageSourcePad (sourcePad); lastMessageIsTransient = true; @@ -219,12 +222,14 @@ namespace MonoDevelop.Ide internal void Update () { if (showProgress) { + statusBar.AutoPulse = autoPulse; + statusBar.SetCancellationTokenSource (CancellationTokenSource); statusBar.BeginProgress (image, message); statusBar.SetProgressFraction (progressFraction); - statusBar.AutoPulse = autoPulse; statusBar.SetMessageSourcePad (sourcePad); lastMessageIsTransient = true; } else { + statusBar.SetCancellationTokenSource (null); statusBar.EndProgress (); if (globalLastChangeTime < lastChangeTime && messageShownAfterProgress) { globalLastChangeTime = lastChangeTime; @@ -251,7 +256,12 @@ namespace MonoDevelop.Ide sourcePad = value; } } - + + public CancellationTokenSource CancellationTokenSource { + get; + set; + } + protected virtual void OnMessageChanged () { } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs index 6eb2f26ee2..aff4962fec 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/StatusProgressMonitor.cs @@ -40,11 +40,12 @@ namespace MonoDevelop.Ide.Gui bool showErrorDialogs; bool showTaskTitles; bool lockGui; + bool showCancelButton; string title; StatusBarContext statusBar; Pad statusSourcePad; - public StatusProgressMonitor (string title, string iconName, bool showErrorDialogs, bool showTaskTitles, bool lockGui, Pad statusSourcePad): base (Runtime.MainSynchronizationContext) + public StatusProgressMonitor (string title, string iconName, bool showErrorDialogs, bool showTaskTitles, bool lockGui, Pad statusSourcePad, bool showCancelButton): base (Runtime.MainSynchronizationContext) { this.lockGui = lockGui; @@ -52,9 +53,12 @@ namespace MonoDevelop.Ide.Gui this.showTaskTitles = showTaskTitles; this.title = title; this.statusSourcePad = statusSourcePad; + this.showCancelButton = showCancelButton; icon = iconName; statusBar = IdeApp.Workbench.StatusBar.CreateContext (); statusBar.StatusSourcePad = statusSourcePad; + if (showCancelButton) + statusBar.CancellationTokenSource = CancellationTokenSource; statusBar.BeginProgress (iconName, title); if (lockGui) IdeApp.Workbench.LockGui (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs index 0077eec9b1..8773eba84c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/Styles.cs @@ -243,6 +243,16 @@ namespace MonoDevelop.Ide.Gui public static Color SearchErrorForegroundColor { get; internal set; } } + public static class KeyBindingsPanel + { + public static Color KeyBackgroundColor { get; internal set; } + public static Color KeyForegroundColor { get; internal set; } + public static Color KeyDuplicateBackgroundColor { get; internal set; } + public static Color KeyDuplicateForegroundColor { get; internal set; } + public static Color KeyConflictBackgroundColor { get; internal set; } + public static Color KeyConflictForegroundColor { get; internal set; } + } + // Helper methods internal static Color Shift (Color color, double factor) @@ -389,6 +399,15 @@ namespace MonoDevelop.Ide.Gui Editor.SmartTagMarkerColorDark = Color.FromName ("#ffffff").WithAlpha (.5); Editor.SearchErrorForegroundColor = ErrorForegroundColor; + // Key Bindings Preferences + + KeyBindingsPanel.KeyBackgroundColor = BackgroundColor; + KeyBindingsPanel.KeyForegroundColor = BaseForegroundColor; + KeyBindingsPanel.KeyDuplicateBackgroundColor = StatusWarningBackgroundColor; + KeyBindingsPanel.KeyDuplicateForegroundColor = StatusWarningTextColor; + KeyBindingsPanel.KeyConflictBackgroundColor = StatusErrorBackgroundColor; + KeyBindingsPanel.KeyConflictForegroundColor = StatusErrorTextColor; + if (Changed != null) Changed (null, EventArgs.Empty); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs index 51ad28502d..9daced5836 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui/ViewCommandHandlers.cs @@ -515,6 +515,19 @@ namespace MonoDevelop.Ide.Gui } } + [CommandHandler (EditCommands.EnableDisableFolding)] + protected void EnableDisableFolding () + { + DefaultSourceEditorOptions.Instance.ShowFoldMargin = !DefaultSourceEditorOptions.Instance.ShowFoldMargin; + } + + [CommandUpdateHandler (EditCommands.EnableDisableFolding)] + protected void UpdateEnableDisableFolding (CommandInfo info) + { + info.Text = IsFoldMarkerMarginEnabled ? GettextCatalog.GetString ("Disable _Folding") : GettextCatalog.GetString ("Enable _Folding"); + info.Enabled = GetContent<IFoldable> () != null; + } + [CommandUpdateHandler (EditCommands.ToggleAllFoldings)] [CommandUpdateHandler (EditCommands.FoldDefinitions)] [CommandUpdateHandler (EditCommands.ToggleFolding)] diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs index 37939b918b..7b6b440635 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Navigation/DocumentNavigationPoint.cs @@ -74,7 +74,7 @@ namespace MonoDevelop.Ide.Navigation } } - FilePath FileName { + public FilePath FileName { get { return doc != null? doc.FileName : fileName; } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/CombineOptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/CombineOptionsDialog.cs index 3d68902157..29b89aeddd 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/CombineOptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/CombineOptionsDialog.cs @@ -43,7 +43,7 @@ namespace MonoDevelop.Ide.Projects { public CombineOptionsDialog (Window parentWindow, Solution solution) : base (parentWindow, solution) { - this.Title = GettextCatalog.GetString ("Solution Options") + " - " + solution.Name; + this.Title = GettextCatalog.GetString ("Solution Options") + " – " + solution.Name; } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs index 4da5584e7a..44ff749e74 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/DefaultPolicyOptionsDialog.cs @@ -57,7 +57,7 @@ namespace MonoDevelop.Ide.Projects : base (parentWindow, new PolicySet (), "/MonoDevelop/ProjectModel/Gui/DefaultPolicyPanels") { - this.Title = GettextCatalog.GetString ("Custom Policies"); + this.Title = GettextCatalog.GetString ("Policies"); editingSet = (PolicySet) DataObject; HBox topBar = new HBox (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectOptionsDialog.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectOptionsDialog.cs index 56fb56a48a..a37757d6e8 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectOptionsDialog.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/ProjectOptionsDialog.cs @@ -46,7 +46,7 @@ namespace MonoDevelop.Ide.Projects { public ProjectOptionsDialog (Window parentWindow, SolutionItem project) : base (parentWindow, project) { - this.Title = GettextCatalog.GetString ("Project Options") + " - " + project.Name; + this.Title = GettextCatalog.GetString ("Project Options") + " – " + project.Name; this.DefaultWidth = 960; this.DefaultHeight = 680; } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplatePackageReference.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplatePackageReference.cs index d5697f8ee8..555df5fb9c 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplatePackageReference.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/ProjectTemplatePackageReference.cs @@ -36,7 +36,8 @@ namespace MonoDevelop.Ide.Templates return new ProjectTemplatePackageReference {
Id = GetAttribute (xmlElement, "id"),
Version = GetAttribute (xmlElement, "version"),
- CreateCondition = GetAttribute (xmlElement, "if")
+ CreateCondition = GetAttribute (xmlElement, "if"),
+ IsLocalPackage = GetBoolAttribute (xmlElement, "local")
};
}
@@ -44,6 +45,8 @@ namespace MonoDevelop.Ide.Templates public string Version { get; private set; }
public string CreateCondition { get; private set; }
+ internal bool IsLocalPackage { get; private set; }
+
static string GetAttribute (XmlElement xmlElement, string attributeName)
{
foreach (XmlAttribute attribute in xmlElement.Attributes) {
@@ -53,6 +56,17 @@ namespace MonoDevelop.Ide.Templates }
return "";
}
+
+ static bool GetBoolAttribute (XmlElement xmlElement, string attributeName)
+ {
+ string attributeValue = GetAttribute (xmlElement, attributeName);
+
+ bool result = false;
+ if (bool.TryParse (attributeValue, out result))
+ return result;
+
+ return false;
+ }
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs index 4582d57c89..bd739a57ba 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Templates/SingleFileDescriptionTemplate.cs @@ -314,9 +314,11 @@ namespace MonoDevelop.Ide.Templates var lineText = doc.GetTextAt (line.Offset, line.Length); if (tabToSpaces != null) lineText = lineText.Replace ("\t", tabToSpaces); - data = System.Text.Encoding.UTF8.GetBytes (lineText); - ms.Write (data, 0, data.Length); - ms.Write (eolMarkerBytes, 0, eolMarkerBytes.Length); + if (line.LengthIncludingDelimiter > 0) { + data = System.Text.Encoding.UTF8.GetBytes (lineText); + ms.Write (data, 0, data.Length); + ms.Write (eolMarkerBytes, 0, eolMarkerBytes.Length); + } } ms.Position = 0; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs index ba26660bd0..462561a653 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopTemporaryStorageServiceFactory.cs @@ -35,6 +35,7 @@ using Microsoft.CodeAnalysis.Text; using MonoDevelop.Core.Text; using System.Reflection; using MonoDevelop.Core; +using System.Collections.Generic; namespace MonoDevelop.Ide.TypeSystem { @@ -80,14 +81,34 @@ namespace MonoDevelop.Ide.TypeSystem class TemporaryStorageService : ITemporaryStorageService { + List<IDisposable> serviceList = new List<IDisposable> (); + + void DisposeServices () + { + foreach (var service in serviceList) + service.Dispose (); + serviceList.Clear (); + } + + public TemporaryStorageService () + { + IdeApp.Workspace.LastWorkspaceItemClosed += delegate { + DisposeServices (); + }; + } + public ITemporaryStreamStorage CreateTemporaryStreamStorage (CancellationToken cancellationToken = default(CancellationToken)) { - return new StreamStorage (); + var result = new StreamStorage (); + serviceList.Add (result); + return result; } public ITemporaryTextStorage CreateTemporaryTextStorage (CancellationToken cancellationToken = default(CancellationToken)) { - return new TemporaryTextStorage (); + var result = new TemporaryTextStorage (); + serviceList.Add (result); + return result; } } @@ -183,6 +204,7 @@ namespace MonoDevelop.Ide.TypeSystem return; try { File.Delete (fileName); + fileName = null; } catch (Exception) {} } @@ -240,6 +262,7 @@ namespace MonoDevelop.Ide.TypeSystem return; try { File.Delete (fileName); + fileName = null; } catch (Exception) {} } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs index 429bab3668..fac4c19460 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/MonoDevelopWorkspace.cs @@ -43,6 +43,7 @@ using MonoDevelop.Ide.Editor.Projection; using System.Reflection; using Microsoft.CodeAnalysis.Host.Mef; using System.Text; +using System.Collections.Immutable; namespace MonoDevelop.Ide.TypeSystem { @@ -182,15 +183,15 @@ namespace MonoDevelop.Ide.TypeSystem { return Task.Run (async delegate { var projects = new ConcurrentBag<ProjectInfo> (); - var mdProjects = solution.GetAllProjects ().OfType<MonoDevelop.Projects.DotNetProject> (); + var mdProjects = solution.GetAllProjects (); projectionList.Clear (); solutionData = new SolutionData (); - List<Task> allTasks = new List<Task> (); foreach (var proj in mdProjects) { if (token.IsCancellationRequested) return null; - if (!proj.SupportsRoslyn) + var netProj = proj as MonoDevelop.Projects.DotNetProject; + if (netProj != null && !netProj.SupportsRoslyn) continue; var tp = LoadProject (proj, token).ContinueWith (t => { if (!t.IsCanceled) @@ -380,7 +381,7 @@ namespace MonoDevelop.Ide.TypeSystem project.Modified -= OnProjectModified; } - async Task<ProjectInfo> LoadProject (MonoDevelop.Projects.DotNetProject p, CancellationToken token) + async Task<ProjectInfo> LoadProject (MonoDevelop.Projects.Project p, CancellationToken token) { if (!projectIdMap.ContainsKey (p)) { p.FileAddedToProject += OnFileAdded; @@ -531,10 +532,28 @@ namespace MonoDevelop.Ide.TypeSystem projectionList.Add (entry); } - static async Task<List<MetadataReference>> CreateMetadataReferences (MonoDevelop.Projects.DotNetProject netProject, ProjectId projectId, CancellationToken token) + static async Task<List<MetadataReference>> CreateMetadataReferences (MonoDevelop.Projects.Project proj, ProjectId projectId, CancellationToken token) { List<MetadataReference> result = new List<MetadataReference> (); - + + var netProject = proj as MonoDevelop.Projects.DotNetProject; + if (netProject == null) { + // create some default references for unsupported project types. + string [] assemblies = { + typeof(string).Assembly.Location, // mscorlib + typeof(System.Text.RegularExpressions.Regex).Assembly.Location, // System + typeof(System.Linq.Enumerable).Assembly.Location, // System.Core + typeof(System.Data.VersionNotFoundException).Assembly.Location, // System.Data + typeof(System.Xml.XmlDocument).Assembly.Location, // System.Xml + }; + + foreach (var asm in assemblies) { + var metadataReference = MetadataReferenceCache.LoadReference (projectId, typeof (string).Assembly.Location); + result.Add (metadataReference); + } + + return result; + } var configurationSelector = IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default; var hashSet = new HashSet<string> (FilePath.PathComparer); @@ -558,8 +577,7 @@ namespace MonoDevelop.Ide.TypeSystem var metadataReference = MetadataReferenceCache.LoadReference (projectId, fileName); if (metadataReference == null) continue; - if (file.Aliases != null) - metadataReference = metadataReference.WithAliases (file.EnumerateAliases ()); + metadataReference = metadataReference.WithAliases (file.EnumerateAliases ()); result.Add (metadataReference); } } catch (Exception e) { @@ -586,14 +604,19 @@ namespace MonoDevelop.Ide.TypeSystem return result; } - IEnumerable<ProjectReference> CreateProjectReferences (MonoDevelop.Projects.DotNetProject p, CancellationToken token) + IEnumerable<ProjectReference> CreateProjectReferences (MonoDevelop.Projects.Project p, CancellationToken token) { - foreach (var referencedProject in p.GetReferencedAssemblyProjects (IdeApp.Workspace?.ActiveConfiguration ?? MonoDevelop.Projects.ConfigurationSelector.Default)) { - if (token.IsCancellationRequested) - yield break; + var netProj = p as MonoDevelop.Projects.DotNetProject; + if (netProj == null) + yield break; + foreach (var pr in netProj.References.Where (pr => pr.ReferenceType == MonoDevelop.Projects.ReferenceType.Project)) { + var referencedProject = pr.ResolveProject (p.ParentSolution) as MonoDevelop.Projects.DotNetProject; + if (referencedProject == null) + continue; if (TypeSystemService.IsOutputTrackedProject (referencedProject)) continue; - yield return new ProjectReference (GetOrCreateProjectId (referencedProject)); + var splittedAliases = (pr.Aliases ?? "").Split (new [] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); + yield return new ProjectReference (GetOrCreateProjectId (referencedProject), ImmutableArray<string>.Empty.AddRange (splittedAliases)); } } @@ -781,29 +804,29 @@ namespace MonoDevelop.Ide.TypeSystem if (documentContext != null) { var editor = (TextEditor)data; - using (var undo = editor.OpenUndoGroup ()) { - var oldVersion = editor.Version; - delta = ApplyChanges (projection, data, changes); - var versionBeforeFormat = editor.Version; - - if (formatter.SupportsOnTheFlyFormatting) { - foreach (var change in changes) { - delta -= change.Span.Length - change.NewText.Length; - var startOffset = change.Span.Start - delta; - if (projection != null) { - int originalOffset; - if (projection.TryConvertFromProjectionToOriginal (startOffset, out originalOffset)) - startOffset = originalOffset; - } - if (change.NewText.Length == 0) { - formatter.OnTheFlyFormat (editor, documentContext, TextSegment.FromBounds (Math.Max (0, startOffset - 1), Math.Min (data.Length, startOffset + 1))); - } else { - formatter.OnTheFlyFormat (editor, documentContext, new TextSegment (startOffset, change.NewText.Length)); + await Runtime.RunInMainThread (async () => { + using (var undo = editor.OpenUndoGroup ()) { + var oldVersion = editor.Version; + delta = ApplyChanges (projection, data, changes); + var versionBeforeFormat = editor.Version; + + if (formatter.SupportsOnTheFlyFormatting) { + foreach (var change in changes) { + delta -= change.Span.Length - change.NewText.Length; + var startOffset = change.Span.Start - delta; + if (projection != null) { + int originalOffset; + if (projection.TryConvertFromProjectionToOriginal (startOffset, out originalOffset)) + startOffset = originalOffset; + } + if (change.NewText.Length == 0) { + formatter.OnTheFlyFormat (editor, documentContext, TextSegment.FromBounds (Math.Max (0, startOffset - 1), Math.Min (data.Length, startOffset + 1))); + } else { + formatter.OnTheFlyFormat (editor, documentContext, new TextSegment (startOffset, change.NewText.Length)); + } } } - } - if (annotatedNode != null && GetInsertionPoints != null) { - await Runtime.RunInMainThread (async () => { + if (annotatedNode != null && GetInsertionPoints != null) { IdeApp.Workbench.Documents.First (d => d.FileName == editor.FileName).Select (); var formattedVersion = editor.Version; @@ -891,9 +914,9 @@ namespace MonoDevelop.Ide.TypeSystem StartRenameSession (editor, documentContext, versionBeforeFormat, renameTokenOpt.Value); }; editor.StartInsertionMode (options); - }); + } } - } + }); } if (projection != null) {
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs index 2636f4c2d2..bbc44a7170 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/NR5CompatibiltyExtensions.cs @@ -151,7 +151,7 @@ namespace MonoDevelop.Ide.TypeSystem public static ITypeSymbol GetReturnType (this ISymbol symbol) { if (symbol == null) - throw new ArgumentNullException ("symbol"); + throw new ArgumentNullException (nameof (symbol)); switch (symbol.Kind) { case SymbolKind.Field: var field = (IFieldSymbol)symbol; @@ -199,7 +199,7 @@ namespace MonoDevelop.Ide.TypeSystem public static IEnumerable<INamedTypeSymbol> GetAllTypesInMainAssembly (this Compilation compilation, CancellationToken cancellationToken = default(CancellationToken)) { if (compilation == null) - throw new ArgumentNullException ("compilation"); + throw new ArgumentNullException (nameof (compilation)); return compilation.Assembly.GlobalNamespace.GetAllTypes (cancellationToken); } @@ -272,7 +272,7 @@ namespace MonoDevelop.Ide.TypeSystem public static string GetComponentCategory (this ISymbol symbol) { if (symbol == null) - throw new ArgumentNullException ("symbol"); + throw new ArgumentNullException (nameof (symbol)); var browsableState = symbol.GetAttributes ().FirstOrDefault (attr => attr.AttributeClass.Name == "CategoryAttribute" && attr.AttributeClass.ContainingNamespace.MetadataName == "System.ComponentModel"); if (browsableState != null && browsableState.ConstructorArguments.Length == 1) { try { @@ -293,7 +293,7 @@ namespace MonoDevelop.Ide.TypeSystem public static bool IsToolboxItem (this ITypeSymbol symbol) { if (symbol == null) - throw new ArgumentNullException ("symbol"); + throw new ArgumentNullException (nameof (symbol)); if (symbol.DeclaredAccessibility != Accessibility.Public) return false; var toolboxItemAttr = symbol.GetAttributes ().FirstOrDefault (attr => attr.AttributeClass.Name == "ToolboxItemAttribute" && attr.AttributeClass.ContainingNamespace.MetadataName == "System.ComponentModel"); @@ -315,7 +315,7 @@ namespace MonoDevelop.Ide.TypeSystem public static bool IsDesignerBrowsable (this ISymbol symbol) { if (symbol == null) - throw new ArgumentNullException ("symbol"); + throw new ArgumentNullException (nameof (symbol)); var browsableState = symbol.GetAttributes ().FirstOrDefault (attr => attr.AttributeClass.Name == "BrowsableAttribute" && attr.AttributeClass.ContainingNamespace.MetadataName == "System.ComponentModel"); if (browsableState != null && browsableState.ConstructorArguments.Length == 1) { try { @@ -355,6 +355,10 @@ namespace MonoDevelop.Ide.TypeSystem ISymbol within, ITypeSymbol throughTypeOpt = null) { + if (symbol == null) + throw new ArgumentNullException (nameof (symbol)); + if (within == null) + throw new ArgumentNullException (nameof (within)); if (within is IAssemblySymbol) { return symbol.IsAccessibleWithin((IAssemblySymbol)within, throughTypeOpt); @@ -377,6 +381,10 @@ namespace MonoDevelop.Ide.TypeSystem IAssemblySymbol within, ITypeSymbol throughTypeOpt = null) { + if (symbol == null) + throw new ArgumentNullException (nameof (symbol)); + if (within == null) + throw new ArgumentNullException (nameof (within)); return (bool)isAccessibleWithin1Method.Invoke (null, new object [] { symbol, within, throughTypeOpt }); } @@ -389,6 +397,10 @@ namespace MonoDevelop.Ide.TypeSystem INamedTypeSymbol within, ITypeSymbol throughTypeOpt = null) { + if (symbol == null) + throw new ArgumentNullException (nameof (symbol)); + if (within == null) + throw new ArgumentNullException (nameof (within)); return (bool)isAccessibleWithin2Method.Invoke (null, new object [] { symbol, within, throughTypeOpt }); } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index e8e753243a..dd2ea08f03 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -7578,6 +7578,18 @@ <EmbeddedResource Include="templates\AppManifest.xft.xml"> <LogicalName>AppManifest.xft.xml</LogicalName> </EmbeddedResource> + <EmbeddedResource Include="options\KeyBindingSchemeVisualStudio-mac.xml"> + <LogicalName>KeyBindingSchemeVisualStudio-mac.xml</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="options\KeyBindingSchemeXcode.xml"> + <LogicalName>KeyBindingSchemeXcode.xml</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="options\KeyBindingSchemeVSCode-mac.xml"> + <LogicalName>KeyBindingSchemeVSCode-mac.xml</LogicalName> + </EmbeddedResource> + <EmbeddedResource Include="options\KeyBindingSchemeRider-mac.xml"> + <LogicalName>KeyBindingSchemeRider-mac.xml</LogicalName> + </EmbeddedResource> </ItemGroup> <ItemGroup> <Compile Include="MonoDevelop.Ide.Commands\CustomStringTagProvider.cs" /> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs index 3a48180f21..7a80ce8dda 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs @@ -370,5 +370,15 @@ namespace MonoDevelop.Ide { PlatformService.PlaceWindow (window, x, y, width, height); } + + /// <summary> + /// Restarts MonoDevelop + /// </summary> + /// <returns> false if the user cancels exiting. </returns> + /// <param name="reopenWorkspace"> true to reopen current workspace. </param> + internal static void RestartIde (bool reopenWorkspace) + { + PlatformService.RestartIde (reopenWorkspace); + } } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs index d7af2aa4d1..e7dfbb9894 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/Ide.cs @@ -227,6 +227,7 @@ namespace MonoDevelop.Ide Counters.Initialization.Trace ("Flushed GUI events"); MessageService.RootWindow = workbench.RootWindow; + Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow (workbench.RootWindow); commandService.EnableIdleUpdate = true; @@ -308,7 +309,7 @@ namespace MonoDevelop.Ide static void KeyBindingFailed (object sender, KeyBindingFailedEventArgs e) { - Ide.IdeApp.Workbench.StatusBar.ShowMessage (e.Message); + Ide.IdeApp.Workbench.StatusBar.ShowWarning (e.Message); } //this method is MIT/X11, 2009, Michael Hutchinson / (c) Novell @@ -397,6 +398,30 @@ namespace MonoDevelop.Ide } return false; } + + /// <summary> + /// Restarts MonoDevelop + /// </summary> + /// <returns> false if the user cancels exiting. </returns> + /// <param name="reopenWorkspace"> true to reopen current workspace. </param> + /// <remarks> + /// Starts a new MonoDevelop instance in a new process and + /// stops the current MonoDevelop instance. + /// </remarks> + public static bool Restart (bool reopenWorkspace = false) + { + if (Exit ()) { + try { + DesktopService.RestartIde (reopenWorkspace); + } catch (Exception ex) { + LoggingService.LogError ("Restarting IDE failed", ex); + } + // return true here even if DesktopService.RestartIde has failed, + // because the Ide has already been closed. + return true; + } + return false; + } internal static bool OnExit () { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs index 7561144dd7..b4bdf0c037 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/IdeStartup.cs @@ -273,6 +273,7 @@ namespace MonoDevelop.Ide initialized = true; MessageService.RootWindow = IdeApp.Workbench.RootWindow; + Xwt.MessageDialog.RootWindow = Xwt.Toolkit.CurrentEngine.WrapWindow (IdeApp.Workbench.RootWindow); Thread.CurrentThread.Name = "GUI Thread"; Counters.Initialization.Trace ("Running IdeApp"); Counters.Initialization.EndTiming (); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs index 753e366e50..9be1f3d8c6 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/ProjectOperations.cs @@ -1209,7 +1209,11 @@ namespace MonoDevelop.Ide try { OnStartClean (monitor, tt); + monitor.BeginTask (GettextCatalog.GetString ("Rebuilding..."), 2); + monitor.BeginStep (GettextCatalog.GetString ("Rebuilding... (Clean)")); + var res = await CleanAsync (entry, monitor, tt, true, operationContext); + monitor.EndStep (); if (res.HasErrors) { tt.End (); monitor.Dispose (); @@ -1218,6 +1222,7 @@ namespace MonoDevelop.Ide if (StartBuild != null) { BeginBuild (monitor, tt, true); } + monitor.BeginStep (GettextCatalog.GetString ("Rebuilding... (Build)")); return await BuildSolutionItemAsync (entry, monitor, tt, operationContext:operationContext); } finally { tt.End (); diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.IDEStyleOptionsPanelWidget.cs b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.IDEStyleOptionsPanelWidget.cs index f12e3d37b7..2c02f0bd2a 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.IDEStyleOptionsPanelWidget.cs +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.IDEStyleOptionsPanelWidget.cs @@ -2,15 +2,30 @@ // This file has been generated by the GUI designer. Do not modify. namespace MonoDevelop.Ide.Gui.OptionPanels { - partial class IDEStyleOptionsPanelWidget + public partial class IDEStyleOptionsPanelWidget { private global::Gtk.VBox vbox13; + private global::Gtk.Table table1; + private global::Gtk.ComboBox comboLanguage; + private global::Gtk.ComboBox comboTheme; + private global::Gtk.Label label2; + private global::Gtk.Label labelTheme; + private global::Gtk.HSeparator separatorRestart; + + private global::Gtk.Table tableRestart; + + private global::Gtk.Button btnRestart; + + private global::MonoDevelop.Components.ImageView imageRestart; + + private global::Gtk.Label labelRestart; + protected virtual void Build () { global::Stetic.Gui.Initialize (this); @@ -71,11 +86,63 @@ namespace MonoDevelop.Ide.Gui.OptionPanels w5.Position = 0; w5.Expand = false; w5.Fill = false; + // Container child vbox13.Gtk.Box+BoxChild + this.separatorRestart = new global::Gtk.HSeparator (); + this.separatorRestart.Name = "separatorRestart"; + this.vbox13.Add (this.separatorRestart); + global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.vbox13 [this.separatorRestart])); + w6.Position = 1; + w6.Expand = false; + w6.Fill = false; + // Container child vbox13.Gtk.Box+BoxChild + this.tableRestart = new global::Gtk.Table (((uint)(2)), ((uint)(3)), false); + this.tableRestart.Name = "tableRestart"; + this.tableRestart.RowSpacing = ((uint)(6)); + this.tableRestart.ColumnSpacing = ((uint)(6)); + // Container child tableRestart.Gtk.Table+TableChild + this.btnRestart = new global::Gtk.Button (); + this.btnRestart.CanFocus = true; + this.btnRestart.Name = "btnRestart"; + this.btnRestart.UseUnderline = true; + this.btnRestart.Label = "Restart {0}"; + this.tableRestart.Add (this.btnRestart); + global::Gtk.Table.TableChild w7 = ((global::Gtk.Table.TableChild)(this.tableRestart [this.btnRestart])); + w7.TopAttach = ((uint)(1)); + w7.BottomAttach = ((uint)(2)); + w7.LeftAttach = ((uint)(1)); + w7.RightAttach = ((uint)(2)); + w7.XOptions = ((global::Gtk.AttachOptions)(4)); + w7.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child tableRestart.Gtk.Table+TableChild + this.imageRestart = new global::MonoDevelop.Components.ImageView (); + this.imageRestart.Name = "imageRestart"; + this.imageRestart.IconId = "md-information"; + this.imageRestart.IconSize = ((global::Gtk.IconSize)(1)); + this.tableRestart.Add (this.imageRestart); + global::Gtk.Table.TableChild w8 = ((global::Gtk.Table.TableChild)(this.tableRestart [this.imageRestart])); + w8.XOptions = ((global::Gtk.AttachOptions)(4)); + w8.YOptions = ((global::Gtk.AttachOptions)(4)); + // Container child tableRestart.Gtk.Table+TableChild + this.labelRestart = new global::Gtk.Label (); + this.labelRestart.Name = "labelRestart"; + this.labelRestart.LabelProp = "These preferences will take effect next time you start {0}"; + this.tableRestart.Add (this.labelRestart); + global::Gtk.Table.TableChild w9 = ((global::Gtk.Table.TableChild)(this.tableRestart [this.labelRestart])); + w9.LeftAttach = ((uint)(1)); + w9.RightAttach = ((uint)(3)); + w9.XOptions = ((global::Gtk.AttachOptions)(4)); + w9.YOptions = ((global::Gtk.AttachOptions)(4)); + this.vbox13.Add (this.tableRestart); + global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox13 [this.tableRestart])); + w10.Position = 2; + w10.Expand = false; + w10.Fill = false; this.Add (this.vbox13); if ((this.Child != null)) { this.Child.ShowAll (); } this.Show (); + this.btnRestart.Clicked += new global::System.EventHandler (this.RestartClicked); } } } diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs index 9138732a01..30c373637d 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/MonoDevelop.Ide.Gui.OptionPanels.KeyBindingsPanel.cs @@ -47,7 +47,9 @@ namespace MonoDevelop.Ide.Gui.OptionPanels private global::Gtk.Entry accelEntry; private global::Gtk.Button updateButton; - + + private global::Gtk.Button addButton; + protected virtual void Build () { global::Stetic.Gui.Initialize (this); @@ -199,6 +201,7 @@ namespace MonoDevelop.Ide.Gui.OptionPanels this.labelMessage.Name = "labelMessage"; this.labelMessage.Xalign = 0F; this.labelMessage.UseMarkup = true; + this.labelMessage.Ellipsize = Pango.EllipsizeMode.End; this.vbox.Add (this.labelMessage); global::Gtk.Box.BoxChild w17 = ((global::Gtk.Box.BoxChild)(this.vbox [this.labelMessage])); w17.Position = 5; @@ -237,11 +240,22 @@ namespace MonoDevelop.Ide.Gui.OptionPanels w20.Position = 2; w20.Expand = false; w20.Fill = false; - this.vbox.Add (this.hbox); - global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.vbox [this.hbox])); - w21.Position = 6; + // Container child hbox.Gtk.Box+BoxChild + this.addButton = new global::Gtk.Button (); + this.addButton.CanFocus = true; + this.addButton.Name = "addButton"; + this.addButton.UseUnderline = true; + this.addButton.Label = global::Mono.Unix.Catalog.GetString ("Add"); + this.hbox.Add (this.addButton); + global::Gtk.Box.BoxChild w21 = ((global::Gtk.Box.BoxChild)(this.hbox [this.addButton])); + w21.Position = 3; w21.Expand = false; w21.Fill = false; + this.vbox.Add (this.hbox); + global::Gtk.Box.BoxChild w22 = ((global::Gtk.Box.BoxChild)(this.vbox [this.hbox])); + w22.Position = 6; + w22.Expand = false; + w22.Fill = false; this.Add (this.vbox); if ((this.Child != null)) { this.Child.ShowAll (); diff --git a/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic b/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic index 8e60eefee9..e5b53d1fac 100644 --- a/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic +++ b/main/src/core/MonoDevelop.Ide/gtk-gui/gui.stetic @@ -464,6 +464,21 @@ <property name="Fill">False</property> </packing> </child> + <child> + <widget class="Gtk.Button" id="addButton"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Type">TextOnly</property> + <property name="Label" translatable="yes">Add</property> + <property name="UseUnderline">True</property> + </widget> + <packing> + <property name="Position">3</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> </widget> <packing> <property name="Position">6</property> @@ -3201,7 +3216,98 @@ Diagnostic</property> </packing> </child> <child> - <placeholder /> + <widget class="Gtk.HSeparator" id="separatorRestart"> + <property name="MemberName" /> + </widget> + <packing> + <property name="Position">1</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Table" id="tableRestart"> + <property name="MemberName" /> + <property name="NRows">2</property> + <property name="NColumns">3</property> + <property name="RowSpacing">6</property> + <property name="ColumnSpacing">6</property> + <child> + <placeholder /> + </child> + <child> + <placeholder /> + </child> + <child> + <widget class="Gtk.Button" id="btnRestart"> + <property name="MemberName" /> + <property name="CanFocus">True</property> + <property name="Type">TextOnly</property> + <property name="Label">Restart {0}</property> + <property name="UseUnderline">True</property> + <signal name="Clicked" handler="RestartClicked" /> + </widget> + <packing> + <property name="TopAttach">1</property> + <property name="BottomAttach">2</property> + <property name="LeftAttach">1</property> + <property name="RightAttach">2</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="MonoDevelop.Components.ImageView" id="imageRestart"> + <property name="MemberName" /> + <property name="IconId">md-information</property> + <property name="IconSize">Menu</property> + </widget> + <packing> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + <child> + <widget class="Gtk.Label" id="labelRestart"> + <property name="MemberName" /> + <property name="LabelProp">These preferences will take effect next time you start {0}</property> + </widget> + <packing> + <property name="LeftAttach">1</property> + <property name="RightAttach">3</property> + <property name="AutoSize">True</property> + <property name="XOptions">Fill</property> + <property name="YOptions">Fill</property> + <property name="XExpand">False</property> + <property name="XFill">True</property> + <property name="XShrink">False</property> + <property name="YExpand">False</property> + <property name="YFill">True</property> + <property name="YShrink">False</property> + </packing> + </child> + </widget> + <packing> + <property name="Position">2</property> + <property name="AutoSize">True</property> + <property name="Expand">False</property> + <property name="Fill">False</property> + </packing> </child> </widget> </child> diff --git a/main/src/core/MonoDevelop.Ide/gtkrc.mac b/main/src/core/MonoDevelop.Ide/gtkrc.mac index 0c033dc745..5476513d54 100644 --- a/main/src/core/MonoDevelop.Ide/gtkrc.mac +++ b/main/src/core/MonoDevelop.Ide/gtkrc.mac @@ -29,14 +29,14 @@ gtk-toolbar-icon-size = large-toolbar gtk-auto-mnemonics = 1 gtk-error-bell = 0 gtk-show-input-method-menu = 0 -gtk-font-name = "Helvetica Neue 12" +gtk-font-name = "-apple-system-font 12" style "default" { xthickness = 1 ythickness = 1 - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" ### colours @@ -135,7 +135,7 @@ style "button" = "default" { xthickness = 2 ythickness = 4 - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" bg[NORMAL] = @base_color bg[PRELIGHT] = @base_color # Mac buttons have no hover state @@ -177,7 +177,7 @@ style "menu" { xthickness = 1 # ythickness = 0 - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" bg[PRELIGHT] = @selected_fg_color fg[PRELIGHT] = @selected_fg_color @@ -232,7 +232,7 @@ style "tooltip" bg[NORMAL] = @tooltip_bg_color bg[SELECTED] = @tooltip_border_color - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" engine "xamarin" { roundness = 0 @@ -318,7 +318,7 @@ style "wizard-dialog" } style "combo-box-menu" = "menu" { - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" } style "notebook" = "default" diff --git a/main/src/core/MonoDevelop.Ide/gtkrc.mac-dark b/main/src/core/MonoDevelop.Ide/gtkrc.mac-dark index 27357e3187..61183299d9 100644 --- a/main/src/core/MonoDevelop.Ide/gtkrc.mac-dark +++ b/main/src/core/MonoDevelop.Ide/gtkrc.mac-dark @@ -30,14 +30,14 @@ gtk-toolbar-icon-size = large-toolbar gtk-auto-mnemonics = 1 gtk-error-bell = 0 gtk-show-input-method-menu = 0 -gtk-font-name = "Helvetica Neue 12" +gtk-font-name = "-apple-system-font 12" style "default" { xthickness = 1 ythickness = 1 - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" ### colours @@ -137,7 +137,7 @@ style "button" = "default" { xthickness = 2 ythickness = 4 - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" bg[NORMAL] = "#595959" bg[PRELIGHT] = "#595959" # Mac buttons have no hover state @@ -192,7 +192,7 @@ style "menu" { xthickness = 1 # ythickness = 0 - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" bg[PRELIGHT] = @selected_fg_color fg[PRELIGHT] = @selected_fg_color @@ -235,7 +235,7 @@ style "tooltip" bg[NORMAL] = @tooltip_bg_color bg[SELECTED] = @tooltip_border_color - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" engine "xamarin" { roundness = 0 @@ -295,7 +295,7 @@ style "wizard-dialog" } style "combo-box-menu" = "menu" { - font_name = "Helvetica Neue 12" + font_name = "-apple-system-font 12" } style "notebook" = "default" @@ -501,4 +501,4 @@ widget "*MonoDevelop.PropertyGridToolbar.GtkRadioButton" style "toggle-button" widget_class "*BooleanEditor*" style "propertygrid-radio-or-check-box" # disable hover background on link labels -class "GtkLabel" style "link-label-fix"
\ No newline at end of file +class "GtkLabel" style "link-label-fix" diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32.png Binary files differindex be66f4fc51..0437189a78 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32@2x.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32@2x.png Binary files differindex f8355f307e..ebfa842789 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark.png Binary files differindex 2e369572b5..c509c82a98 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark@2x.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark@2x.png Binary files differindex 7a81e3d102..402d1fad7c 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel.png Binary files differindex fe5e25d190..a2032381e4 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel@2x.png Binary files differindex 67a071e9cd..91c8f6b7c3 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32~dark~sel@2x.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel.png Binary files differindex cace68b5c3..82d10bf168 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel.png diff --git a/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel@2x.png b/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel@2x.png Binary files differindex cf352a83ce..65349b2a47 100644 --- a/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel@2x.png +++ b/main/src/core/MonoDevelop.Ide/icons/file-information-32~sel@2x.png diff --git a/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeRider-mac.xml b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeRider-mac.xml new file mode 100644 index 0000000000..ce1c764611 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeRider-mac.xml @@ -0,0 +1,169 @@ +<?xml version="1.0"?> +<scheme version="1.0"> + <binding command="MonoDevelop.AnalysisCore.AnalysisCommands.ShowFixes" shortcut="" /> + <binding command="MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" shortcut="" /> + <binding command="MonoDevelop.Components.MainToolbar.Commands.NavigateTo" shortcut="Meta+N" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ExpandSelection" shortcut="Meta+W" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ShrinkSelection" shortcut="Shift+Meta+W" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.NextUsage" shortcut="" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.PrevUsage" shortcut="" /> + <binding command="MonoDevelop.CSharp.Navigation.FindImplementingMembers" shortcut="Control+Alt+Shift+B" /> + <binding command="MonoDevelop.CSharp.Refactoring.ExtractMethodCommand" shortcut="Alt+Meta+M" /> + <binding command="MonoDevelop.CSharp.Refactoring.FindProjectReferenceUsages" shortcut="Alt+F7" /> + <binding command="MonoDevelop.CSharp.Refactoring.SortAndRemoveImportsCommand" shortcut="Alt+Meta+O" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Continue" shortcut="F5" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Debug" shortcut="Alt+F5" /> + <binding command="MonoDevelop.Debugger.DebugCommands.EnableDisableBreakpoint" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator" shortcut="Alt+F8" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Pause" shortcut="Shift+Meta+P" /> + <binding command="MonoDevelop.Debugger.DebugCommands.RunToCursor" shortcut="Meta+F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowBreakpoints" shortcut="Alt+F9" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepInto" shortcut="F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOut" shortcut="Shift+F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOver" shortcut="F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ToggleBreakpoint" shortcut="F9" /> + <binding command="MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.ClearFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.RestartFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendLine" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendReferences" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendSelection" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.ShowFSharpInteractive" shortcut="" /> + <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" shortcut="Alt+F8" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Copy" shortcut="Meta+C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Cut" shortcut="Meta+X" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Delete" shortcut="Meta+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.IndentSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.JoinWithNextLine" shortcut="Control+Shift+J" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" shortcut="Shift+Meta+U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Paste" shortcut="Meta+V" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Redo" shortcut="Shift+Meta+Z" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveCodeComment" shortcut="Meta+Y" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Rename" shortcut="F2" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.SelectAll" shortcut="Meta+A" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" shortcut="Shift+Meta++ Shift+Meta+-" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" shortcut="Meta+/" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" shortcut="Meta++ Meta+-" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Undo" shortcut="Meta+Z" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" shortcut="Shift+Meta+U" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseAllFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseFile" shortcut="Meta+F4" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseWorkspace" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Exit" shortcut="Meta+Q" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewProject" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewWorkspace" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.OpenFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.PrintDocument" shortcut="Control+Alt+Shift+P" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.ReloadFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Save" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAll" shortcut="Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAs" shortcut="Shift+Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.CopyPathName" shortcut="Shift+Meta+C" /> + <binding command="MonoDevelop.Ide.Commands.HelpCommands.Help" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" shortcut="Alt+Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" shortcut="Alt+Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Build" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.BuildSolution" shortcut="Shift+Meta+B" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Clean" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Rebuild" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Run" shortcut="Meta+F5" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.SetAsStartupProject" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Stop" shortcut="Shift+F5" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Find" shortcut="Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" shortcut="Control+Shift+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNext" shortcut="F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNextSelection" shortcut="Meta+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" shortcut="Shift+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoFile" shortcut="Shift+Meta+N" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" shortcut="Meta+G" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoType" shortcut="Alt+Shift+Meta+N" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Replace" shortcut="Meta+H" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ReplaceInFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ToggleBookmark" shortcut="Meta+F2" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharRight" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine" shortcut="Shift+Meta+L" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextWord" shortcut="Alt+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevWord" shortcut="Alt+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd" shortcut="Meta+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart" shortcut="Meta+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DuplicateLine" shortcut="Meta+D" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DynamicAbbrev" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" shortcut="Shift+Meta+M" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLineAtEnd" shortcut="Shift+Return" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLinePreserveCaretPosition" shortcut="Meta+Return" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineDown" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd" shortcut="Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineStart" shortcut="Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineUp" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveBlockDown" shortcut="Alt+Shift+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveBlockUp" shortcut="Alt+Shift+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextWord" shortcut="Alt+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevWord" shortcut="Alt+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PageDown" shortcut="Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PageUp" shortcut="Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PulseCaret" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageDown" shortcut="Meta+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageUp" shortcut="Meta+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveDown" shortcut="Shift+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveEnd" shortcut="Shift+End Shift+Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveHome" shortcut="Shift+Home Shift+Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveLeft" shortcut="Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextWord" shortcut="Alt+Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevWord" shortcut="Alt+Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveRight" shortcut="Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentEnd" shortcut="Shift+Meta+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentStart" shortcut="Shift+Meta+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveUp" shortcut="Shift+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageDownAction" shortcut="Shift+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageUpAction" shortcut="Shift+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeSurroundingsWindow" shortcut="Alt+Meta+T" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" shortcut="Meta+J" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" shortcut="Shift+Meta+I" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowParameterCompletionWindow" shortcut="Meta+P" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ToggleBlockSelectionMode" shortcut="Shift+Meta+8" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.TransposeCharacters" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FullScreen" shortcut="Control+Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.NextNotebook" shortcut="Alt+Tab" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.PreviousNotebook" shortcut="Alt+Shift+Tab" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" shortcut="Alt+Meta+Down" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" shortcut="Alt+Meta+Up" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SingleMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.NextDocument" shortcut="Control+Right" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.PrevDocument" shortcut="Control+Left" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchNextDocument" shortcut="Control+Down" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchPreviousDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Editor.MessageBubbleCommands.HideIssues" shortcut="Meta+F1" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideOthers" shortcut="" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideWindow" shortcut="" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.MinimizeWindow" shortcut="Meta+M" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.ZoomWindow" shortcut="Control+Meta+=" /> + <binding command="MonoDevelop.Refactoring.Navigation.FindDerivedSymbols" shortcut="Control+Alt+B" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.FindReferences" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration" shortcut="Meta+B" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.ImportSymbol" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.QuickFix" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" shortcut="F2" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" shortcut="Shift+F2" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RunAllTests" shortcut="Shift+Meta+T" /> + <binding command="MonoDevelop.VersionControl.Commands.SolutionStatus" shortcut="Meta+K" /> + <binding command="MonoDevelop.VersionControl.Commands.UpdateSolution" shortcut="Meta+T" /> +</scheme> diff --git a/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVSCode-mac.xml b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVSCode-mac.xml new file mode 100644 index 0000000000..ab642e7e97 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVSCode-mac.xml @@ -0,0 +1,165 @@ +<?xml version="1.0"?> +<scheme version="1.0"> + <binding command="MonoDevelop.AnalysisCore.AnalysisCommands.ShowFixes" shortcut="" /> + <binding command="MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" shortcut="" /> + <binding command="MonoDevelop.Components.MainToolbar.Commands.NavigateTo" shortcut="" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ExpandSelection" shortcut="Control+Shift+Meta+Right" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ShrinkSelection" shortcut="Control+Shift+Meta+Left" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.NextUsage" shortcut="" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.PrevUsage" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Continue" shortcut="F5" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Debug" shortcut="F5" /> + <binding command="MonoDevelop.Debugger.DebugCommands.EnableDisableBreakpoint" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Pause" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepInto" shortcut="F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOut" shortcut="Shift+F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOver" shortcut="F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ToggleBreakpoint" shortcut="F9" /> + <binding command="MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.ClearFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.RestartFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendLine" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendReferences" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendSelection" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.ShowFSharpInteractive" shortcut="" /> + <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" shortcut="Alt+Shift+F" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.AddCodeComment" shortcut="Meta+K|Meta+C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Copy" shortcut="Meta+C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Cut" shortcut="Meta+X" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Delete" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.IndentSelection" shortcut="Meta+] Tab" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" shortcut="Meta+," /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Paste" shortcut="Meta+V" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Redo" shortcut="Shift+Meta+Z" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveCodeComment" shortcut="Meta+K|Meta+U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveTrailingWhiteSpaces" shortcut="Shift+Meta+X" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Rename" shortcut="F2 Meta+F2" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.SelectAll" shortcut="Meta+A" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.SortSelectedLines" shortcut="Shift+Meta+2" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" shortcut="Alt+Shift+Meta+[ Alt+Shift+Meta+]" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" shortcut="Meta+/" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" shortcut="Shift+Meta+[ Shift+Meta+]" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Undo" shortcut="Meta+Z" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" shortcut="Meta+[ Shift+Tab" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseAllFiles" shortcut="Shift+Meta+W" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseFile" shortcut="Meta+W Meta+K|W" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseWorkspace" shortcut="Meta+K|F" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Exit" shortcut="Meta+Q" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewFile" shortcut="Meta+N" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewProject" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.OpenContainingFolder" shortcut="Meta+K|R" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.OpenFile" shortcut="Meta+O" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.OpenInTerminal" shortcut="Shift+Meta+C" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.PrintDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.ReloadFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Save" shortcut="Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAll" shortcut="Shift+Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.CloseAll" shortcut="Meta+K|Meta+W" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.CloseAllButThis" shortcut="Meta+K|Shift+Meta+W" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.CopyPathName" shortcut="Meta+K|P" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.ToggleMaximize" shortcut="Meta+B" /> + <binding command="MonoDevelop.Ide.Commands.HelpCommands.Help" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" shortcut="Control+-" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" shortcut="Control+Shift+-" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Build" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.BuildSolution" shortcut="Shift+Meta+B" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Clean" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Rebuild" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Run" shortcut="Meta+F5" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Stop" shortcut="Shift+F5" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Find" shortcut="Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" shortcut="Shift+Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNext" shortcut="F3 Meta+G" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNextSelection" shortcut="Meta+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" shortcut="Shift+F3 Shift+Meta+G" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPreviousSelection" shortcut="Shift+Meta+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoFile" shortcut="Meta+P" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" shortcut="Control+G" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoType" shortcut="Shift+Meta+O" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Replace" shortcut="Alt+Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ReplaceInFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft" shortcut="Control+B" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharRight" shortcut="Control+F" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar" shortcut="Control+H Shift+BackSpace Control+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine" shortcut="Shift+Meta+K" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextWord" shortcut="Alt+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevWord" shortcut="Alt+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar" shortcut="Control+D Control+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd" shortcut="Control+K Meta+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineStart" shortcut="Meta+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd" shortcut="Meta+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart" shortcut="Meta+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DuplicateLine" shortcut="Alt+Shift+Up Alt+Shift+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DynamicAbbrev" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ExpandSelectionToLine" shortcut="Meta+I" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" shortcut="Shift+Meta+\" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLineAtEnd" shortcut="Meta+Return" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLinePreserveCaretPosition" shortcut="Control+O" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineDown" shortcut="Control+N" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd" shortcut="Meta+Right Control+E" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineStart" shortcut="Meta+Left Control+A" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineUp" shortcut="Control+P" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveBlockDown" shortcut="Alt+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveBlockUp" shortcut="Alt+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextWord" shortcut="Alt+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevWord" shortcut="Alt+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PageDown" shortcut="Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PageUp" shortcut="Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PulseCaret" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineDown" shortcut="Control+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineUp" shortcut="Control+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageDown" shortcut="Meta+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageUp" shortcut="Meta+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveDown" shortcut="Shift+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveEnd" shortcut="Shift+End Shift+Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveHome" shortcut="Shift+Home Shift+Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveLeft" shortcut="Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextWord" shortcut="Alt+Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevWord" shortcut="Alt+Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveRight" shortcut="Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentEnd" shortcut="Shift+Meta+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentStart" shortcut="Shift+Meta+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveUp" shortcut="Shift+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageDownAction" shortcut="Shift+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageUpAction" shortcut="Shift+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" shortcut="Control+Space" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowParameterCompletionWindow" shortcut="Shift+Meta+Space" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.TransposeCharacters" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FocusCurrentDocument" shortcut="Meta+K|E" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FullScreen" shortcut="Control+Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.NextNotebook" shortcut="Alt+Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.PreviousNotebook" shortcut="Alt+Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" shortcut="Meta+\" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SingleMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" shortcut="Meta++" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" shortcut="Meta+-" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.NextDocument" shortcut="Meta+K|Down" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.PrevDocument" shortcut="Meta+K|Up" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchNextDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchPreviousDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Editor.MessageBubbleCommands.HideIssues" shortcut="Shift+Meta+M" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideOthers" shortcut="Alt+Meta+H" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideWindow" shortcut="Meta+H" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.MinimizeWindow" shortcut="Meta+M" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.FindReferences" shortcut="Shift+F12" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration" shortcut="F12" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.ImportSymbol" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.QuickFix" shortcut="Meta+." /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" shortcut="F8" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" shortcut="Shift+F8" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RunAllTests" shortcut="Shift+Meta+T" /> + <binding command="MonoDevelop.VersionControl.Commands.SolutionStatus" shortcut="Control+Shift+G" /> + <binding command="Pad|OutputPad-MonoDevelop.Ide.ApplicationOutput-0" shortcut="Shift+Meta+U" /> + <binding command="Pad|ProjectPad" shortcut="Meta+0 Shift+Meta+E" /> +</scheme> diff --git a/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio-mac.xml b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio-mac.xml new file mode 100644 index 0000000000..dbd3f5591c --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio-mac.xml @@ -0,0 +1,170 @@ +<?xml version="1.0"?> +<scheme version="1.0"> + <binding command="MonoDevelop.AnalysisCore.AnalysisCommands.ShowFixes" shortcut="" /> + <binding command="MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" shortcut="Meta+K|M Meta+K|Meta+M" /> + <binding command="MonoDevelop.Components.MainToolbar.Commands.NavigateTo" shortcut="Meta+," /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ExpandSelection" shortcut="Meta+Shift+]" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ShrinkSelection" shortcut="" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.NextUsage" shortcut="Meta+Shift+Down" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.PrevUsage" shortcut="Meta+Shift+Up" /> + <binding command="MonoDevelop.CSharp.Navigation.FindImplementingMembers" shortcut="Meta+F12" /> + <binding command="MonoDevelop.CSharp.Refactoring.ExtractMethodCommand" shortcut="Meta+R|M Meta+R|Meta+M" /> + <binding command="MonoDevelop.Debugger.DebugCommands.AttachToProcess" shortcut="Meta+Alt+P" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ClearAllBreakpoints" shortcut="Meta+Shift+F9" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Debug" shortcut="F5" /> + <binding command="MonoDevelop.Debugger.DebugCommands.EnableDisableBreakpoint" shortcut="Meta+F9" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Pause" shortcut="Meta+Alt+F15" /> + <binding command="MonoDevelop.Debugger.DebugCommands.RunToCursor" shortcut="Meta+F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.SetNextStatement" shortcut="Meta+Shift+F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowBreakpoints" shortcut="Meta+Alt+B Meta+D|B Meta+D|Meta+B" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowDisassembly" shortcut="Meta+Alt+D" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowNextStatement" shortcut="Alt+*" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepInto" shortcut="F11 Meta+F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOut" shortcut="Shift+F11 Meta+Shift+F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOver" shortcut="F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ToggleBreakpoint" shortcut="F9" /> + <binding command="MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.ClearFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.RestartFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendLine" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendReferences" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" shortcut="Meta+E|D Meta+K|D Meta+K|Meta+D" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.AddCodeComment" shortcut="Meta+E|C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Copy" shortcut="Meta+C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Cut" shortcut="Meta+X" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Delete" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" shortcut="Meta+M|Meta+O" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.IndentSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" shortcut="Meta+U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Paste" shortcut="Meta+V" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Redo" shortcut="Meta+Y" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveCodeComment" shortcut="Meta+E|U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveTrailingWhiteSpaces" shortcut="Meta+E|\ Meta+K|\" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Rename" shortcut="F2 Meta+R|R Meta+R|Meta+R" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.SelectAll" shortcut="Meta+A" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" shortcut="Meta+M|L Meta+M|Meta+L" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" shortcut="Meta+K|U Meta+K|Meta+U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" shortcut="Meta+M|M Meta+M|Meta+M" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Undo" shortcut="Meta+Z" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" shortcut="Meta+Shift+U" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseAllFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseFile" shortcut="Meta+F4" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseWorkspace" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Exit" shortcut="Alt+F4" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewFile" shortcut="Meta+N" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewProject" shortcut="Meta+Shift+N" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.OpenFile" shortcut="Meta+O Meta+Shift+O" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.PrintDocument" shortcut="Meta+P" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.ReloadFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Save" shortcut="Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAll" shortcut="Meta+Shift+S" /> + <binding command="MonoDevelop.Ide.Commands.HelpCommands.Help" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" shortcut="Meta+Shift+2 Meta+-" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" shortcut="Meta+Shift+1 Meta+Shift+-" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddItem" shortcut="Alt+Shift+A" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddNewFiles" shortcut="Meta+Shift+A" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Build" shortcut="Shift+F6 Meta+F7" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.BuildSolution" shortcut="F6 Meta+Shift+B" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Clean" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Rebuild" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Run" shortcut="Meta+F5" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RunCodeAnalysisSolution" shortcut="Alt+F11" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Stop" shortcut="Meta+F15 Shift+F5" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ClearBookmarks" shortcut="Meta+B|C Meta+K|L Meta+K|Meta+L" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Find" shortcut="Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" shortcut="Meta+Shift+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNext" shortcut="F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNextSelection" shortcut="Meta+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" shortcut="Shift+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPreviousSelection" shortcut="Meta+Shift+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" shortcut="Meta+G" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoType" shortcut="Meta+K|Meta+V" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.NextBookmark" shortcut="Meta+B|N Meta+K|N Meta+K|Meta+N" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.PrevBookmark" shortcut="Meta+B|P Meta+K|P Meta+K|Meta+P" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Replace" shortcut="Meta+H" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ReplaceInFiles" shortcut="Meta+Shift+H" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ToggleBookmark" shortcut="Meta+B|T Meta+K|K Meta+K|Meta+K" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharRight" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine" shortcut="Meta+L Meta+Shift+L" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextWord" shortcut="Meta+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevWord" shortcut="Meta+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd" shortcut="Meta+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart" shortcut="Meta+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DynamicAbbrev" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" shortcut="Meta+]" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLineAtEnd" shortcut="Meta+Shift+Return" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLinePreserveCaretPosition" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineDown" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd" shortcut="End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineStart" shortcut="Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineUp" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextWord" shortcut="Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevWord" shortcut="Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PulseCaret" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineDown" shortcut="Meta+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineUp" shortcut="Meta+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageDown" shortcut="Page_Down Meta+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageUp" shortcut="Page_Up Meta+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveEnd" shortcut="Shift+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveHome" shortcut="Shift+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextWord" shortcut="Meta+Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevWord" shortcut="Meta+Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeSurroundingsWindow" shortcut="Meta+K|S Meta+K|Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" shortcut="Meta+K|X Meta+K|Meta+X" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" shortcut="Meta+Space Meta+J" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FocusCurrentDocument" shortcut="F7" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FullScreen" shortcut="Alt+Shift+Return" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.NextNotebook" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.PreviousNotebook" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" shortcut="F8" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" shortcut="Shift+F8" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SingleMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" shortcut="Meta+Shift+. Meta+Alt+=" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" shortcut="Meta+Shift+, Meta+Alt+-" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.NextDocument" shortcut="Meta+F6" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.PrevDocument" shortcut="Meta+Shift+F6" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideOthers" shortcut="" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideWindow" shortcut="" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.MinimizeWindow" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.FindReferences" shortcut="Shift+F12 Meta+K|R Meta+K|Meta+R" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration" shortcut="F12" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.ImportSymbol" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.QuickFix" shortcut="Meta+." /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" shortcut="Meta+Shift+F12" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" shortcut="" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RerunTest" shortcut="Meta+R|L Meta+R|Meta+L" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RunAllTests" shortcut="Meta+R|A Meta+R|Meta+A" /> + <binding command="MonoDevelop.VersionMeta.Commands.Log" shortcut="Meta+0|O Meta+0|Meta+O" /> + <binding command="MonoDevelop.VersionMeta.Commands.SolutionStatus" shortcut="Meta+0|G Meta+0|Meta+G" /> + <binding command="MonoDevelop.VersionMeta.Git.Commands.ManageBranches" shortcut="Meta+0|N Meta+0|Meta+N" /> + <binding command="Pad|ClassPad" shortcut="Meta+Shift+C Meta+W|C" /> + <binding command="Pad|MonoDevelop.Debugger.ImmediatePad" shortcut="Meta+Alt+I Meta+D|I" /> + <binding command="Pad|MonoDevelop.Debugger.LocalsPad" shortcut="Meta+Alt+V|L Meta+D|L" /> + <binding command="Pad|MonoDevelop.Debugger.StackTracePad" shortcut="Meta+Alt+C Meta+D|C" /> + <binding command="Pad|MonoDevelop.Debugger.ThreadsPad" shortcut="Meta+Alt+H Meta+D|T" /> + <binding command="Pad|MonoDevelop.Debugger.WatchPad" shortcut="Meta+Alt+W Meta+D|W" /> + <binding command="Pad|MonoDevelop.DesignerSupport.DocumentOutlinePad" shortcut="Meta+Alt+T Meta+W|U" /> + <binding command="Pad|MonoDevelop.DesignerSupport.PropertyPad" shortcut="F4 Meta+W|P" /> + <binding command="Pad|MonoDevelop.DesignerSupport.ToolboxPad" shortcut="Meta+Alt+X Meta+W|X" /> + <binding command="Pad|MonoDevelop.Ide.Gui.Pads.ErrorListPad" shortcut="Meta+\|Meta+E Meta+W|E" /> + <binding command="Pad|MonoDevelop.Ide.Gui.Pads.TaskListPad" shortcut="Meta+\|Meta+T Meta+W|T" /> + <binding command="Pad|OutputPad-MonoDevelop.Ide.ApplicationOutput-0" shortcut="Meta+Alt+O Meta+W|O" /> + <binding command="Pad|ProjectPad" shortcut="Meta+Alt+L Meta+W|S" /> +</scheme> diff --git a/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio.xml b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio.xml index 24dd969d95..d41b2d703b 100644 --- a/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio.xml +++ b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeVisualStudio.xml @@ -1,64 +1,171 @@ <scheme version="1.0"> - <binding command="MonoDevelop.Ide.Commands.DebugCommands.Pause" shortcut="Control+Alt+Break" /> - <binding command="MonoDevelop.Ide.Commands.DebugCommands.StepInto" shortcut="F11" /> - <binding command="MonoDevelop.Ide.Commands.DebugCommands.StepOut" shortcut="Shift+F11" /> - <binding command="MonoDevelop.Ide.Commands.DebugCommands.StepOver" shortcut="F10" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" shortcut="Control+U" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" shortcut="Control+Shift+U" /> - <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseFile" shortcut="Control+F4" /> - <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAll" shortcut="Control+Shift+S" /> - <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAs" shortcut="" /> - <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" shortcut="Control+-" /> - <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" shortcut="Control+Shift+-" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Build" shortcut="Shift+F6" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.BuildSolution" shortcut="F6" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Debug" shortcut="F5" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" shortcut="Control+Alt+F7" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Run" shortcut="Control+F5" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNext" shortcut="F3" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" shortcut="Shift+F3" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.ReplaceInFiles" shortcut="Control+Shift+H" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.ClearBookmarks" shortcut="Control+B|C" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" shortcut="Control+G" /> - <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" shortcut="Control+]" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" shortcut="Control+M|Control+O" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" shortcut="Control+M|Control+L" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" shortcut="Control+M|Control+M" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.AddCodeComment" shortcut="Control+E|C" /> - <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveCodeComment" shortcut="Control+E|U" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddNewFiles" shortcut="Control+Shift+A" /> - <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddItem" shortcut="Alt+Shift+A" /> - <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" shortcut="F8" /> - <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" shortcut="Shift+F8" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoType" shortcut="Control+K|Control+V" /> - <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchSplitWindow" shortcut="" /> - <binding command="MonoDevelop.Debugger.DebugCommands.Debug" shortcut="F5" /> - <binding command="MonoDevelop.Debugger.DebugCommands.StepInto" shortcut="F11" /> - <binding command="MonoDevelop.Debugger.DebugCommands.StepOver" shortcut="F10" /> - <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd" shortcut="" /> - <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine" shortcut="Control+L" /> - <binding command="Pad|MonoDevelop.Ide.Gui.Pads.ErrorListPad" shortcut="Control+W|E" /> - <binding command="Pad|MonoDevelop.Debugger.LocalsPad" shortcut="Control+D|L" /> - <binding command="Pad|MonoDevelop.Debugger.StackTracePad" shortcut="Control+D|C" /> - <binding command="Pad|MonoDevelop.Debugger.ImmediatePad" shortcut="Control+D|I" /> - <binding command="Pad|MonoDevelop.Debugger.DebugCommands.ExpressionEvaluator" shortcut="Control+D|Q" /> - <binding command="Pad|MonoDevelop.Debugger.WatchPad" shortcut="Control+D|W" /> - <binding command="Pad|ClassPad" shortcut="Control+W|C" /> - <binding command="Pad|MonoDevelop.DesignerSupport.PropertyPad" shortcut="Control+W|P" /> - <binding command="Pad|ProjectPad" shortcut="Control+W|S" /> - <binding command="Pad|MonoDevelop.Ide.Gui.Pads.TaskListPad" shortcut="Control+W|T" /> - <binding command="Pad|MonoDevelop.DesignerSupport.ToolboxPad" shortcut="Control+W|X" /> - <binding command="Pad|ConnectionManagerPad" shortcut="Alt+Shift+D" /> - <binding command="Pad|MonoDevelop.Ide.Gui.Pads.HelpTree" shortcut="Control+W|F1" /> - <binding command="Pad|OutputPad-MonoDevelop.Ide.ApplicationOutput-0" shortcut="Control+W|O" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.NextBookmark" shortcut="Control+B|N" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.PrevBookmark" shortcut="Control+B|P" /> - <binding command="MonoDevelop.Ide.Commands.SearchCommands.ToggleBookmark" shortcut="Control+B|T" /> - <binding command="Pad|MonoDevelop.DesignerSupport.DocumentOutlinePad" shortcut="Control+W|U" /> - <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" shortcut="Control+Alt++" /> - <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" shortcut="Control+Alt+-" /> - <binding command="MonoDevelop.Refactoring.RefactoryCommands.QuickFix" shortcut="Control+." /> - <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" shortcut="Control+E|D" /> - <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatSelection" shortcut="Control+E|F" /> - <binding command="MonoDevelop.Debugger.DebugCommands.SelectExceptions" shortcut="Control+Alt+E" /> + <binding command="MonoDevelop.AnalysisCore.AnalysisCommands.ShowFixes" shortcut="" /> + <binding command="MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" shortcut="Control+K|M Control+K|Control+M" /> + <binding command="MonoDevelop.Components.MainToolbar.Commands.NavigateTo" shortcut="Control+," /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ExpandSelection" shortcut="Control+Shift+]" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ShrinkSelection" shortcut="" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.NextUsage" shortcut="Control+Shift+Down" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.PrevUsage" shortcut="Control+Shift+Up" /> + <binding command="MonoDevelop.CSharp.Navigation.FindImplementingMembers" shortcut="Control+F12" /> + <binding command="MonoDevelop.CSharp.Refactoring.ExtractMethodCommand" shortcut="Control+R|M Control+R|Control+M" /> + <binding command="MonoDevelop.Debugger.DebugCommands.AttachToProcess" shortcut="Control+Alt+P" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ClearAllBreakpoints" shortcut="Control+Shift+F9" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Debug" shortcut="F5" /> + <binding command="MonoDevelop.Debugger.DebugCommands.EnableDisableBreakpoint" shortcut="Control+F9" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Pause" shortcut="Control+Alt+F15" /> + <binding command="MonoDevelop.Debugger.DebugCommands.RunToCursor" shortcut="Control+F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.SetNextStatement" shortcut="Control+Shift+F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowBreakpoints" shortcut="Control+Alt+B Control+D|B Control+D|Control+B" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowCurrentExecutionLine" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowDisassembly" shortcut="Control+Alt+D" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowNextStatement" shortcut="Alt+*" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepInto" shortcut="F11 Control+F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOut" shortcut="Shift+F11 Control+Shift+F11" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOver" shortcut="F10" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ToggleBreakpoint" shortcut="F9" /> + <binding command="MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.ClearFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.RestartFsi" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendLine" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendReferences" shortcut="" /> + <binding command="MonoDevelop.FSharp.FSharpCommands.SendSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" shortcut="Control+E|D Control+K|D Control+K|Control+D" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.AddCodeComment" shortcut="Control+E|C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Copy" shortcut="Control+C" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Cut" shortcut="Control+X" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" shortcut="Control+M|Control+O" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.IndentSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.LowercaseSelection" shortcut="Control+U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.MonodevelopPreferences" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Paste" shortcut="Control+V" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Redo" shortcut="Control+Y" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveCodeComment" shortcut="Control+E|U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.RemoveTrailingWhiteSpaces" shortcut="Control+E|\ Control+K|\" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Rename" shortcut="F2 Control+R|R Control+R|Control+R" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.SelectAll" shortcut="Control+A" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" shortcut="Control+M|L Control+M|Control+L" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" shortcut="Control+K|U Control+K|Control+U" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleFolding" shortcut="Control+M|M Control+M|Control+M" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Undo" shortcut="Control+Z" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.UppercaseSelection" shortcut="Control+Shift+U" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseAllFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseFile" shortcut="Control+F4" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseWorkspace" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Exit" shortcut="Alt+F4" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewFile" shortcut="Control+N" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.NewProject" shortcut="Control+Shift+N" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.OpenFile" shortcut="Control+O Control+Shift+O" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.PrintDocument" shortcut="Control+P" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.ReloadFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.Save" shortcut="Control+S" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAll" shortcut="Control+Shift+S" /> + <binding command="MonoDevelop.Ide.Commands.HelpCommands.Help" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateBack" shortcut="Control+Shift+2 Control+-" /> + <binding command="MonoDevelop.Ide.Commands.NavigationCommands.NavigateForward" shortcut="Control+Shift+1 Control+Shift+-" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddItem" shortcut="Alt+Shift+A" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.AddNewFiles" shortcut="Control+Shift+A" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Build" shortcut="Shift+F6 Control+F7" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.BuildSolution" shortcut="F6 Control+Shift+B" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Clean" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Rebuild" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Run" shortcut="Control+F5" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RunCodeAnalysisSolution" shortcut="Alt+F11" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Stop" shortcut="Control+F15 Shift+F5" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ClearBookmarks" shortcut="Control+B|C Control+K|L Control+K|Control+L" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Find" shortcut="Control+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindInFiles" shortcut="Control+Shift+F" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNext" shortcut="F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindNextSelection" shortcut="Control+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPrevious" shortcut="Shift+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.FindPreviousSelection" shortcut="Control+Shift+F3" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" shortcut="Control+G" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoType" shortcut="Control+K|Control+V" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.NextBookmark" shortcut="Control+B|N Control+K|N Control+K|Control+N" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.PrevBookmark" shortcut="Control+B|P Control+K|P Control+K|Control+P" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.Replace" shortcut="Control+H" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ReplaceInFiles" shortcut="Control+Shift+H" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.ToggleBookmark" shortcut="Control+B|T Control+K|K Control+K|Control+K" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharRight" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CompleteStatement" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLine" shortcut="Control+L Control+Shift+L" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextWord" shortcut="Control+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevSubword" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevWord" shortcut="Control+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd" shortcut="Control+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart" shortcut="Control+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DynamicAbbrev" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" shortcut="Control+]" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLineAtEnd" shortcut="Control+Shift+Return" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.InsertNewLinePreserveCaretPosition" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineDown" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd" shortcut="End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineStart" shortcut="Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineUp" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextWord" shortcut="Control+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevWord" shortcut="Control+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PulseCaret" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineDown" shortcut="Control+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollLineUp" shortcut="Control+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageDown" shortcut="Page_Down Control+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ScrollPageUp" shortcut="Page_Up Control+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveEnd" shortcut="Shift+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveHome" shortcut="Shift+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextWord" shortcut="Control+Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevWord" shortcut="Control+Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeSurroundingsWindow" shortcut="Control+K|S Control+K|Control+S" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCodeTemplateWindow" shortcut="Control+K|X Control+K|Control+X" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" shortcut="Control+Space Control+J" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FocusCurrentDocument" shortcut="F7" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FullScreen" shortcut="Alt+Shift+Return" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.NextNotebook" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.PreviousNotebook" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" shortcut="F8" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" shortcut="Shift+F8" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SingleMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" shortcut="Control+Shift+. Control+Alt+=" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" shortcut="Control+Shift+, Control+Alt+-" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.NextDocument" shortcut="Control+F6" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.PrevDocument" shortcut="Control+Shift+F6" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideOthers" shortcut="" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.HideWindow" shortcut="" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.MinimizeWindow" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.FindReferences" shortcut="Shift+F12 Control+K|R Control+K|Control+R" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration" shortcut="F12" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.ImportSymbol" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.QuickFix" shortcut="Control+." /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" shortcut="Control+Shift+F12" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" shortcut="" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RerunTest" shortcut="Control+R|L Control+R|Control+L" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RunAllTests" shortcut="Control+R|A Control+R|Control+A" /> + <binding command="MonoDevelop.VersionControl.Commands.Log" shortcut="Control+0|O Control+0|Control+O" /> + <binding command="MonoDevelop.VersionControl.Commands.SolutionStatus" shortcut="Control+0|G Control+0|Control+G" /> + <binding command="MonoDevelop.VersionControl.Git.Commands.ManageBranches" shortcut="Control+0|N Control+0|Control+N" /> + <binding command="MonoDevelop.Xml.Editor.XmlCommands.RunXslTransform" shortcut="" /> + <binding command="Pad|ClassPad" shortcut="Control+Shift+C Control+W|C" /> + <binding command="Pad|MonoDevelop.Debugger.ImmediatePad" shortcut="Control+Alt+I Control+D|I" /> + <binding command="Pad|MonoDevelop.Debugger.LocalsPad" shortcut="Control+Alt+V|L Control+D|L" /> + <binding command="Pad|MonoDevelop.Debugger.StackTracePad" shortcut="Control+Alt+C Control+D|C" /> + <binding command="Pad|MonoDevelop.Debugger.ThreadsPad" shortcut="Control+Alt+H Control+D|T" /> + <binding command="Pad|MonoDevelop.Debugger.WatchPad" shortcut="Control+Alt+W Control+D|W" /> + <binding command="Pad|MonoDevelop.DesignerSupport.DocumentOutlinePad" shortcut="Control+Alt+T Control+W|U" /> + <binding command="Pad|MonoDevelop.DesignerSupport.PropertyPad" shortcut="F4 Control+W|P" /> + <binding command="Pad|MonoDevelop.DesignerSupport.ToolboxPad" shortcut="Control+Alt+X Control+W|X" /> + <binding command="Pad|MonoDevelop.Ide.Gui.Pads.ErrorListPad" shortcut="Control+\|Control+E Control+W|E" /> + <binding command="Pad|MonoDevelop.Ide.Gui.Pads.TaskListPad" shortcut="Control+\|Control+T Control+W|T" /> + <binding command="Pad|OutputPad-MonoDevelop.Ide.ApplicationOutput-0" shortcut="Control+Alt+O Control+W|O" /> + <binding command="Pad|ProjectPad" shortcut="Control+Alt+L Control+W|S" /> </scheme> diff --git a/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeXcode.xml b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeXcode.xml new file mode 100644 index 0000000000..4ae44b7e74 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/options/KeyBindingSchemeXcode.xml @@ -0,0 +1,124 @@ +<?xml version="1.0"?> +<scheme version="1.0"> + <binding command="MonoDevelop.AnalysisCore.AnalysisCommands.ShowFixes" shortcut="" /> + <binding command="MonoDevelop.CodeGeneration.CodeGenerationCommands.ShowCodeGenerationWindow" shortcut="" /> + <binding command="MonoDevelop.Components.MainToolbar.Commands.NavigateTo" shortcut="" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ExpandSelection" shortcut="" /> + <binding command="MonoDevelop.CSharp.ExpandCommands.ShrinkSelection" shortcut="" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.NextUsage" shortcut="" /> + <binding command="MonoDevelop.CSharp.Highlighting.MoveToUsagesCommand.PrevUsage" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Continue" shortcut="Control+Meta+Y" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Debug" shortcut="Meta+R" /> + <binding command="MonoDevelop.Debugger.DebugCommands.EnableDisableBreakpoint" shortcut="" /> + <binding command="MonoDevelop.Debugger.DebugCommands.Pause" shortcut="Control+Meta+Y" /> + <binding command="MonoDevelop.Debugger.DebugCommands.ShowBreakpoints" shortcut="Meta+7" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepInto" shortcut="F7" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOut" shortcut="F8" /> + <binding command="MonoDevelop.Debugger.DebugCommands.StepOver" shortcut="F6" /> + <binding command="MonoDevelop.DesignerSupport.Commands.SwitchBetweenRelatedFiles" shortcut="" /> + <binding command="MonoDevelop.Ide.CodeFormatting.CodeFormattingCommands.FormatBuffer" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Delete" shortcut="Meta+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.FoldDefinitions" shortcut="Control+Shift+Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.Rename" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.EditCommands.ToggleAllFoldings" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseAllFiles" shortcut="Meta+W" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.CloseFile" shortcut="Control+Meta+W Shift+Meta+W" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.PrintPageSetup" shortcut="Shift+Meta+P" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.ReloadFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.FileCommands.SaveAll" shortcut="Alt+Meta+S" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.CloseAllButThis" shortcut="Control+Alt+Meta+W" /> + <binding command="MonoDevelop.Ide.Commands.FileTabCommands.ToggleMaximize" shortcut="Meta+0" /> + <binding command="MonoDevelop.Ide.Commands.HelpCommands.Help" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Build" shortcut="Meta+B" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.BuildSolution" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.ProjectOptions" shortcut="Shift+Meta+," /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Rebuild" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RebuildSolution" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Run" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.RunCodeAnalysisProject" shortcut="Shift+Meta+B" /> + <binding command="MonoDevelop.Ide.Commands.ProjectCommands.Stop" shortcut="Meta+." /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoFile" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.SearchCommands.GotoLineNumber" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharLeft" shortcut="Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.CharRight" shortcut="Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteLeftChar" shortcut="Control+H" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextSubword" shortcut="Control+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteNextWord" shortcut="Alt+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevSubword" shortcut="Control+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeletePrevWord" shortcut="Alt+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteRightChar" shortcut="Control+D" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineEnd" shortcut="Control+K Meta+Delete" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DeleteToLineStart" shortcut="Meta+BackSpace" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentEnd" shortcut="Meta+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DocumentStart" shortcut="Meta+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.DynamicAbbrev" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.GotoMatchingBrace" shortcut="Shift+Meta+\" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineDown" shortcut="Control+N Alt+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineEnd" shortcut="Control+E Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineStart" shortcut="Control+A Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.LineUp" shortcut="Control+P Alt+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveBlockDown" shortcut="Alt+Meta+]" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveBlockUp" shortcut="Alt+Meta+[" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextSubword" shortcut="Control+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MoveNextWord" shortcut="Alt+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevSubword" shortcut="Control+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.MovePrevWord" shortcut="Alt+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PageDown" shortcut="Alt+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PageUp" shortcut="Alt+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.PulseCaret" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveDown" shortcut="Shift+Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveEnd" shortcut="Control+Shift+E Shift+Meta+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveHome" shortcut="Control+Shift+A Shift+Meta+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveLeft" shortcut="Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextSubword" shortcut="Control+Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveNextWord" shortcut="Alt+Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevSubword" shortcut="Control+Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMovePrevWord" shortcut="Alt+Shift+Left" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveRight" shortcut="Shift+Right" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentEnd" shortcut="Shift+Meta+Down Shift+End" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveToDocumentStart" shortcut="Shift+Meta+Up Shift+Home" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionMoveUp" shortcut="Alt+Shift+Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageDownAction" shortcut="Shift+Page_Down" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.SelectionPageUpAction" shortcut="Shift+Page_Up" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowCompletionWindow" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.TextEditorCommands.ShowParameterCompletionWindow" shortcut="Control+Space" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.CenterAndFocusCurrentDocument" shortcut="Control+L" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FocusCurrentDocument" shortcut="Meta+J" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.FullScreen" shortcut="Control+Meta+F" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.NextNotebook" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.PreviousNotebook" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowNext" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowPrevious" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ShowWelcomePage" shortcut="Shift+Meta+1" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SideBySideMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.SingleMode" shortcut="" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomIn" shortcut="Meta++" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomOut" shortcut="Meta+-" /> + <binding command="MonoDevelop.Ide.Commands.ViewCommands.ZoomReset" shortcut="Shift+Meta+=" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchNextDocument" shortcut="Control+3" /> + <binding command="MonoDevelop.Ide.Commands.WindowCommands.SwitchPreviousDocument" shortcut="Control+2" /> + <binding command="MonoDevelop.Ide.Editor.MessageBubbleCommands.HideIssues" shortcut="Control+Meta+M" /> + <binding command="MonoDevelop.IPhone.IPhoneCommands.Profile" shortcut="Meta+I" /> + <binding command="MonoDevelop.MacIntegration.MacIntegrationCommands.ZoomWindow" shortcut="Alt+Meta+8" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.FindReferences" shortcut="Control+Shift+Meta+F" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.GotoDeclaration" shortcut="Control+Meta+J" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.ImportSymbol" shortcut="" /> + <binding command="MonoDevelop.Refactoring.RefactoryCommands.QuickFix" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.NextIssueError" shortcut="Meta+'" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssue" shortcut="" /> + <binding command="MonoDevelop.SourceEditor.SourceEditorCommands.PrevIssueError" shortcut="Meta+Shift+'" /> + <binding command="MonoDevelop.UnitTesting.Commands.TestCommands.RunAllTests" shortcut="Meta+U" /> + <binding command="MonoDevelop.VersionControl.Commands.SolutionStatus" shortcut="Alt+Meta+C" /> + <binding command="MonoDevelop.VersionControl.Commands.UpdateSolution" shortcut="Alt+Meta+X" /> + <binding command="Pad|ClassPad" shortcut="Meta+2" /> + <binding command="Pad|MonoDevelop.Debugger.ImmediatePad" shortcut="Shift+Meta+C" /> + <binding command="Pad|MonoDevelop.Debugger.LocalsPad" shortcut="Meta+6" /> + <binding command="Pad|MonoDevelop.DesignerSupport.PropertyPad" shortcut="Alt+Meta+4" /> + <binding command="Pad|MonoDevelop.Ide.Gui.Pads.ErrorListPad" shortcut="Meta+4" /> + <binding command="Pad|MonoDevelop.Ide.Gui.Pads.HelpTree" shortcut="Shift+Meta+0" /> + <binding command="Pad|MonoDevelop.UnitTesting.TestPad" shortcut="Meta+5" /> + <binding command="Pad|ProjectPad" shortcut="Meta+1" /> + <binding command="Pad|SearchPad - Search Results - 0" shortcut="Meta+3" /> + <binding command="Xamarin.Inspector.XS.Commands.InspectorCommands.Inspect" shortcut="" /> +</scheme> |