Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit d8cdbd7

Browse files
authored
Merge pull request #520 from github/features/start-page
Add a loader for external packages
2 parents 4eb8565 + d8a80cc commit d8cdbd7

File tree

14 files changed

+149
-30
lines changed

14 files changed

+149
-30
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "script"]
1717
path = script
1818
url = [email protected]:github/VisualStudioBuildScripts
19+
[submodule "submodules/externalpackages/StartPage"]
20+
path = submodules/externalpackages/StartPage
21+
url = [email protected]:editor-tools/StartPage.git

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ install:
1212
Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
1313
} else {
1414
git submodule deinit script
15+
git submodule deinit submodules/externalpackages/StartPage
1516
}
1617
1718
git submodule update

src/GitHub.App/ViewModels/RepositoryCloneViewModel.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System.Collections.ObjectModel;
2323
using GitHub.Collections;
2424
using GitHub.UI;
25+
using GitHub.Extensions.Reactive;
2526

2627
namespace GitHub.ViewModels
2728
{
@@ -152,12 +153,16 @@ IObservable<Unit> OnCloneRepository(object state)
152153
notificationService.ShowError(Resources.RepositoryCloneFailedNoSelectedRepo);
153154
return Observable.Return(Unit.Default);
154155
}
155-
156+
156157
// The following is a noop if the directory already exists.
157158
operatingSystem.Directory.CreateDirectory(BaseRepositoryPath);
158159

159160
return cloneService.CloneRepository(repository.CloneUrl, repository.Name, BaseRepositoryPath)
160-
.Do(_ => this.usageTracker.IncrementCloneCount());
161+
.ContinueAfter(() =>
162+
{
163+
usageTracker.IncrementCloneCount();
164+
return Observable.Return(Unit.Default);
165+
});
161166
})
162167
.SelectMany(_ => _)
163168
.Catch<Unit, Exception>(e =>

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
<DependentUpon>IPackageSettings.tt</DependentUpon>
154154
</Compile>
155155
<Compile Include="Settings\GitHubConnectSectionState.cs" />
156+
<Compile Include="Settings\Guids.cs" />
156157
<Compile Include="Settings\PullRequestListUIState.cs" />
157158
<Compile Include="Settings\RepositoryUIState.cs" />
158159
<Compile Include="Settings\UIState.cs" />

src/GitHub.Exports/Helpers/AssemblyResolver.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
using System.Reflection;
88
using System.Text;
99
using System.Threading.Tasks;
10+
using Microsoft.VisualStudio.Shell;
11+
using System.Diagnostics;
12+
using GitHub.Collections;
1013

1114
namespace GitHub.Helpers
1215
{
@@ -47,13 +50,15 @@ static Assembly LoadAssemblyFromRunDir(object sender, ResolveEventArgs e)
4750
{
4851
try
4952
{
50-
var name = new AssemblyName(e.Name);
51-
if (!ourAssemblies.Contains(name.Name))
53+
var requestedName = e.Name.TrimSuffix(".dll", StringComparison.OrdinalIgnoreCase);
54+
var name = new AssemblyName(requestedName).Name;
55+
if (!ourAssemblies.Contains(name, StringComparer.OrdinalIgnoreCase))
5256
return null;
5357
var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
54-
var filename = Path.Combine(path, name.Name + ".dll");
58+
var filename = Path.Combine(path, name + ".dll");
5559
if (!File.Exists(filename))
5660
return null;
61+
5762
return Assembly.LoadFrom(filename);
5863
}
5964
catch (Exception ex)

src/GitHub.Exports/Services/IUIProvider.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
using GitHub.Models;
44
using GitHub.UI;
55
using System.Windows.Controls;
6+
using System.Runtime.InteropServices;
67

78
namespace GitHub.Services
89
{
10+
[Guid("76909E1A-9D58-41AB-8957-C26B9550787B")]
911
public interface IUIProvider : IServiceProvider
1012
{
1113
ExportProvider ExportProvider { get; }

src/GitHub.Exports/Settings/Guids.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace GitHub.VisualStudio
4+
{
5+
public static class Guids
6+
{
7+
public const string PackageId = "c3d3dc68-c977-411f-b3e8-03b0dccf7dfc";
8+
public const string ImagesId = "27841f47-070a-46d6-90be-a5cbbfc724ac";
9+
}
10+
}

src/GitHub.Extensions/LambdaComparer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public class LambdaComparer<T> : IEqualityComparer<T>, IComparer<T>
1010
readonly Func<T, int> lambdaHash;
1111

1212
public LambdaComparer(Func<T, T, int> lambdaComparer) :
13-
this(lambdaComparer, o => 0)
13+
this(lambdaComparer, null)
1414
{
1515
}
1616

17-
LambdaComparer(Func<T, T, int> lambdaComparer, Func<T, int> lambdaHash)
17+
public LambdaComparer(Func<T, T, int> lambdaComparer, [AllowNull] Func<T, int> lambdaHash)
1818
{
1919
this.lambdaComparer = lambdaComparer;
2020
this.lambdaHash = lambdaHash;
@@ -32,7 +32,9 @@ public bool Equals([AllowNull] T x, [AllowNull] T y)
3232

3333
public int GetHashCode([AllowNull] T obj)
3434
{
35-
return lambdaHash(obj);
35+
return lambdaHash != null
36+
? lambdaHash(obj)
37+
: obj?.GetHashCode() ?? 0;
3638
}
3739
}
3840
}

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,26 @@
107107
<Reference Include="Microsoft.CSharp" />
108108
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
109109
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
110+
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
111+
<HintPath>..\..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll</HintPath>
112+
<Private>True</Private>
113+
</Reference>
110114
<Reference Include="Microsoft.VisualStudio.Shell.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
115+
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
116+
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll</HintPath>
117+
<Private>True</Private>
118+
</Reference>
119+
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.14.0, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
120+
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll</HintPath>
121+
<Private>True</Private>
122+
</Reference>
123+
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124+
<HintPath>..\..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll</HintPath>
125+
<Private>True</Private>
126+
</Reference>
111127
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
112128
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
113129
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
114-
<Reference Include="Microsoft.VisualStudio.OLE.Interop" />
115-
<Reference Include="Microsoft.VisualStudio.Shell.Interop" />
116130
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />
117131
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />
118132
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0" />
@@ -123,10 +137,12 @@
123137
<EmbedInteropTypes>true</EmbedInteropTypes>
124138
</Reference>
125139
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
126-
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
127140
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
128-
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />
129141
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0" />
142+
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
143+
<HintPath>..\..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll</HintPath>
144+
<Private>True</Private>
145+
</Reference>
130146
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
131147
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
132148
<Private>True</Private>
@@ -234,7 +250,7 @@
234250
<SubType>Component</SubType>
235251
</Compile>
236252
<Compile Include="Settings\PackageSettings.cs" />
237-
<Compile Include="Settings\Settings.cs" />
253+
<Compile Include="Settings\Guids.cs" />
238254
<Compile Include="GlobalSuppressions.cs" />
239255
<Compile Include="GitHubPackage.cs" />
240256
<Compile Include="PkgCmdID.cs" />
@@ -547,14 +563,14 @@
547563
<Project>{161dbf01-1dbf-4b00-8551-c5c00f26720d}</Project>
548564
<Name>GitHub.TeamFoundation.14</Name>
549565
<Private>False</Private>
550-
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems%3bDebugSymbolsProjectOutputGroup%3bBuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
566+
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIX>
551567
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
552568
</ProjectReference>
553569
<ProjectReference Include="..\GitHub.TeamFoundation.15\GitHub.TeamFoundation.15.csproj">
554570
<Project>{161dbf01-1dbf-4b00-8551-c5c00f26720e}</Project>
555571
<Name>GitHub.TeamFoundation.15</Name>
556572
<Private>False</Private>
557-
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup%3bGetCopyToOutputDirectoryItems%3bDebugSymbolsProjectOutputGroup%3bBuiltProjectOutputGroup%3bBuiltProjectOutputGroupDependencies%3bGetCopyToOutputDirectoryItems%3bSatelliteDllsProjectOutputGroup%3b</IncludeOutputGroupsInVSIX>
573+
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems;DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIX>
558574
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
559575
</ProjectReference>
560576
<ProjectReference Include="..\GitHub.UI.Reactive\GitHub.UI.Reactive.csproj">
@@ -589,6 +605,23 @@
589605
<ItemGroup>
590606
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
591607
</ItemGroup>
608+
<ItemGroup Condition="$(Buildtype) == 'Internal'">
609+
<Content Include="..\..\submodules\externalpackages\StartPage\build\GitHub.StartPage.pkgdef">
610+
<Link>GitHub.StartPage.pkgdef</Link>
611+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
612+
<IncludeInVSIX>true</IncludeInVSIX>
613+
</Content>
614+
<Content Include="..\..\submodules\externalpackages\StartPage\build\GitHub.StartPage.dll">
615+
<Link>GitHub.StartPage.dll</Link>
616+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
617+
<IncludeInVSIX>true</IncludeInVSIX>
618+
</Content>
619+
<Content Include="..\..\submodules\externalpackages\StartPage\build\GitHub.StartPage.pdb">
620+
<Link>GitHub.StartPage.pdb</Link>
621+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
622+
<IncludeInVSIX>true</IncludeInVSIX>
623+
</Content>
624+
</ItemGroup>
592625
<PropertyGroup>
593626
<UseCodebase>true</UseCodebase>
594627
</PropertyGroup>

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
using System;
22
using System.ComponentModel.Composition;
3-
using System.Diagnostics;
4-
using System.Globalization;
5-
using System.IO;
6-
using System.Linq;
7-
using System.Reflection;
83
using System.Runtime.InteropServices;
94
using GitHub.Extensions;
105
using GitHub.Models;
11-
using GitHub.Primitives;
126
using GitHub.Services;
13-
using GitHub.UI;
14-
using GitHub.VisualStudio.Base;
157
using GitHub.VisualStudio.UI;
168
using Microsoft.VisualStudio;
179
using Microsoft.VisualStudio.Shell;
1810
using Microsoft.VisualStudio.Shell.Interop;
1911
using Octokit;
2012
using GitHub.Helpers;
13+
using System.ComponentModel.Design;
14+
using System.Diagnostics;
15+
using System.Threading;
16+
using tasks = System.Threading.Tasks;
2117

2218
namespace GitHub.VisualStudio
2319
{
2420
[PackageRegistration(UseManagedResourcesOnly = true)]
2521
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
2622
[Guid(GuidList.guidGitHubPkgString)]
27-
//[ProvideBindingPath]
2823
[ProvideMenuResource("Menus.ctmenu", 1)]
29-
//[ProvideAutoLoad(UIContextGuids.NoSolution)]
3024
// this is the Git service GUID, so we load whenever it loads
3125
[ProvideAutoLoad("11B8E6D7-C08B-4385-B321-321078CDD1F8")]
3226
[ProvideToolWindow(typeof(GitHubPane), Orientation = ToolWindowOrientation.Right, Style = VsDockStyle.Tabbed, Window = EnvDTE.Constants.vsWindowKindSolutionExplorer)]
@@ -80,4 +74,63 @@ public GHClient(IProgram program)
8074
{
8175
}
8276
}
77+
78+
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
79+
[ProvideService(typeof(IUIProvider), IsAsyncQueryable = true)]
80+
[ProvideAutoLoad(UIContextGuids.NoSolution)]
81+
[ProvideAutoLoad(UIContextGuids.SolutionExists)]
82+
[Guid(ServiceProviderPackageId)]
83+
public sealed class ServiceProviderPackage : AsyncPackage
84+
{
85+
const string ServiceProviderPackageId = "D5CE1488-DEDE-426D-9E5B-BFCCFBE33E53";
86+
const string StartPagePreview4PackageId = "3b764d23-faf7-486f-94c7-b3accc44a70d";
87+
88+
Version vsversion;
89+
Version VSVersion
90+
{
91+
get
92+
{
93+
if (vsversion == null)
94+
{
95+
var asm = typeof(ITaskList).Assembly;
96+
try
97+
{
98+
// this will return Microsoft.VisualStudio.Shell.Immutable.14.0 in VS15
99+
// but Microsoft.VisualStudio.Shell.Framework in Dev15
100+
var vinfo = FileVersionInfo.GetVersionInfo(asm.Location);
101+
vsversion = new Version(vinfo.FileMajorPart, vinfo.FileMinorPart, vinfo.FileBuildPart, vinfo.FilePrivatePart);
102+
}
103+
catch
104+
{
105+
// something wrong, fallback to assembly version
106+
vsversion = asm.GetName().Version;
107+
}
108+
}
109+
return vsversion;
110+
}
111+
}
112+
113+
protected override async tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
114+
{
115+
AddService(typeof(IUIProvider), CreateService, true);
116+
117+
// Load the start page package only for Dev15 Preview 4
118+
if (VSVersion.Major == 15 && VSVersion.Build == 25618)
119+
{
120+
var shell = await GetServiceAsync(typeof(SVsShell)) as IVsShell;
121+
IVsPackage startPagePackage;
122+
if (ErrorHandler.Failed(shell?.LoadPackage(new Guid(StartPagePreview4PackageId), out startPagePackage) ?? -1))
123+
{
124+
// ¯\_(ツ)_/¯
125+
}
126+
}
127+
}
128+
129+
tasks.Task<object> CreateService(IAsyncServiceContainer container, CancellationToken cancellationToken, Type serviceType)
130+
{
131+
AssemblyResolver.InitializeAssemblyResolver();
132+
var ret = Services.ComponentModel.DefaultExportProvider.GetExportedValueOrDefault<IUIProvider>();
133+
return tasks.Task.FromResult((object)ret);
134+
}
135+
}
83136
}
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// Guids.cs
2-
// MUST match guids.h
3-
using System;
4-
using System.Diagnostics;
1+
using System;
52

63
namespace GitHub.VisualStudio
74
{
@@ -11,10 +8,10 @@ static class GuidList
118
public const string guidGitHubCmdSetString = "c4c91892-8881-4588-a5d9-b41e8f540f5a";
129
public const string guidGitHubToolbarCmdSetString = "C5F1193E-F300-41B3-B4C4-5A703DD3C1C6";
1310
public const string guidContextMenuSetString = "31057D08-8C3C-4C5B-9F91-8682EA08EC27";
11+
public const string guidImageMoniker = "27841f47-070a-46d6-90be-a5cbbfc724ac";
1412

1513
public static readonly Guid guidGitHubCmdSet = new Guid(guidGitHubCmdSetString);
1614
public static readonly Guid guidGitHubToolbarCmdSet = new Guid(guidGitHubToolbarCmdSetString);
17-
1815
public static readonly Guid guidContextMenuSet = new Guid(guidContextMenuSetString);
1916
}
2017
}

src/GitHub.VisualStudio/packages.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<package id="Fody" version="1.28.0" targetFramework="net45" developmentDependency="true" />
55
<package id="LibGit2Sharp" version="0.22.0" targetFramework="net461" />
66
<package id="LibGit2Sharp.NativeBinaries" version="1.0.129" targetFramework="net461" />
7+
<package id="Microsoft.VisualStudio.OLE.Interop" version="7.10.6070" targetFramework="net461" />
8+
<package id="Microsoft.VisualStudio.Shell.Immutable.11.0" version="11.0.50727" targetFramework="net461" />
9+
<package id="Microsoft.VisualStudio.Shell.Immutable.14.0" version="14.3.25407" targetFramework="net461" />
10+
<package id="Microsoft.VisualStudio.Shell.Interop" version="7.10.6071" targetFramework="net461" />
11+
<package id="Microsoft.VisualStudio.TextManager.Interop" version="7.10.6070" targetFramework="net461" />
712
<package id="Microsoft.VSSDK.Vsixsigntool" version="14.1.24720" targetFramework="net45" />
813
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
914
<package id="NLog" version="3.1.0" targetFramework="net45" />

src/GitHub.VisualStudio/source.extension.vsixmanifest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@
2828
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="GitHub.App" Path="|GitHub.App|" />
2929
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="GitHub.TeamFoundation.14" Path="|GitHub.TeamFoundation.14|" />
3030
<Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="GitHub.TeamFoundation.15" Path="|GitHub.TeamFoundation.15|" />
31+
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="File" Path="GitHub.StartPage.pkgdef" />
3132
</Assets>
3233
</PackageManifest>

submodules/externalpackages/StartPage

Submodule StartPage added at 0115855

0 commit comments

Comments
 (0)