Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reorgnize the projects.

- Moved dev12 dlls into new directory lib\V12.
- Updated dev12 dlls with version 12.0.21005.1.
- Renamed TeamFoundationServer to TeamFoundationServer12.
- Renamed Dialog to Dialog12
- Put common codes in TeamFoundationServer and Dialog.
  • Loading branch information...
commit f66ce5837e0773db3ac9e3cd9da328fc955e695c 1 parent 22a7c7f
@feiling feiling authored
Showing with 5,716 additions and 5,584 deletions.
  1. +4 −1 Build/Build.proj
  2. +2 −2 NuGet.sln
  3. BIN  lib/Microsoft.TeamFoundation.Client.dll
  4. BIN  lib/Microsoft.TeamFoundation.Common.dll
  5. BIN  lib/Microsoft.TeamFoundation.VersionControl.Client.dll
  6. BIN  lib/Microsoft.VisualStudio.ExtensionsExplorer.UI.dll
  7. BIN  lib/Microsoft.VisualStudio.ExtensionsExplorer.dll
  8. BIN  lib/Microsoft.VisualStudio.Shell.12.0.dll
  9. BIN  lib/Microsoft.VisualStudio.Threading.dll
  10. BIN  lib/VS12/Microsoft.TeamFoundation.Client.dll
  11. BIN  lib/VS12/Microsoft.TeamFoundation.Common.dll
  12. BIN  lib/VS12/Microsoft.TeamFoundation.VersionControl.Client.dll
  13. BIN  lib/VS12/Microsoft.VisualStudio.ExtensionsExplorer.UI.dll
  14. BIN  lib/VS12/Microsoft.VisualStudio.ExtensionsExplorer.dll
  15. 0  lib/{ → VS12}/Microsoft.VisualStudio.ProjectSystem.V12Only.dll
  16. BIN  lib/VS12/Microsoft.VisualStudio.Services.Common.dll
  17. BIN  lib/VS12/Microsoft.VisualStudio.Shell.12.0.dll
  18. BIN  lib/VS12/Microsoft.VisualStudio.Threading.dll
  19. +25 −25 src/{Dialog10 → Dialog}/CommonStyles.xaml
  20. +0 −197 src/Dialog/Dialog.csproj
  21. +12 −12 src/{Dialog10 → Dialog}/GlobalSuppressions.cs
  22. +32 −32 src/{Dialog10 → Dialog}/LoadPageResult.cs
  23. +45 −45 src/{Dialog10 → Dialog}/Nodes/EmptyTreeNode.cs
  24. 0  src/{Dialog10 → Dialog}/Nodes/OnlineTreeNode.cs
  25. +78 −78 src/{Dialog10 → Dialog}/Nodes/PackagesSearchNode.cs
  26. +675 −675 src/{Dialog10 → Dialog}/Nodes/PackagesTreeNodeBase.cs
  27. 0  src/{Dialog10 → Dialog}/Nodes/PagedPackagesSearchNode.cs
  28. +74 −74 src/{Dialog10 → Dialog}/Nodes/RootTreeNode.cs
  29. +59 −59 src/{Dialog10 → Dialog}/Nodes/SimpleTreeNode.cs
  30. +117 −117 src/{Dialog10 → Dialog}/Nodes/UpdatesTreeNode.cs
  31. +326 −326 src/{Dialog10 → Dialog}/OnlineProviderTemplates.xaml
  32. +265 −265 src/{Dialog10 → Dialog}/PackageItem.cs
  33. +142 −142 src/{Dialog10 → Dialog}/PackageManagerWindow.xaml
  34. +778 −778 src/{Dialog10 → Dialog}/PackageManagerWindow.xaml.cs
  35. +61 −61 src/{Dialog10 → Dialog}/PackageSortDescriptor.cs
  36. +91 −91 src/{Dialog10 → Dialog}/PackagesProvider.cd
  37. +341 −341 src/{Dialog10 → Dialog}/Providers/InstalledProvider.cs
  38. +246 −246 src/{Dialog10 → Dialog}/Providers/OnlineProvider.cs
  39. 0  src/{Dialog10 → Dialog}/Providers/OnlineSearchProvider.cs
  40. +788 −788 src/{Dialog10 → Dialog}/Providers/PackagesProviderBase.cs
  41. +324 −324 src/{Dialog10 → Dialog}/Providers/SolutionInstalledProvider.cs
  42. +165 −165 src/{Dialog10 → Dialog}/Providers/SolutionOnlineProvider.cs
  43. +218 −218 src/{Dialog10 → Dialog}/Providers/SolutionUpdatesProvider.cs
  44. +284 −284 src/{Dialog10 → Dialog}/Providers/UpdatesProvider.cs
  45. +93 −93 src/{Dialog10 → Dialog}/TemplateStyles.xaml
  46. +73 −28 src/Dialog10/Dialog10.csproj
  47. +28 −25 src/Dialog11/Dialog11.csproj
  48. +209 −0 src/Dialog12/Dialog12.csproj
  49. 0  src/{Dialog → Dialog12}/Properties/AssemblyInfo.cs
  50. 0  src/{Dialog → Dialog12}/packageicon.png
  51. +0 −71 src/TeamFoundationServer/TeamFoundationServer.csproj
  52. +1 −1  src/{TeamFoundationServer → TeamFoundationServer12}/Properties/AssemblyInfo.cs
  53. 0  src/{TeamFoundationServer → TeamFoundationServer12}/ProviderConstants.cs
  54. +81 −0 src/TeamFoundationServer12/TeamFoundationServer12.csproj
  55. +10 −1 src/VisualStudio/Resources/VsResources.Designer.cs
  56. +3 −0  src/VisualStudio/Resources/VsResources.resx
  57. +13 −3 src/VisualStudio/TfsSourceControlFileSystemProviderPicker.cs
  58. +31 −8 src/VsExtension/NuGetPackage.cs
  59. +10 −1 src/VsExtension/Resources.Designer.cs
  60. +3 −0  src/VsExtension/Resources.resx
  61. +9 −7 src/VsExtension/VsExtension.csproj
View
5 Build/Build.proj
@@ -156,7 +156,10 @@
</Target>
<Target Name="Build">
- <MSBuild Projects="$(NuGetRoot)\NuGet.sln" Targets="Build" Properties="EnableCodeAnalysis=true;DeployExtension=false" />
+ <PropertyGroup>
+ <EnableCodeAnalysis Condition="'$(EnableCodeAnalysis)' == ''" >true</EnableCodeAnalysis>
+ </PropertyGroup>
+ <MSBuild Projects="$(NuGetRoot)\NuGet.sln" Targets="Build" Properties="EnableCodeAnalysis=$(EnableCodeAnalysis);DeployExtension=false" />
</Target>
<Target Name="BuildMono">
View
4 NuGet.sln
@@ -69,7 +69,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellHost", "src\VsCon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommandLine", "src\CommandLine\CommandLine.csproj", "{B34A6632-E627-4B66-8E0A-D2DA3BC96893}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamFoundationServer", "src\TeamFoundationServer\TeamFoundationServer.csproj", "{5FC1C439-9263-470E-9C09-6E8B1E24C6B2}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamFoundationServer12", "src\TeamFoundationServer12\TeamFoundationServer12.csproj", "{5FC1C439-9263-470E-9C09-6E8B1E24C6B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellHostProvider", "src\VsConsole\PowerShellHostProvider\PowerShellHostProvider.csproj", "{A5E7AEB3-738F-4C39-A459-00F90483B2FE}"
EndProject
@@ -99,7 +99,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DialogServices", "src\Dialo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dialog10", "src\Dialog10\Dialog10.csproj", "{5984731D-613C-440A-833A-F92A3E3CF793}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dialog", "src\Dialog\Dialog.csproj", "{1C5E9CB6-F6FE-4858-BB63-AA50832F0A4D}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dialog12", "src\Dialog12\Dialog12.csproj", "{1C5E9CB6-F6FE-4858-BB63-AA50832F0A4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamFoundationServer10", "src\TeamFoundationServer10\TeamFoundationServer10.csproj", "{3F786922-B4F3-4C6E-B22F-3D764BA5B3B8}"
EndProject
View
BIN  lib/Microsoft.TeamFoundation.Client.dll
Binary file not shown
View
BIN  lib/Microsoft.TeamFoundation.Common.dll
Binary file not shown
View
BIN  lib/Microsoft.TeamFoundation.VersionControl.Client.dll
Binary file not shown
View
BIN  lib/Microsoft.VisualStudio.ExtensionsExplorer.UI.dll
Binary file not shown
View
BIN  lib/Microsoft.VisualStudio.ExtensionsExplorer.dll
Binary file not shown
View
BIN  lib/Microsoft.VisualStudio.Shell.12.0.dll
Binary file not shown
View
BIN  lib/Microsoft.VisualStudio.Threading.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.TeamFoundation.Client.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.TeamFoundation.Common.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.TeamFoundation.VersionControl.Client.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.VisualStudio.ExtensionsExplorer.UI.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.VisualStudio.ExtensionsExplorer.dll
Binary file not shown
View
0  lib/Microsoft.VisualStudio.ProjectSystem.V12Only.dll → .../Microsoft.VisualStudio.ProjectSystem.V12Only.dll
File renamed without changes
View
BIN  lib/VS12/Microsoft.VisualStudio.Services.Common.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.VisualStudio.Shell.12.0.dll
Binary file not shown
View
BIN  lib/VS12/Microsoft.VisualStudio.Threading.dll
Binary file not shown
View
50 src/Dialog10/CommonStyles.xaml → src/Dialog/CommonStyles.xaml
@@ -1,25 +1,25 @@
-<ResourceDictionary
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0">
-
- <Style TargetType="{x:Type Hyperlink}" x:Key="CommonHyperlinkStyle">
- <Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.ControlLinkTextKey}}" />
-
- <Style.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.ControlLinkTextHoverKey}}" />
- </Trigger>
-
- <Trigger Property="IsMouseOver" Value="False">
- <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
- </Trigger>
-
- <Trigger Property="NavigateUri" Value="{x:Null}">
- <Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}" />
- <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
- <Setter Property="IsEnabled" Value="False" />
- </Trigger>
- </Style.Triggers>
- </Style>
-</ResourceDictionary>
+<ResourceDictionary
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:vsshell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.10.0">
+
+ <Style TargetType="{x:Type Hyperlink}" x:Key="CommonHyperlinkStyle">
+ <Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.ControlLinkTextKey}}" />
+
+ <Style.Triggers>
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.ControlLinkTextHoverKey}}" />
+ </Trigger>
+
+ <Trigger Property="IsMouseOver" Value="False">
+ <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
+ </Trigger>
+
+ <Trigger Property="NavigateUri" Value="{x:Null}">
+ <Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}" />
+ <Setter Property="TextBlock.TextDecorations" Value="{x:Null}" />
+ <Setter Property="IsEnabled" Value="False" />
+ </Trigger>
+ </Style.Triggers>
+ </Style>
+</ResourceDictionary>
View
197 src/Dialog/Dialog.csproj
@@ -1,197 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\..\Build\NuGet.Settings.targets" />
- <PropertyGroup>
- <ProjectGuid>{1C5E9CB6-F6FE-4858-BB63-AA50832F0A4D}</ProjectGuid>
- <OutputType>Library</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>NuGet.Dialog</RootNamespace>
- <AssemblyName>NuGet.Dialog</AssemblyName>
- <CodeAnalysisRuleSet>..\..\NuGet.ruleset</CodeAnalysisRuleSet>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="Microsoft.VisualStudio.ExtensionsExplorer, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <HintPath>..\..\lib\Microsoft.VisualStudio.ExtensionsExplorer.dll</HintPath>
- <SpecificVersion>False</SpecificVersion>
- <Private>False</Private>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.ExtensionsExplorer.UI, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <HintPath>..\..\lib\Microsoft.VisualStudio.ExtensionsExplorer.UI.dll</HintPath>
- <SpecificVersion>False</SpecificVersion>
- <Private>False</Private>
- </Reference>
- <Reference Include="$(ShellAssembly)">
- <SpecificVersion>True</SpecificVersion>
- <HintPath>$(ShellAssemblyHintPath)</HintPath>
- <Private>False</Private>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <EmbedInteropTypes>False</EmbedInteropTypes>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>True</SpecificVersion>
- <EmbedInteropTypes>False</EmbedInteropTypes>
- <Private>False</Private>
- <HintPath>..\..\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll</HintPath>
- </Reference>
- <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
- <Reference Include="PresentationCore" />
- <Reference Include="PresentationFramework" />
- <Reference Include="System" />
- <Reference Include="System.ComponentModel.DataAnnotations" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xaml" />
- <Reference Include="System.Xml" />
- <Reference Include="WindowsBase" />
- </ItemGroup>
- <ItemGroup>
- <COMReference Include="EnvDTE">
- <Guid>{80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}</Guid>
- <VersionMajor>8</VersionMajor>
- <VersionMinor>0</VersionMinor>
- <Lcid>0</Lcid>
- <WrapperTool>primary</WrapperTool>
- <Isolated>False</Isolated>
- <EmbedInteropTypes>False</EmbedInteropTypes>
- </COMReference>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="..\..\Common\CommonAssemblyInfo.cs">
- <Link>Properties\CommonAssemblyInfo.cs</Link>
- </Compile>
- <Compile Include="..\..\Common\CommonResources.Designer.cs">
- <Link>CommonResources.Designer.cs</Link>
- <DependentUpon>CommonResources.resx</DependentUpon>
- </Compile>
- <Compile Include="..\Dialog10\GlobalSuppressions.cs">
- <Link>GlobalSuppressions.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\LoadPageResult.cs">
- <Link>LoadPageResult.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\EmptyTreeNode.cs">
- <Link>Nodes\EmptyTreeNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\PackagesSearchNode.cs">
- <Link>Nodes\PackagesSearchNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\PagedPackagesSearchNode.cs">
- <Link>Nodes\PagedPackagesSearchNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\PackagesTreeNodeBase.cs">
- <Link>Nodes\PackagesTreeNodeBase.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\RootTreeNode.cs">
- <Link>Nodes\RootTreeNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\SimpleTreeNode.cs">
- <Link>Nodes\SimpleTreeNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\OnlineTreeNode.cs">
- <Link>Nodes\OnlineTreeNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Nodes\UpdatesTreeNode.cs">
- <Link>Nodes\UpdatesTreeNode.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\PackageItem.cs">
- <Link>PackageItem.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\PackageManagerWindow.xaml.cs">
- <Link>PackageManagerWindow.xaml.cs</Link>
- <DependentUpon>PackageManagerWindow.xaml</DependentUpon>
- </Compile>
- <Compile Include="..\Dialog10\PackageSortDescriptor.cs">
- <Link>PackageSortDescriptor.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\InstalledProvider.cs">
- <Link>Providers\InstalledProvider.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\OnlineProvider.cs">
- <Link>Providers\OnlineProvider.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\PackagesProviderBase.cs">
- <Link>Providers\PackagesProviderBase.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\OnlineSearchProvider.cs">
- <Link>Providers\SearchProvider.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\SolutionInstalledProvider.cs">
- <Link>Providers\SolutionInstalledProvider.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\SolutionOnlineProvider.cs">
- <Link>Providers\SolutionOnlineProvider.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\SolutionUpdatesProvider.cs">
- <Link>Providers\SolutionUpdatesProvider.cs</Link>
- </Compile>
- <Compile Include="..\Dialog10\Providers\UpdatesProvider.cs">
- <Link>Providers\UpdatesProvider.cs</Link>
- </Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\Core\Core.csproj">
- <Project>{F879F274-EFA0-4157-8404-33A19B4E6AEC}</Project>
- <Name>Core</Name>
- </ProjectReference>
- <ProjectReference Include="..\DialogServices\DialogServices.csproj">
- <Project>{05497432-8899-4ED4-BB97-7B5EA3E911DB}</Project>
- <Name>DialogServices</Name>
- </ProjectReference>
- <ProjectReference Include="..\VisualStudio\VisualStudio.csproj">
- <Project>{6146CA62-CC16-422C-A105-3E81F7452AA6}</Project>
- <Name>VisualStudio</Name>
- </ProjectReference>
- <ProjectReference Include="..\VsConsole\Console.Types\Console.Types.csproj">
- <Project>{6FD11460-39A3-4A10-BA63-7541B0A7D053}</Project>
- <Name>Console.Types</Name>
- </ProjectReference>
- </ItemGroup>
- <ItemGroup>
- <CodeAnalysisDictionary Include="..\..\CodeAnalysisDictionary.xml">
- <Link>Properties\CodeAnalysisDictionary.xml</Link>
- </CodeAnalysisDictionary>
- </ItemGroup>
- <ItemGroup>
- <EmbeddedResource Include="..\..\Common\CommonResources.resx">
- <Link>CommonResources.resx</Link>
- <Generator>PublicResXFileCodeGenerator</Generator>
- <LastGenOutput>CommonResources.Designer.cs</LastGenOutput>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <Page Include="..\Dialog10\CommonStyles.xaml">
- <Link>CommonStyles.xaml</Link>
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Page Include="..\Dialog10\OnlineProviderTemplates.xaml">
- <Link>OnlineProviderTemplates.xaml</Link>
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Page Include="..\Dialog10\PackageManagerWindow.xaml">
- <Link>PackageManagerWindow.xaml</Link>
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Page Include="..\Dialog10\TemplateStyles.xaml">
- <Link>TemplateStyles.xaml</Link>
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- </ItemGroup>
- <ItemGroup>
- <Resource Include="packageicon.png" />
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
View
24 src/Dialog10/GlobalSuppressions.cs → src/Dialog/GlobalSuppressions.cs
@@ -1,12 +1,12 @@
-// This file is used by Code Analysis to maintain SuppressMessage
-// attributes that are applied to this project.
-// Project-level suppressions either have no target or are given
-// a specific target and scoped to a namespace, type, member, etc.
-//
-// To add a suppression to this file, right-click the message in the
-// Error List, point to "Suppress Message(s)", and click
-// "In Project Suppression File".
-// You do not need to add suppressions to this file manually.
-
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]
-[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NuGet.Dialog.Providers")]
+// This file is used by Code Analysis to maintain SuppressMessage
+// attributes that are applied to this project.
+// Project-level suppressions either have no target or are given
+// a specific target and scoped to a namespace, type, member, etc.
+//
+// To add a suppression to this file, right-click the message in the
+// Error List, point to "Suppress Message(s)", and click
+// "In Project Suppression File".
+// You do not need to add suppressions to this file manually.
+
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "NuGet.Dialog.Providers")]
View
64 src/Dialog10/LoadPageResult.cs → src/Dialog/LoadPageResult.cs
@@ -1,32 +1,32 @@
-using System.Collections.Generic;
-
-namespace NuGet.Dialog.Providers
-{
- internal class LoadPageResult
- {
- public LoadPageResult(IEnumerable<IPackage> packages, int pageNumber, int totalCount)
- {
- Packages = packages;
- PageNumber = pageNumber;
- TotalCount = totalCount;
- }
-
- public IEnumerable<IPackage> Packages
- {
- get;
- private set;
- }
-
- public int TotalCount
- {
- get;
- private set;
- }
-
- public int PageNumber
- {
- get;
- private set;
- }
- }
-}
+using System.Collections.Generic;
+
+namespace NuGet.Dialog.Providers
+{
+ internal class LoadPageResult
+ {
+ public LoadPageResult(IEnumerable<IPackage> packages, int pageNumber, int totalCount)
+ {
+ Packages = packages;
+ PageNumber = pageNumber;
+ TotalCount = totalCount;
+ }
+
+ public IEnumerable<IPackage> Packages
+ {
+ get;
+ private set;
+ }
+
+ public int TotalCount
+ {
+ get;
+ private set;
+ }
+
+ public int PageNumber
+ {
+ get;
+ private set;
+ }
+ }
+}
View
90 src/Dialog10/Nodes/EmptyTreeNode.cs → src/Dialog/Nodes/EmptyTreeNode.cs
@@ -1,45 +1,45 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.ExtensionsExplorer;
-
-namespace NuGet.Dialog.Providers
-{
-
- /// <summary>
- /// This tree node simply shows no packages.
- /// </summary>
- internal class EmptyTreeNode : PackagesTreeNodeBase
- {
- private readonly string _category;
-
- public EmptyTreeNode(PackagesProviderBase provider, string category, IVsExtensionsTreeNode parent) :
- base(parent, provider)
- {
-
- if (category == null)
- {
- throw new ArgumentNullException("category");
- }
-
- _category = category;
- }
-
- public override string Name
- {
- get
- {
- return _category;
- }
- }
-
- public override bool SupportsPrereleasePackages
- {
- get { return false; }
- }
-
- public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
- {
- return Enumerable.Empty<IPackage>().AsQueryable();
- }
- }
-}
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.ExtensionsExplorer;
+
+namespace NuGet.Dialog.Providers
+{
+
+ /// <summary>
+ /// This tree node simply shows no packages.
+ /// </summary>
+ internal class EmptyTreeNode : PackagesTreeNodeBase
+ {
+ private readonly string _category;
+
+ public EmptyTreeNode(PackagesProviderBase provider, string category, IVsExtensionsTreeNode parent) :
+ base(parent, provider)
+ {
+
+ if (category == null)
+ {
+ throw new ArgumentNullException("category");
+ }
+
+ _category = category;
+ }
+
+ public override string Name
+ {
+ get
+ {
+ return _category;
+ }
+ }
+
+ public override bool SupportsPrereleasePackages
+ {
+ get { return false; }
+ }
+
+ public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
+ {
+ return Enumerable.Empty<IPackage>().AsQueryable();
+ }
+ }
+}
View
0  src/Dialog10/Nodes/OnlineTreeNode.cs → src/Dialog/Nodes/OnlineTreeNode.cs
File renamed without changes
View
156 src/Dialog10/Nodes/PackagesSearchNode.cs → src/Dialog/Nodes/PackagesSearchNode.cs
@@ -1,79 +1,79 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.ExtensionsExplorer;
-
-namespace NuGet.Dialog.Providers
-{
- internal class PackagesSearchNode : PackagesTreeNodeBase
- {
- private string _searchText;
- private readonly PackagesTreeNodeBase _baseNode;
-
- public PackagesSearchNode(PackagesProviderBase provider, IVsExtensionsTreeNode parent, PackagesTreeNodeBase baseNode, string searchText) :
- base(parent, provider, baseNode.CollapseVersions)
- {
- if (baseNode == null)
- {
- throw new ArgumentNullException("baseNode");
- }
-
- _searchText = searchText;
- _baseNode = baseNode;
-
- // Mark this node as a SearchResults node to assist navigation in ExtensionsExplorer
- IsSearchResultsNode = true;
- }
-
- public PackagesTreeNodeBase BaseNode
- {
- get
- {
- return _baseNode;
- }
- }
-
- public override bool SupportsPrereleasePackages
- {
- get { return BaseNode.SupportsPrereleasePackages; }
- }
-
- public override string Name
- {
- get
- {
- return Resources.Dialog_RootNodeSearch;
- }
- }
-
- public void SetSearchText(string newSearchText)
- {
- if (newSearchText == null)
- {
- throw new ArgumentNullException("newSearchText");
- }
-
- _searchText = newSearchText;
-
- if (IsSelected)
- {
- ResetQuery();
- LoadPage(1);
- }
- }
-
- public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
- {
- return _baseNode.GetPackages(_searchText, allowPrereleaseVersions);
- }
-
- protected override IQueryable<IPackage> ApplyOrdering(IQueryable<IPackage> query)
- {
- if (Provider.CurrentSort == OnlineSearchProvider.RelevanceSortDescriptor)
- {
- // If we are sorting by relevance, then do nothing.
- return query;
- }
- return base.ApplyOrdering(query);
- }
- }
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.ExtensionsExplorer;
+
+namespace NuGet.Dialog.Providers
+{
+ internal class PackagesSearchNode : PackagesTreeNodeBase
+ {
+ private string _searchText;
+ private readonly PackagesTreeNodeBase _baseNode;
+
+ public PackagesSearchNode(PackagesProviderBase provider, IVsExtensionsTreeNode parent, PackagesTreeNodeBase baseNode, string searchText) :
+ base(parent, provider, baseNode.CollapseVersions)
+ {
+ if (baseNode == null)
+ {
+ throw new ArgumentNullException("baseNode");
+ }
+
+ _searchText = searchText;
+ _baseNode = baseNode;
+
+ // Mark this node as a SearchResults node to assist navigation in ExtensionsExplorer
+ IsSearchResultsNode = true;
+ }
+
+ public PackagesTreeNodeBase BaseNode
+ {
+ get
+ {
+ return _baseNode;
+ }
+ }
+
+ public override bool SupportsPrereleasePackages
+ {
+ get { return BaseNode.SupportsPrereleasePackages; }
+ }
+
+ public override string Name
+ {
+ get
+ {
+ return Resources.Dialog_RootNodeSearch;
+ }
+ }
+
+ public void SetSearchText(string newSearchText)
+ {
+ if (newSearchText == null)
+ {
+ throw new ArgumentNullException("newSearchText");
+ }
+
+ _searchText = newSearchText;
+
+ if (IsSelected)
+ {
+ ResetQuery();
+ LoadPage(1);
+ }
+ }
+
+ public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
+ {
+ return _baseNode.GetPackages(_searchText, allowPrereleaseVersions);
+ }
+
+ protected override IQueryable<IPackage> ApplyOrdering(IQueryable<IPackage> query)
+ {
+ if (Provider.CurrentSort == OnlineSearchProvider.RelevanceSortDescriptor)
+ {
+ // If we are sorting by relevance, then do nothing.
+ return query;
+ }
+ return base.ApplyOrdering(query);
+ }
+ }
}
View
1,350 src/Dialog10/Nodes/PackagesTreeNodeBase.cs → src/Dialog/Nodes/PackagesTreeNodeBase.cs
@@ -1,676 +1,676 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.VisualStudio.ExtensionsExplorer;
-using NuGet.VisualStudio;
-
-namespace NuGet.Dialog.Providers
-{
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
- internal abstract class PackagesTreeNodeBase : IVsExtensionsTreeNode, IVsSortDataSource, IVsProgressPaneConsumer, INotifyPropertyChanged, IVsMessagePaneConsumer
- {
- // The number of extensions to show per page for online
- public const int DefaultItemsPerPage = 10;
-
- // We cache the query until it changes (due to sort order or search)
- private IEnumerable<IPackage> _query;
- private int _totalCount;
-
-#if VS10
- private IList<IVsExtension> _extensions;
-#else
- private IList _extensions;
-#endif
-
- private IList<IVsExtensionsTreeNode> _nodes;
- private int _totalPages = 1, _currentPage = 1;
- private bool _progressPaneActive;
- private bool _isExpanded;
- private bool _isSelected;
- private bool _loadingInProgress;
- private bool _includePrereleaseWhenLastLoaded;
- private readonly bool _collapseVersions;
-
- // true if packages are fetched in pages. Otherwise, all packages are fetched in 1 page.
- private bool _isPaged;
-
- private CancellationTokenSource _currentCancellationSource;
-
- public event PropertyChangedEventHandler PropertyChanged;
- public event EventHandler<EventArgs> PageDataChanged;
-
- protected PackagesTreeNodeBase(IVsExtensionsTreeNode parent, PackagesProviderBase provider, bool collapseVersions = true)
- {
- Debug.Assert(provider != null);
-
- _collapseVersions = collapseVersions;
- Parent = parent;
- Provider = provider;
- PageSize = DefaultItemsPerPage;
-
- _isPaged = this is IVsPageDataSource;
- }
-
- public bool CollapseVersions
- {
- get
- {
- return _collapseVersions;
- }
- }
-
- public bool IsPaged
- {
- get
- {
- return _isPaged;
- }
- }
-
- protected PackagesProviderBase Provider
- {
- get;
- private set;
- }
-
- private IVsProgressPane ProgressPane
- {
- get;
- set;
- }
-
- private IVsMessagePane MessagePane
- {
- get;
- set;
- }
-
- /// <summary>
- /// Name of this node
- /// </summary>
- public abstract string Name
- {
- get;
- }
-
- public bool IsSearchResultsNode
- {
- get;
- set;
- }
-
- /// <summary>
- /// Select node (UI) property
- /// This property maps to TreeViewItem.IsSelected
- /// </summary>
- public bool IsSelected
- {
- get
- {
- return _isSelected;
- }
- set
- {
- if (_isSelected != value)
- {
- _isSelected = value;
- OnNotifyPropertyChanged("IsSelected");
- }
- }
- }
-
- public abstract bool SupportsPrereleasePackages { get; }
-
- /// <summary>
- /// Expand node (UI) property
- /// This property maps to TreeViewItem.IsExpanded
- /// </summary>
- public bool IsExpanded
- {
- get
- {
- return _isExpanded;
- }
- set
- {
- if (_isExpanded != value)
- {
- _isExpanded = value;
- OnNotifyPropertyChanged("IsExpanded");
- }
- }
- }
-
- /// <summary>
- /// List of templates at this node for the current page only
- /// </summary>
-#if VS10
- public IList<IVsExtension> Extensions
- {
-#else
- public IList Extensions {
-#endif
- get
- {
- if (_extensions == null)
- {
- EnsureExtensionCollection();
- LoadPage(1);
- }
-
- return _extensions;
- }
- }
-
- /// <summary>
- /// Children at this node
- /// </summary>
- public IList<IVsExtensionsTreeNode> Nodes
- {
- get
- {
- if (_nodes == null)
- {
- _nodes = new ObservableCollection<IVsExtensionsTreeNode>();
- }
- return _nodes;
- }
- }
- /// <summary>
- /// Parent of this node
- /// </summary>
- public IVsExtensionsTreeNode Parent
- {
- get;
- private set;
- }
-
- public int TotalPages
- {
- get
- {
- return _totalPages;
- }
- internal set
- {
- _totalPages = value;
- NotifyPropertyChanged();
- }
- }
-
- public int CurrentPage
- {
- get
- {
- return _currentPage;
- }
- internal set
- {
- _currentPage = value;
- NotifyPropertyChanged();
- }
- }
-
- public int TotalNumberOfPackages
- {
- get
- {
- return _totalCount;
- }
- }
-
- /// <summary>
- /// Raised when the current node completes loading packages.
- /// </summary>
- internal event EventHandler PackageLoadCompleted = delegate { };
-
- internal int PageSize
- {
- get;
- set;
- }
-
- /// <summary>
- /// Refresh the list of packages belong to this node
- /// </summary>
- public virtual void Refresh(bool resetQueryBeforeRefresh = false)
- {
- if (resetQueryBeforeRefresh)
- {
- ResetQuery();
- }
- LoadPage(CurrentPage);
- }
-
- public override string ToString()
- {
- return Name;
- }
-
- /// <summary>
- /// Get all packages belonging to this node.
- /// </summary>
- /// <returns></returns>
- public abstract IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions);
-
- /// <summary>
- /// Helper function to raise property changed events
- /// </summary>
- private void NotifyPropertyChanged()
- {
- if (PageDataChanged != null)
- {
- PageDataChanged(this, EventArgs.Empty);
- }
- }
-
- /// <summary>
- /// Loads the packages in the specified page.
- /// </summary>
- /// <param name="pageNumber"></param>
- public void LoadPage(int pageNumber)
- {
- if (pageNumber < 1)
- {
- throw new ArgumentOutOfRangeException(
- "pageNumber",
- String.Format(CultureInfo.CurrentCulture, CommonResources.Argument_Must_Be_GreaterThanOrEqualTo, 1));
- }
-
- if (_loadingInProgress || Provider.SuppressLoad)
- {
- return;
- }
-
- EnsureExtensionCollection();
-
- // Bug #1930: this will clear the content of details pane
- Extensions.Clear();
-
- ShowProgressPane();
-
- // avoid more than one loading occurring at the same time
- _loadingInProgress = true;
-
- _includePrereleaseWhenLastLoaded = Provider.IncludePrerelease;
-
- _currentCancellationSource = new CancellationTokenSource();
-
- TaskScheduler uiScheduler;
- try
- {
- uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
- }
- catch (InvalidOperationException)
- {
- // FromCurrentSynchronizationContext() fails when running from unit test
- uiScheduler = TaskScheduler.Default;
- }
-
- NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadBegin);
- Task.Factory.StartNew(
- (state) => ExecuteAsync(pageNumber, _currentCancellationSource.Token),
- _currentCancellationSource,
- _currentCancellationSource.Token).ContinueWith(QueryExecutionCompleted, uiScheduler);
- }
-
- private void EnsureExtensionCollection()
- {
- if (_extensions == null)
- {
- _extensions = new ObservableCollection<IVsExtension>();
- }
- }
-
- /// <summary>
- /// Called when user clicks on the Cancel button in the progress pane.
- /// </summary>
- private void CancelCurrentExtensionQuery()
- {
- Debug.WriteLine("Cancelling pending extensions query.");
-
- if (_currentCancellationSource != null)
- {
- _currentCancellationSource.Cancel();
- _loadingInProgress = false;
- Provider.RemoveSearchNode();
- }
- }
-
- /// <summary>
- /// This method executes on background thread.
- /// </summary>
- [System.Diagnostics.CodeAnalysis.SuppressMessage(
- "Microsoft.Design",
- "CA1031:DoNotCatchGeneralExceptionTypes",
- Justification = "We want to show error message inside the dialog, rather than blowing up VS.")]
- private LoadPageResult ExecuteAsync(int pageNumber, CancellationToken token)
- {
- token.ThrowIfCancellationRequested();
-
- if (_query == null)
- {
- IQueryable<IPackage> query = GetPackages(searchTerm: null, allowPrereleaseVersions: Provider.IncludePrerelease);
-
- if (CollapseVersions)
- {
- query = CollapsePackageVersions(query);
- }
-
- token.ThrowIfCancellationRequested();
-
- // Execute the total count query
- _totalCount = query.Count();
-
- if (_totalCount == 0)
- {
- return new LoadPageResult(new IPackage[0], 0, 0);
- }
-
- if (!_isPaged)
- {
- PageSize = _totalCount;
- }
-
- // make sure we don't query a page that is greater than the maximum page number.
- int maximumPages = (_totalCount + PageSize - 1)/PageSize;
- pageNumber = Math.Min(pageNumber, maximumPages);
-
- token.ThrowIfCancellationRequested();
-
- IQueryable<IPackage> orderedQuery = ApplyOrdering(query);
-
- // Buffer 3 pages
- _query = orderedQuery.AsBufferedEnumerable(PageSize * 3);
-
- if (CollapseVersions)
- {
- // If we are connecting to an older gallery implementation, we need to use the Published field.
- // For newer gallery, the package is never unpublished, it is only unlisted.
- _query = _query.Where(PackageExtensions.IsListed).AsCollapsed();
- }
- }
-
- IList<IPackage> packages = _query.Skip((pageNumber - 1) * PageSize)
- .Take(PageSize)
- .ToList();
-
- if (packages.Count < PageSize)
- {
- _totalCount = (pageNumber - 1) * PageSize + packages.Count;
- }
-
- token.ThrowIfCancellationRequested();
-
- return new LoadPageResult(packages, pageNumber, _totalCount);
- }
-
- protected virtual IQueryable<IPackage> CollapsePackageVersions(IQueryable<IPackage> packages)
- {
- if (Provider.IncludePrerelease && SupportsPrereleasePackages)
- {
- return packages.Where(p => p.IsAbsoluteLatestVersion);
- }
- else
- {
- return packages.Where(p => p.IsLatestVersion);
- }
- }
-
- protected virtual IQueryable<IPackage> ApplyOrdering(IQueryable<IPackage> query)
- {
- // If the default sort is null then fall back to download count
- IOrderedQueryable<IPackage> result;
- if (Provider.CurrentSort == null)
- {
- result = query.OrderByDescending(p => p.DownloadCount);
- }
- else
- {
- // Order by the current descriptor
- result = query.SortBy<IPackage>(Provider.CurrentSort.SortProperties, Provider.CurrentSort.Direction);
- }
- return result.ThenBy(p => p.Id);
- }
-
- public IList<IVsSortDescriptor> GetSortDescriptors()
- {
- // Get the sort descriptor from the provider
- return Provider.SortDescriptors;
- }
-
- protected internal void ResetQuery()
- {
- _query = null;
- }
-
- public bool SortSelectionChanged(IVsSortDescriptor selectedDescriptor)
- {
- Provider.CurrentSort = selectedDescriptor as PackageSortDescriptor;
-
- // The value of CurrentSort could be null if we're dealing with the SearchProvider. Use the selectedDescriptor instead since it returns the actual instance.
- if (selectedDescriptor != null)
- {
- // If we changed the sort order then invalidate the cache.
- ResetQuery();
-
- // Reload the first page since the sort order changed
- LoadPage(1);
- return true;
- }
-
- return false;
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage(
- "Microsoft.Design",
- "CA1031:DoNotCatchGeneralExceptionTypes",
- Justification = "We don't want it to crash VS.")]
- private void QueryExecutionCompleted(Task<LoadPageResult> task)
- {
- // If a task throws, the exception must be handled or the Exception
- // property must be accessed or the exception will tear down the process when finalized
- Exception exception = task.Exception;
-
- if (task.IsFaulted)
- {
- try
- {
- ExceptionHelper.WriteToActivityLog(exception);
- }
- catch
- {
- // don't let this crash VS
- }
- }
-
- var cancellationSource = (CancellationTokenSource)task.AsyncState;
- if (cancellationSource != _currentCancellationSource)
- {
- return;
- }
-
- _loadingInProgress = false;
-
- // Only process the result if this node is still selected.
- if (IsSelected)
- {
- if (task.IsFaulted)
- {
- if (cancellationSource.IsCancellationRequested)
- {
- HideProgressPane();
- }
- else
- {
- // show error message in the Message pane
- ShowMessagePane(ExceptionUtility.Unwrap(exception).Message);
- }
- }
- else if (task.IsCanceled)
- {
- HideProgressPane();
- }
- else
- {
- LoadPageResult result = task.Result;
-
- UpdateNewPackages(result.Packages.ToList());
-
- int totalPages = (result.TotalCount + PageSize - 1) / PageSize;
- TotalPages = Math.Max(1, totalPages);
- CurrentPage = Math.Max(1, result.PageNumber);
-
- HideProgressPane();
- }
- }
-
- Provider.OnPackageLoadCompleted(this);
-
- // for unit tests
- PackageLoadCompleted(this, EventArgs.Empty);
- NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadEnd);
- }
-
- private void UpdateNewPackages(IList<IPackage> packages)
- {
- int newPackagesIndex = 0;
- int oldPackagesIndex = 0;
- while (oldPackagesIndex < _extensions.Count)
- {
- if (newPackagesIndex >= packages.Count)
- {
- _extensions.RemoveAt(oldPackagesIndex);
- }
- else
- {
- PackageItem currentOldItem = (PackageItem)_extensions[oldPackagesIndex];
- if (PackageEqualityComparer.IdAndVersion.Equals(packages[newPackagesIndex], currentOldItem.PackageIdentity))
- {
- newPackagesIndex++;
- oldPackagesIndex++;
- }
- else
- {
- _extensions.RemoveAt(oldPackagesIndex);
- }
- }
- }
-
- while (newPackagesIndex < packages.Count)
- {
- var extension = Provider.CreateExtension(packages[newPackagesIndex++]);
- if (extension != null)
- {
- _extensions.Add(extension);
- }
- }
-
- if (_extensions.Count > 0)
- {
- // select the first package by default
- ((IVsExtension)_extensions[0]).IsSelected = true;
- }
- }
-
- protected void OnNotifyPropertyChanged(string propertyName)
- {
- if (PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-
- public void SetProgressPane(IVsProgressPane progressPane)
- {
- ProgressPane = progressPane;
- }
-
- public void SetMessagePane(IVsMessagePane messagePane)
- {
- MessagePane = messagePane;
- }
-
- protected bool ShowProgressPane()
- {
- if (ProgressPane != null)
- {
- _progressPaneActive = true;
- return ProgressPane.Show(new CancelProgressCallback(CancelCurrentExtensionQuery), true);
- }
- else
- {
- return false;
- }
- }
-
- protected void HideProgressPane()
- {
- if (_progressPaneActive && ProgressPane != null)
- {
- ProgressPane.Close();
- _progressPaneActive = false;
- }
- }
-
- protected bool ShowMessagePane(string message)
- {
- if (MessagePane != null)
- {
- MessagePane.SetMessageThreadSafe(message);
- return MessagePane.Show();
- }
- else
- {
- return false;
- }
- }
-
- /// <summary>
- /// Called when this node is opened.
- /// </summary>
- internal void OnOpened()
- {
- if (!Provider.SuppressNextRefresh)
- {
- Provider.SelectedNode = this;
- if (!this.IsSearchResultsNode)
- {
- // If user switches back to this node, and the Include Prerelease combox box value
- // has changed, we need to reload the packages.
- //
- // This 'if' statement must come before the next one, so that we favor setting
- // 'resetQueryBeforeRefresh' to true.
- if (_includePrereleaseWhenLastLoaded != Provider.IncludePrerelease)
- {
- Refresh(resetQueryBeforeRefresh: true);
- return;
- }
-
- if (Provider.RefreshOnNodeSelection)
- {
- Refresh();
- }
- }
- }
- }
-
- /// <summary>
- /// Called when the focus switches away from this node
- /// </summary>
- internal virtual void OnClosed()
- {
- if (IsSearchResultsNode)
- {
- Provider.RemoveSearchNode();
- }
- }
- }
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.ExtensionsExplorer;
+using NuGet.VisualStudio;
+
+namespace NuGet.Dialog.Providers
+{
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
+ internal abstract class PackagesTreeNodeBase : IVsExtensionsTreeNode, IVsSortDataSource, IVsProgressPaneConsumer, INotifyPropertyChanged, IVsMessagePaneConsumer
+ {
+ // The number of extensions to show per page for online
+ public const int DefaultItemsPerPage = 10;
+
+ // We cache the query until it changes (due to sort order or search)
+ private IEnumerable<IPackage> _query;
+ private int _totalCount;
+
+#if VS10
+ private IList<IVsExtension> _extensions;
+#else
+ private IList _extensions;
+#endif
+
+ private IList<IVsExtensionsTreeNode> _nodes;
+ private int _totalPages = 1, _currentPage = 1;
+ private bool _progressPaneActive;
+ private bool _isExpanded;
+ private bool _isSelected;
+ private bool _loadingInProgress;
+ private bool _includePrereleaseWhenLastLoaded;
+ private readonly bool _collapseVersions;
+
+ // true if packages are fetched in pages. Otherwise, all packages are fetched in 1 page.
+ private bool _isPaged;
+
+ private CancellationTokenSource _currentCancellationSource;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ public event EventHandler<EventArgs> PageDataChanged;
+
+ protected PackagesTreeNodeBase(IVsExtensionsTreeNode parent, PackagesProviderBase provider, bool collapseVersions = true)
+ {
+ Debug.Assert(provider != null);
+
+ _collapseVersions = collapseVersions;
+ Parent = parent;
+ Provider = provider;
+ PageSize = DefaultItemsPerPage;
+
+ _isPaged = this is IVsPageDataSource;
+ }
+
+ public bool CollapseVersions
+ {
+ get
+ {
+ return _collapseVersions;
+ }
+ }
+
+ public bool IsPaged
+ {
+ get
+ {
+ return _isPaged;
+ }
+ }
+
+ protected PackagesProviderBase Provider
+ {
+ get;
+ private set;
+ }
+
+ private IVsProgressPane ProgressPane
+ {
+ get;
+ set;
+ }
+
+ private IVsMessagePane MessagePane
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Name of this node
+ /// </summary>
+ public abstract string Name
+ {
+ get;
+ }
+
+ public bool IsSearchResultsNode
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Select node (UI) property
+ /// This property maps to TreeViewItem.IsSelected
+ /// </summary>
+ public bool IsSelected
+ {
+ get
+ {
+ return _isSelected;
+ }
+ set
+ {
+ if (_isSelected != value)
+ {
+ _isSelected = value;
+ OnNotifyPropertyChanged("IsSelected");
+ }
+ }
+ }
+
+ public abstract bool SupportsPrereleasePackages { get; }
+
+ /// <summary>
+ /// Expand node (UI) property
+ /// This property maps to TreeViewItem.IsExpanded
+ /// </summary>
+ public bool IsExpanded
+ {
+ get
+ {
+ return _isExpanded;
+ }
+ set
+ {
+ if (_isExpanded != value)
+ {
+ _isExpanded = value;
+ OnNotifyPropertyChanged("IsExpanded");
+ }
+ }
+ }
+
+ /// <summary>
+ /// List of templates at this node for the current page only
+ /// </summary>
+#if VS10
+ public IList<IVsExtension> Extensions
+ {
+#else
+ public IList Extensions {
+#endif
+ get
+ {
+ if (_extensions == null)
+ {
+ EnsureExtensionCollection();
+ LoadPage(1);
+ }
+
+ return _extensions;
+ }
+ }
+
+ /// <summary>
+ /// Children at this node
+ /// </summary>
+ public IList<IVsExtensionsTreeNode> Nodes
+ {
+ get
+ {
+ if (_nodes == null)
+ {
+ _nodes = new ObservableCollection<IVsExtensionsTreeNode>();
+ }
+ return _nodes;
+ }
+ }
+ /// <summary>
+ /// Parent of this node
+ /// </summary>
+ public IVsExtensionsTreeNode Parent
+ {
+ get;
+ private set;
+ }
+
+ public int TotalPages
+ {
+ get
+ {
+ return _totalPages;
+ }
+ internal set
+ {
+ _totalPages = value;
+ NotifyPropertyChanged();
+ }
+ }
+
+ public int CurrentPage
+ {
+ get
+ {
+ return _currentPage;
+ }
+ internal set
+ {
+ _currentPage = value;
+ NotifyPropertyChanged();
+ }
+ }
+
+ public int TotalNumberOfPackages
+ {
+ get
+ {
+ return _totalCount;
+ }
+ }
+
+ /// <summary>
+ /// Raised when the current node completes loading packages.
+ /// </summary>
+ internal event EventHandler PackageLoadCompleted = delegate { };
+
+ internal int PageSize
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Refresh the list of packages belong to this node
+ /// </summary>
+ public virtual void Refresh(bool resetQueryBeforeRefresh = false)
+ {
+ if (resetQueryBeforeRefresh)
+ {
+ ResetQuery();
+ }
+ LoadPage(CurrentPage);
+ }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+
+ /// <summary>
+ /// Get all packages belonging to this node.
+ /// </summary>
+ /// <returns></returns>
+ public abstract IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions);
+
+ /// <summary>
+ /// Helper function to raise property changed events
+ /// </summary>
+ private void NotifyPropertyChanged()
+ {
+ if (PageDataChanged != null)
+ {
+ PageDataChanged(this, EventArgs.Empty);
+ }
+ }
+
+ /// <summary>
+ /// Loads the packages in the specified page.
+ /// </summary>
+ /// <param name="pageNumber"></param>
+ public void LoadPage(int pageNumber)
+ {
+ if (pageNumber < 1)
+ {
+ throw new ArgumentOutOfRangeException(
+ "pageNumber",
+ String.Format(CultureInfo.CurrentCulture, CommonResources.Argument_Must_Be_GreaterThanOrEqualTo, 1));
+ }
+
+ if (_loadingInProgress || Provider.SuppressLoad)
+ {
+ return;
+ }
+
+ EnsureExtensionCollection();
+
+ // Bug #1930: this will clear the content of details pane
+ Extensions.Clear();
+
+ ShowProgressPane();
+
+ // avoid more than one loading occurring at the same time
+ _loadingInProgress = true;
+
+ _includePrereleaseWhenLastLoaded = Provider.IncludePrerelease;
+
+ _currentCancellationSource = new CancellationTokenSource();
+
+ TaskScheduler uiScheduler;
+ try
+ {
+ uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
+ }
+ catch (InvalidOperationException)
+ {
+ // FromCurrentSynchronizationContext() fails when running from unit test
+ uiScheduler = TaskScheduler.Default;
+ }
+
+ NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadBegin);
+ Task.Factory.StartNew(
+ (state) => ExecuteAsync(pageNumber, _currentCancellationSource.Token),
+ _currentCancellationSource,
+ _currentCancellationSource.Token).ContinueWith(QueryExecutionCompleted, uiScheduler);
+ }
+
+ private void EnsureExtensionCollection()
+ {
+ if (_extensions == null)
+ {
+ _extensions = new ObservableCollection<IVsExtension>();
+ }
+ }
+
+ /// <summary>
+ /// Called when user clicks on the Cancel button in the progress pane.
+ /// </summary>
+ private void CancelCurrentExtensionQuery()
+ {
+ Debug.WriteLine("Cancelling pending extensions query.");
+
+ if (_currentCancellationSource != null)
+ {
+ _currentCancellationSource.Cancel();
+ _loadingInProgress = false;
+ Provider.RemoveSearchNode();
+ }
+ }
+
+ /// <summary>
+ /// This method executes on background thread.
+ /// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage(
+ "Microsoft.Design",
+ "CA1031:DoNotCatchGeneralExceptionTypes",
+ Justification = "We want to show error message inside the dialog, rather than blowing up VS.")]
+ private LoadPageResult ExecuteAsync(int pageNumber, CancellationToken token)
+ {
+ token.ThrowIfCancellationRequested();
+
+ if (_query == null)
+ {
+ IQueryable<IPackage> query = GetPackages(searchTerm: null, allowPrereleaseVersions: Provider.IncludePrerelease);
+
+ if (CollapseVersions)
+ {
+ query = CollapsePackageVersions(query);
+ }
+
+ token.ThrowIfCancellationRequested();
+
+ // Execute the total count query
+ _totalCount = query.Count();
+
+ if (_totalCount == 0)
+ {
+ return new LoadPageResult(new IPackage[0], 0, 0);
+ }
+
+ if (!_isPaged)
+ {
+ PageSize = _totalCount;
+ }
+
+ // make sure we don't query a page that is greater than the maximum page number.
+ int maximumPages = (_totalCount + PageSize - 1)/PageSize;
+ pageNumber = Math.Min(pageNumber, maximumPages);
+
+ token.ThrowIfCancellationRequested();
+
+ IQueryable<IPackage> orderedQuery = ApplyOrdering(query);
+
+ // Buffer 3 pages
+ _query = orderedQuery.AsBufferedEnumerable(PageSize * 3);
+
+ if (CollapseVersions)
+ {
+ // If we are connecting to an older gallery implementation, we need to use the Published field.
+ // For newer gallery, the package is never unpublished, it is only unlisted.
+ _query = _query.Where(PackageExtensions.IsListed).AsCollapsed();
+ }
+ }
+
+ IList<IPackage> packages = _query.Skip((pageNumber - 1) * PageSize)
+ .Take(PageSize)
+ .ToList();
+
+ if (packages.Count < PageSize)
+ {
+ _totalCount = (pageNumber - 1) * PageSize + packages.Count;
+ }
+
+ token.ThrowIfCancellationRequested();
+
+ return new LoadPageResult(packages, pageNumber, _totalCount);
+ }
+
+ protected virtual IQueryable<IPackage> CollapsePackageVersions(IQueryable<IPackage> packages)
+ {
+ if (Provider.IncludePrerelease && SupportsPrereleasePackages)
+ {
+ return packages.Where(p => p.IsAbsoluteLatestVersion);
+ }
+ else
+ {
+ return packages.Where(p => p.IsLatestVersion);
+ }
+ }
+
+ protected virtual IQueryable<IPackage> ApplyOrdering(IQueryable<IPackage> query)
+ {
+ // If the default sort is null then fall back to download count
+ IOrderedQueryable<IPackage> result;
+ if (Provider.CurrentSort == null)
+ {
+ result = query.OrderByDescending(p => p.DownloadCount);
+ }
+ else
+ {
+ // Order by the current descriptor
+ result = query.SortBy<IPackage>(Provider.CurrentSort.SortProperties, Provider.CurrentSort.Direction);
+ }
+ return result.ThenBy(p => p.Id);
+ }
+
+ public IList<IVsSortDescriptor> GetSortDescriptors()
+ {
+ // Get the sort descriptor from the provider
+ return Provider.SortDescriptors;
+ }
+
+ protected internal void ResetQuery()
+ {
+ _query = null;
+ }
+
+ public bool SortSelectionChanged(IVsSortDescriptor selectedDescriptor)
+ {
+ Provider.CurrentSort = selectedDescriptor as PackageSortDescriptor;
+
+ // The value of CurrentSort could be null if we're dealing with the SearchProvider. Use the selectedDescriptor instead since it returns the actual instance.
+ if (selectedDescriptor != null)
+ {
+ // If we changed the sort order then invalidate the cache.
+ ResetQuery();
+
+ // Reload the first page since the sort order changed
+ LoadPage(1);
+ return true;
+ }
+
+ return false;
+ }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage(
+ "Microsoft.Design",
+ "CA1031:DoNotCatchGeneralExceptionTypes",
+ Justification = "We don't want it to crash VS.")]
+ private void QueryExecutionCompleted(Task<LoadPageResult> task)
+ {
+ // If a task throws, the exception must be handled or the Exception
+ // property must be accessed or the exception will tear down the process when finalized
+ Exception exception = task.Exception;
+
+ if (task.IsFaulted)
+ {
+ try
+ {
+ ExceptionHelper.WriteToActivityLog(exception);
+ }
+ catch
+ {
+ // don't let this crash VS
+ }
+ }
+
+ var cancellationSource = (CancellationTokenSource)task.AsyncState;
+ if (cancellationSource != _currentCancellationSource)
+ {
+ return;
+ }
+
+ _loadingInProgress = false;
+
+ // Only process the result if this node is still selected.
+ if (IsSelected)
+ {
+ if (task.IsFaulted)
+ {
+ if (cancellationSource.IsCancellationRequested)
+ {
+ HideProgressPane();
+ }
+ else
+ {
+ // show error message in the Message pane
+ ShowMessagePane(ExceptionUtility.Unwrap(exception).Message);
+ }
+ }
+ else if (task.IsCanceled)
+ {
+ HideProgressPane();
+ }
+ else
+ {
+ LoadPageResult result = task.Result;
+
+ UpdateNewPackages(result.Packages.ToList());
+
+ int totalPages = (result.TotalCount + PageSize - 1) / PageSize;
+ TotalPages = Math.Max(1, totalPages);
+ CurrentPage = Math.Max(1, result.PageNumber);
+
+ HideProgressPane();
+ }
+ }
+
+ Provider.OnPackageLoadCompleted(this);
+
+ // for unit tests
+ PackageLoadCompleted(this, EventArgs.Empty);
+ NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageLoadEnd);
+ }
+
+ private void UpdateNewPackages(IList<IPackage> packages)
+ {
+ int newPackagesIndex = 0;
+ int oldPackagesIndex = 0;
+ while (oldPackagesIndex < _extensions.Count)
+ {
+ if (newPackagesIndex >= packages.Count)
+ {
+ _extensions.RemoveAt(oldPackagesIndex);
+ }
+ else
+ {
+ PackageItem currentOldItem = (PackageItem)_extensions[oldPackagesIndex];
+ if (PackageEqualityComparer.IdAndVersion.Equals(packages[newPackagesIndex], currentOldItem.PackageIdentity))
+ {
+ newPackagesIndex++;
+ oldPackagesIndex++;
+ }
+ else
+ {
+ _extensions.RemoveAt(oldPackagesIndex);
+ }
+ }
+ }
+
+ while (newPackagesIndex < packages.Count)
+ {
+ var extension = Provider.CreateExtension(packages[newPackagesIndex++]);
+ if (extension != null)
+ {
+ _extensions.Add(extension);
+ }
+ }
+
+ if (_extensions.Count > 0)
+ {
+ // select the first package by default
+ ((IVsExtension)_extensions[0]).IsSelected = true;
+ }
+ }
+
+ protected void OnNotifyPropertyChanged(string propertyName)
+ {
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ public void SetProgressPane(IVsProgressPane progressPane)
+ {
+ ProgressPane = progressPane;
+ }
+
+ public void SetMessagePane(IVsMessagePane messagePane)
+ {
+ MessagePane = messagePane;
+ }
+
+ protected bool ShowProgressPane()
+ {
+ if (ProgressPane != null)
+ {
+ _progressPaneActive = true;
+ return ProgressPane.Show(new CancelProgressCallback(CancelCurrentExtensionQuery), true);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ protected void HideProgressPane()
+ {
+ if (_progressPaneActive && ProgressPane != null)
+ {
+ ProgressPane.Close();
+ _progressPaneActive = false;
+ }
+ }
+
+ protected bool ShowMessagePane(string message)
+ {
+ if (MessagePane != null)
+ {
+ MessagePane.SetMessageThreadSafe(message);
+ return MessagePane.Show();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// Called when this node is opened.
+ /// </summary>
+ internal void OnOpened()
+ {
+ if (!Provider.SuppressNextRefresh)
+ {
+ Provider.SelectedNode = this;
+ if (!this.IsSearchResultsNode)
+ {
+ // If user switches back to this node, and the Include Prerelease combox box value
+ // has changed, we need to reload the packages.
+ //
+ // This 'if' statement must come before the next one, so that we favor setting
+ // 'resetQueryBeforeRefresh' to true.
+ if (_includePrereleaseWhenLastLoaded != Provider.IncludePrerelease)
+ {
+ Refresh(resetQueryBeforeRefresh: true);
+ return;
+ }
+
+ if (Provider.RefreshOnNodeSelection)
+ {
+ Refresh();
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Called when the focus switches away from this node
+ /// </summary>
+ internal virtual void OnClosed()
+ {
+ if (IsSearchResultsNode)
+ {
+ Provider.RemoveSearchNode();
+ }
+ }
+ }
}
View
0  src/Dialog10/Nodes/PagedPackagesSearchNode.cs → src/Dialog/Nodes/PagedPackagesSearchNode.cs
File renamed without changes
View
148 src/Dialog10/Nodes/RootTreeNode.cs → src/Dialog/Nodes/RootTreeNode.cs
@@ -1,74 +1,74 @@
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using Microsoft.VisualStudio.ExtensionsExplorer;
-
-namespace NuGet.Dialog.Providers
-{
- /// <summary>
- /// Base implementation of IVsExtensionsTreeNode
- /// </summary>
- public class RootPackagesTreeNode : IVsExtensionsTreeNode
- {
- private readonly IList<IVsExtensionsTreeNode> nodes = new ObservableCollection<IVsExtensionsTreeNode>();
-
- #region IVsExtensionsTreeNode Members
-
-#if VS10
- private readonly IList<IVsExtension> extensions = new ObservableCollection<IVsExtension>();
-
- public IList<IVsExtension> Extensions
- {
- get { return extensions; }
- }
-#else
- private readonly IList extensions = new ObservableCollection<IVsExtension>();
-
- public IList Extensions {
- get { return extensions; }
- }
-#endif
-
- public bool IsSearchResultsNode
- {
- get { return false; }
- }
-
- public bool IsExpanded
- {
- get;
- set;
- }
-
- public bool IsSelected
- {
- get;
- set;
- }
-
- public string Name
- {
- get;
- set;
- }
-
- public IList<IVsExtensionsTreeNode> Nodes
- {
- get { return nodes; }
- }
-
- public IVsExtensionsTreeNode Parent
- {
- get;
- set;
- }
-
- #endregion
-
- public RootPackagesTreeNode(IVsExtensionsTreeNode parent, string name)
- {
- this.Parent = parent;
- this.Name = name;
- }
- }
-}
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Microsoft.VisualStudio.ExtensionsExplorer;
+
+namespace NuGet.Dialog.Providers
+{
+ /// <summary>
+ /// Base implementation of IVsExtensionsTreeNode
+ /// </summary>
+ public class RootPackagesTreeNode : IVsExtensionsTreeNode
+ {
+ private readonly IList<IVsExtensionsTreeNode> nodes = new ObservableCollection<IVsExtensionsTreeNode>();
+
+ #region IVsExtensionsTreeNode Members
+
+#if VS10
+ private readonly IList<IVsExtension> extensions = new ObservableCollection<IVsExtension>();
+
+ public IList<IVsExtension> Extensions
+ {
+ get { return extensions; }
+ }
+#else
+ private readonly IList extensions = new ObservableCollection<IVsExtension>();
+
+ public IList Extensions {
+ get { return extensions; }
+ }
+#endif
+
+ public bool IsSearchResultsNode
+ {
+ get { return false; }
+ }
+
+ public bool IsExpanded
+ {
+ get;
+ set;
+ }
+
+ public bool IsSelected
+ {
+ get;
+ set;
+ }
+
+ public string Name
+ {
+ get;
+ set;
+ }
+
+ public IList<IVsExtensionsTreeNode> Nodes
+ {
+ get { return nodes; }
+ }
+
+ public IVsExtensionsTreeNode Parent
+ {
+ get;
+ set;
+ }
+
+ #endregion
+
+ public RootPackagesTreeNode(IVsExtensionsTreeNode parent, string name)
+ {
+ this.Parent = parent;
+ this.Name = name;
+ }
+ }
+}
View
118 src/Dialog10/Nodes/SimpleTreeNode.cs → src/Dialog/Nodes/SimpleTreeNode.cs
@@ -1,60 +1,60 @@
-using System;
-using System.Linq;
-using Microsoft.VisualStudio.ExtensionsExplorer;
-
-namespace NuGet.Dialog.Providers
-{
- /// <summary>
- /// This tree node lists all packages from a fixed repository.
- /// </summary>
- internal class SimpleTreeNode : PackagesTreeNodeBase
- {
- private readonly IPackageRepository _repository;
- private readonly string _category;
-
- public IPackageRepository Repository
- {
- get
- {
- return _repository;
- }
- }
-
- public SimpleTreeNode(PackagesProviderBase provider, string category, IVsExtensionsTreeNode parent, IPackageRepository repository, bool collapseVersion = true) :
- base(parent, provider, collapseVersion)
- {
- if (category == null)
- {
- throw new ArgumentNullException("category");
- }
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
-
- _category = category;
- _repository = repository;
- }
-
- public override string Name
- {
- get
- {
- return _category;
- }
- }
-
- public override bool SupportsPrereleasePackages
- {
- get
- {
- return Repository.SupportsPrereleasePackages;
- }
- }
-
- public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
- {
- return Repository.Search(searchTerm: searchTerm, targetFrameworks: Provider.SupportedFrameworks, allowPrereleaseVersions: allowPrereleaseVersions);
- }
- }
+using System;
+using System.Linq;
+using Microsoft.VisualStudio.ExtensionsExplorer;
+
+namespace NuGet.Dialog.Providers
+{
+ /// <summary>
+ /// This tree node lists all packages from a fixed repository.
+ /// </summary>
+ internal class SimpleTreeNode : PackagesTreeNodeBase
+ {
+ private readonly IPackageRepository _repository;
+ private readonly string _category;
+
+ public IPackageRepository Repository
+ {
+ get
+ {
+ return _repository;
+ }
+ }
+
+ public SimpleTreeNode(PackagesProviderBase provider, string category, IVsExtensionsTreeNode parent, IPackageRepository repository, bool collapseVersion = true) :
+ base(parent, provider, collapseVersion)
+ {
+ if (category == null)
+ {
+ throw new ArgumentNullException("category");
+ }
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+
+ _category = category;
+ _repository = repository;
+ }
+
+ public override string Name
+ {
+ get
+ {
+ return _category;
+ }
+ }
+
+ public override bool SupportsPrereleasePackages
+ {
+ get
+ {
+ return Repository.SupportsPrereleasePackages;
+ }
+ }
+
+ public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
+ {
+ return Repository.Search(searchTerm: searchTerm, targetFrameworks: Provider.SupportedFrameworks, allowPrereleaseVersions: allowPrereleaseVersions);
+ }
+ }
}
View
234 src/Dialog10/Nodes/UpdatesTreeNode.cs → src/Dialog/Nodes/UpdatesTreeNode.cs
@@ -1,118 +1,118 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Versioning;
-using Microsoft.VisualStudio.ExtensionsExplorer;
-
-namespace NuGet.Dialog.Providers
-{
- /// <summary>
- /// This class represents a tree node under the Updates tab
- /// </summary>
- internal class UpdatesTreeNode : SimpleTreeNode
- {
- private readonly IPackageRepository _localRepository;
-
- // This is used to cache update packages.
- // Index 0 is for includePrerelease = true. Index 1 is for includePrerelease = false
- private readonly IList<IPackage>[] _updatePackagesCache = new IList<IPackage>[2];
-
- public UpdatesTreeNode(
- PackagesProviderBase provider,
- string category,
- IVsExtensionsTreeNode parent,
- IPackageRepository localRepository,
- IPackageRepository sourceRepository) :
- base(provider, category, parent, sourceRepository)
- {
- _localRepository = localRepository;
- }
-
- public override void Refresh(bool resetQueryBeforeRefresh = false)
- {
- // if we are about the refresh the packages, we need to clear the cache
- _updatePackagesCache[0] = _updatePackagesCache[1] = null;
- base.Refresh(resetQueryBeforeRefresh);
- }
-
- internal override void OnClosed()
- {
- // if focus switches away from this node, we need to clear the cache
- // so that the next time it becomes active, it will reload packages.
- _updatePackagesCache[0] = _updatePackagesCache[1] = null;
- base.OnClosed();
- }
-
- public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
- {
- int cacheIndex = -1;
-
- // if this not a search request, we'll cache the request
- if (String.IsNullOrEmpty(searchTerm))
- {
- cacheIndex = allowPrereleaseVersions ? 0 : 1;
- }
-
- if (cacheIndex > -1 && _updatePackagesCache[cacheIndex] != null)
- {
- return _updatePackagesCache[cacheIndex].AsQueryable();
- }
-
- // We need to call ToList() here so that we don't evaluate the enumerable twice
- IList<FrameworkName> solutionFrameworks = Provider.SupportedFrameworks.Select(s => new FrameworkName(s)).ToList();
-
- // The allow prerelease flag passed to this method indicates if we are allowed to show prerelease packages as part of the updates
- // and does not reflect the filtering of packages we are looking for updates to.
- var packages = _localRepository.GetPackages();
- if (!String.IsNullOrEmpty(searchTerm))
- {
- packages = packages.Find(searchTerm);
- }
-
- // Fix Bug #3034: When showing updates in solution-level dialog, it can happen that the local repository includes
- // both jQuery 1.7 and jQuery 1.9 (from two different projects). To shows update for the jQuery 1.7, we need to make
- // sure to remove jQuery 1.9 from the list.
- // To do so, we sort all packages by increasing version, and call Distinct() which effectively remove higher versions of each package id
- List<IPackage> packagesList = packages.ToList();
- if (packagesList.Count > 0)
- {
- packagesList.Sort(PackageComparer.Version);
- packagesList = packagesList.Distinct<IPackage>(PackageEqualityComparer.Id).ToList();
- }
-
- IQueryable<IPackage> updatePackages;
-
- // If the local repository contains constraints for each package, we send the version constraints to the GetUpdates() service.
- IPackageConstraintProvider constraintProvider = _localRepository as IPackageConstraintProvider;
- if (constraintProvider != null)
- {
- IEnumerable<IVersionSpec> constraintList = packagesList.Select(p => constraintProvider.GetConstraint(p.Id));
- updatePackages = Repository.GetUpdates(packagesList, allowPrereleaseVersions, includeAllVersions: false, targetFrameworks: solutionFrameworks, versionConstraints: constraintList)
- .AsQueryable();
- }
- else
- {
- updatePackages = Repository.GetUpdates(packagesList, allowPrereleaseVersions, includeAllVersions: false, targetFrameworks: solutionFrameworks)
- .AsQueryable();
- }
-
- if (cacheIndex > -1)
- {
- _updatePackagesCache[cacheIndex] = updatePackages.ToList();
-
- // IMPORTANT: We must return this list, instead of 'updatePackages' directly to avoid additional request
- // when the downstream code try to sort the results.
- return _updatePackagesCache[cacheIndex].AsQueryable();
- }
-
- return updatePackages;
- }
-
- protected override IQueryable<IPackage> CollapsePackageVersions(IQueryable<IPackage> packages)
- {
- // GetUpdates collapses package versions to start with. Additionally, our method of using the IsLatest might not work here because
- // we might have a package that is not the latest version but is the only compatible package that satisfies the result set.
- return packages;
- }
- }
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.Versioning;
+using Microsoft.VisualStudio.ExtensionsExplorer;
+
+namespace NuGet.Dialog.Providers
+{
+ /// <summary>
+ /// This class represents a tree node under the Updates tab
+ /// </summary>
+ internal class UpdatesTreeNode : SimpleTreeNode
+ {
+ private readonly IPackageRepository _localRepository;
+
+ // This is used to cache update packages.
+ // Index 0 is for includePrerelease = true. Index 1 is for includePrerelease = false
+ private readonly IList<IPackage>[] _updatePackagesCache = new IList<IPackage>[2];
+
+ public UpdatesTreeNode(
+ PackagesProviderBase provider,
+ string category,
+ IVsExtensionsTreeNode parent,
+ IPackageRepository localRepository,
+ IPackageRepository sourceRepository) :
+ base(provider, category, parent, sourceRepository)
+ {
+ _localRepository = localRepository;
+ }
+
+ public override void Refresh(bool resetQueryBeforeRefresh = false)
+ {
+ // if we are about the refresh the packages, we need to clear the cache
+ _updatePackagesCache[0] = _updatePackagesCache[1] = null;
+ base.Refresh(resetQueryBeforeRefresh);
+ }
+
+ internal override void OnClosed()
+ {
+ // if focus switches away from this node, we need to clear the cache
+ // so that the next time it becomes active, it will reload packages.
+ _updatePackagesCache[0] = _updatePackagesCache[1] = null;
+ base.OnClosed();
+ }
+
+ public override IQueryable<IPackage> GetPackages(string searchTerm, bool allowPrereleaseVersions)
+ {
+ int cacheIndex = -1;
+
+ // if this not a search request, we'll cache the request
+ if (String.IsNullOrEmpty(searchTerm))
+ {
+ cacheIndex = allowPrereleaseVersions ? 0 : 1;
+ }
+
+ if (cacheIndex > -1 && _updatePackagesCache[cacheIndex] != null)
+ {
+ return _updatePackagesCache[cacheIndex].AsQueryable();
+ }
+
+ // We need to call ToList() here so that we don't evaluate the enumerable twice
+ IList<FrameworkName> solutionFrameworks = Provider.SupportedFrameworks.Select(s => new FrameworkName(s)).ToList();
+
+ // The allow prerelease flag passed to this method indicates if we are allowed to show prerelease packages as part of the updates
+ // and does not reflect the filtering of packages we are looking for updates to.
+ var packages = _localRepository.GetPackages();
+ if (!String.IsNullOrEmpty(searchTerm))
+ {
+ packages = packages.Find(searchTerm);
+ }
+
+ // Fix Bug #3034: When showing updates in solution-level dialog, it can happen that the local repository includes
+ // both jQuery 1.7 and jQuery 1.9 (from two different projects). To shows update for the jQuery 1.7, we need to make
+ // sure to remove jQuery 1.9 from the list.
+ // To do so, we sort all packages by increasing version, and call Distinct() which effectively remove higher versions of each package id
+ List<IPackage> packagesList = packages.ToList();
+ if (packagesList.Count > 0)
+ {
+ packagesList.Sort(PackageComparer.Version);
+ packagesList = packagesList.Distinct<IPackage>(PackageEqualityComparer.Id).ToList();
+ }
+
+ IQueryable<IPackage> updatePackages;
+
+ // If the local repository contains constraints for each package, we send the version constraints to the GetUpdates() service.
+ IPackageConstraintProvider constraintProvider = _localRepository as IPackageConstraintProvider;
+ if (constraintProvider != null)
+ {
+ IEnumerable<IVersionSpec> constraintList = packagesList.Select(p => constraintProvider.GetConstraint(p.Id));
+ updatePackages = Repository.GetUpdates(packagesList, allowPrereleaseVersions, includeAllVersions: false, targetFrameworks: solutionFrameworks, versionConstraints: constraintList)
+ .AsQueryable();
+ }
+ else
+ {
+ updatePackages = Repository.GetUpdates(packagesList, allowPrereleaseVersions, includeAllVersions: false, targetFrameworks: solutionFrameworks)
+ .AsQueryable();
+ }
+
+ if (cacheIndex > -1)
+ {
+ _updatePackagesCache[cacheIndex] = updatePackages.ToList();
+
+ // IMPORTANT: We must return this list, instead of 'updatePackages' directly to avoid additional request
+ // when the downstream code try to sort the results.
+ return _updatePackagesCache[cacheIndex].AsQueryable();
+ }
+
+ return updatePackages;
+ }
+
+ protected override IQueryable<IPackage> CollapsePackageVersions(IQueryable<IPackage> packages)
+ {
+ // GetUpdates collapses package versions to start with. Additionally, our method of using the IsLatest might not work here because
+ // we might have a package that is not the latest version but is the only compatible package that satisfies the result set.
+ return packages;
+ }
+ }
}
View
652 src/Dialog10/OnlineProviderTemplates.xaml → src/Dialog/OnlineProviderTemplates.xaml
@@ -1,327 +1,327 @@
-<ResourceDictionary
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:core="clr-namespace:NuGet;assembly=NuGet.Core"
- xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib"
- xmlns:self="clr-namespace:NuGet.Dialog.PackageManagerUI;assembly=NuGet.DialogServices"
- xmlns:resources="clr-namespace:NuGet.Dialog;assembly=NuGet.DialogServices">
-
- <ResourceDictionary.MergedDictionaries>
- <ResourceDictionary Source="TemplateStyles.xaml" />
- </ResourceDictionary.MergedDictionaries>
-
- <self:DescriptionLabelConverter x:Key="DescriptionLabelConverter" />
- <self:NormalizeTextConverter x:Key="NormalizeTextConverter" />
- <self:FixUrlConverter x:Key="urlConverter" />
- <self:BooleanToVisibilityConverter Inverted="True" x:Key="invertedBoolToVis" />
- <self:BooleanToVisibilityConverter x:Key="boolToVis" />
- <self:CountToVisibilityConverter x:Key="countConverter" />
- <self:CountToVisibilityConverter Inverted="True" x:Key="invertedCountConverter" />
- <self:ProjectToDisplayNameConverter x:Key="ProjectToNameConverter" />
- <self:MultiNullToVisibilityConverter x:Key="multiNullToVisibilityConverter" />
- <BitmapImage x:Key="BitmapImage_AlreadyInstalled" UriSource="pack://application:,,,/Microsoft.VisualStudio.ExtensionManager.Implementation;Component/UI/AlreadyInstalled.png" />
-
- <DataTemplate DataType="{x:Type core:PackageDependency}">
- <TextBlock Text="{Binding}" TextWrapping="Wrap" />
- </DataTemplate>
-
- <DataTemplate DataType="{x:Type core:PackageDependencySet}">
- <Grid Margin="0,0,0,8">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
-
- <TextBlock Text="{Binding TargetFramework, TargetNullValue={x:Static resources:Resources.NoFxDependencyGroup}}" FontWeight="SemiBold" TextWrapping="Wrap" />
- <ItemsControl
- x:Name="dependenciesList"
- Grid.Row="1"
- Margin="20,0,0,0"
- ItemsSource="{Binding Dependencies}" />
-
- <self:TextBlockControl
- Grid.Row="1"
- Margin="20,0,0,0"
- Visibility="{Binding Items.Count, ElementName=dependenciesList, Converter={StaticResource invertedCountConverter}}"
- Style="{StaticResource NoDependencyTextBoxStyle}"
- Text="{x:Static resources:Resources.Dialog_NoDependencyLabel}">
- </self:TextBlockControl>
- </Grid>
- </DataTemplate>
-
- <Style x:Key="DescriptionLabelStyle" BasedOn="{StaticResource DetailMetadataLabelStyle}" TargetType="{x:Type self:TextBlockControl}">
- <Style.Triggers>
- <DataTrigger Binding="{Binding IsUpdateItem, Mode=OneTime}" Value="true">
- <Setter Property="Text" Value="{Binding PackageIdentity.ReleaseNotes, Mode=OneTime, Converter={StaticResource DescriptionLabelConverter}}" />
- </DataTrigger>
- <DataTrigger Binding="{Binding IsUpdateItem, Mode=OneTime}" Value="false">
- <Setter Property="Text" Value="{x:Static resources:Resources.Dialog_DescriptionLabel}" />
- </DataTrigger>
- </Style.Triggers>
- </Style>
-
- <Style x:Key="TileImageStyle" TargetType="{x:Type Image}">
- <Setter Property="Height" Value="32" />
- <Setter Property="Width" Value="32" />
- <Setter Property="HorizontalAlignment" Value="Center" />
- <Setter Property="StretchDirection" Value="DownOnly" />
- <Setter Property="Stretch" Value="Fill" />
- <Style.Triggers>
- <EventTrigger RoutedEvent="ImageFailed">
- <BeginStoryboard>
- <Storyboard>
- <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Source" FillBehavior="HoldEnd">
- <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource BitmapImage_DefaultIcon}">
- </DiscreteObjectKeyFrame>
- </ObjectAnimationUsingKeyFrames>
- </Storyboard>
- </BeginStoryboard>