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

Commit 0fb23b8

Browse files
author
Jasmine
committed
Merge branch 'master' into paladique/build-script-cleanup
2 parents 957092b + 5c1ba78 commit 0fb23b8

26 files changed

+1030
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,4 @@ WiX.Toolset.DummyFile.txt
238238
nunit-UnitTests.xml
239239
nunit-TrackingCollectionTests.xml
240240
GitHubVS.sln.DotSettings
241+
**/generated/*.cs

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Most of the extension UI lives in the Team Explorer pane, which is available fro
55

66
Official builds of this extension are available at [the official website](https://visualstudio.github.com).
77

8-
[![Join the chat at https://gitter.im/github/VisualStudio](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github/VisualStudio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
8+
[![Join the chat at freenode:github-vs](https://img.shields.io/badge/irc-freenode:%20%23github--vs-blue.svg)](http://webchat.freenode.net/?channels=%23github-vs) [![Join the chat at https://gitter.im/github/VisualStudio](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/github/VisualStudio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
99

1010
## Installing beta versions
1111

55.3 KB
Binary file not shown.

lib/Microsoft.TextTemplating.targets

Lines changed: 535 additions & 0 deletions
Large diffs are not rendered by default.
52.3 KB
Binary file not shown.

src/GitHub.Exports/GitHub.Exports.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@
9595
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
9696
<Link>Key.snk</Link>
9797
</None>
98+
<None Include="..\common\settings.json">
99+
<Link>Properties\settings.json</Link>
100+
</None>
98101
<Compile Include="Collections\ICopyable.cs" />
99102
<Compile Include="ExceptionExtensions.cs" />
100103
<Compile Include="Extensions\VSExtensions.cs" />
101104
<Compile Include="GlobalSuppressions.cs" />
102105
<Compile Include="Helpers\INotifyPropertySource.cs" />
103106
<Compile Include="Extensions\PropertyNotifierExtensions.cs" />
104107
<Compile Include="Extensions\SimpleRepositoryModelExtensions.cs" />
108+
<Compile Include="Helpers\SettingsStore.cs" />
105109
<Compile Include="Info\ApplicationInfo.cs" />
106110
<Compile Include="Models\IAccount.cs" />
107111
<Compile Include="Models\IConnectionManager.cs" />
@@ -134,6 +138,11 @@
134138
<ItemGroup>
135139
<Compile Include="Authentication\AuthenticationResultExtensions.cs" />
136140
<Compile Include="Extensions\ServiceProviderExtensions.cs" />
141+
<Compile Include="Settings\generated\IPackageSettings.cs">
142+
<AutoGen>True</AutoGen>
143+
<DesignTime>True</DesignTime>
144+
<DependentUpon>IPackageSettings.tt</DependentUpon>
145+
</Compile>
137146
<Compile Include="ViewModels\IServiceProviderAware.cs" />
138147
<Compile Include="UI\IView.cs" />
139148
<Compile Include="UI\Octicon.cs" />
@@ -178,7 +187,18 @@
178187
<Private>True</Private>
179188
</ProjectReference>
180189
</ItemGroup>
190+
<ItemGroup>
191+
<Content Include="Settings\generated\IPackageSettings.tt">
192+
<Generator>TextTemplatingFileGenerator</Generator>
193+
<LastGenOutput>IPackageSettings.cs</LastGenOutput>
194+
</Content>
195+
</ItemGroup>
196+
<ItemGroup>
197+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
198+
</ItemGroup>
181199
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
200+
<Import Project="$(SolutionDir)\src\common\t4.targets" />
201+
<Import Project="$(SolutionDir)\lib\Microsoft.TextTemplating.targets" />
182202
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
183203
Other similar extension points exist, see Microsoft.Common.targets.
184204
<Target Name="BeforeBuild">
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System.IO;
2+
using Microsoft.VisualStudio.Settings;
3+
using GitHub.Extensions;
4+
5+
namespace GitHub.Helpers
6+
{
7+
public class SettingsStore
8+
{
9+
readonly WritableSettingsStore store;
10+
readonly string root;
11+
public SettingsStore(WritableSettingsStore store, string root)
12+
{
13+
Guard.ArgumentNotNull(store, nameof(store));
14+
Guard.ArgumentNotNull(root, nameof(root));
15+
Guard.ArgumentNotEmptyString(root, nameof(root));
16+
this.store = store;
17+
this.root = root;
18+
}
19+
20+
public object Read(string property, object defaultValue)
21+
{
22+
return Read(null, property, defaultValue);
23+
}
24+
25+
/// <summary>
26+
/// Read from a settings store
27+
/// </summary>
28+
/// <typeparam name="T"></typeparam>
29+
/// <param name="subpath">The subcollection path (appended to the path passed to the constructor)</param>
30+
/// <param name="property">The property name to read</param>
31+
/// <param name="defaultValue">The default value to use in case the property doesn't exist.
32+
/// The type of the default value will be used to figure out the proper way to read the property, so if pass null,
33+
/// the property will be read as a string (which may or may not be what you want)</param>
34+
/// <returns></returns>
35+
public object Read(string subpath, string property, object defaultValue)
36+
{
37+
Guard.ArgumentNotNull(property, nameof(property));
38+
Guard.ArgumentNotEmptyString(property, nameof(property));
39+
40+
var collection = subpath != null ? Path.Combine(root, subpath) : root;
41+
store.CreateCollection(collection);
42+
43+
if (defaultValue is bool)
44+
return store.GetBoolean(collection, property, (bool)defaultValue);
45+
else if (defaultValue is int)
46+
return store.GetInt32(collection, property, (int)defaultValue);
47+
else if (defaultValue is uint)
48+
return store.GetUInt32(collection, property, (uint)defaultValue);
49+
else if (defaultValue is long)
50+
return store.GetInt64(collection, property, (long)defaultValue);
51+
else if (defaultValue is ulong)
52+
return store.GetUInt64(collection, property, (ulong)defaultValue);
53+
return store.GetString(collection, property, defaultValue?.ToString() ?? "");
54+
}
55+
56+
public void Write(string property, object value)
57+
{
58+
Write(null, property, value);
59+
}
60+
61+
public void Write(string subpath, string property, object value)
62+
{
63+
Guard.ArgumentNotNull(property, nameof(property));
64+
Guard.ArgumentNotEmptyString(property, nameof(property));
65+
66+
var collection = subpath != null ? Path.Combine(root, subpath) : root;
67+
store.CreateCollection(collection);
68+
69+
if (value is bool)
70+
store.SetBoolean(collection, property, (bool)value);
71+
else if (value is int)
72+
store.SetInt32(collection, property, (int)value);
73+
else if (value is uint)
74+
store.SetUInt32(collection, property, (uint)value);
75+
else if (value is long)
76+
store.SetInt64(collection, property, (long)value);
77+
else if (value is ulong)
78+
store.SetUInt64(collection, property, (ulong)value);
79+
else
80+
store.SetString(collection, property, value?.ToString() ?? "");
81+
}
82+
}
83+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<#@ template debug="false" hostspecific="true" language="C#" #>
2+
<#@ assembly name="System.Core" #>
3+
<#@ import namespace="System.Linq" #>
4+
<#@ import namespace="System.Text" #>
5+
<#@ import namespace="System.Collections.Generic" #>
6+
<#@ import namespace="System.IO" #>
7+
<#@ assembly name="$(PackageDir)\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll" #>
8+
<#@ import namespace="Newtonsoft.Json.Linq" #>
9+
<#@ output extension=".cs" #>
10+
<#
11+
var file = this.Host.ResolvePath(@"..\..\..\common\settings.json");
12+
var json = JObject.Parse(File.ReadAllText(file));
13+
#>
14+
// This is an automatically generated file, based on settings.json and PackageSettingsGen.tt
15+
/* settings.json content:
16+
<#@ include file="..\..\..\common\settings.json" #>
17+
*/
18+
namespace GitHub.Settings
19+
{
20+
public interface IPackageSettings
21+
{
22+
void Save();
23+
<#
24+
foreach (var j in json["settings"].Children()) {
25+
#>
26+
<#= j["type"] #> <#= j["name"] #> { get; set; }
27+
<#
28+
}
29+
#>
30+
}
31+
}

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</NuGetPackageImportStamp>
99
<TargetFrameworkProfile />
1010
<BuildType Condition="Exists('..\..\script\ApiClientConfiguration.cs')">Internal</BuildType>
11-
<ApplicationVersion>1.0.17.0</ApplicationVersion>
11+
<ApplicationVersion>1.0.17.1</ApplicationVersion>
1212
<OutputPath>..\..\build\$(Configuration)\</OutputPath>
1313
</PropertyGroup>
1414
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
@@ -241,12 +241,21 @@
241241
<Compile Include="Base\TeamExplorerNavigationItemBase.cs" />
242242
<Compile Include="Base\TeamExplorerSectionBase.cs" />
243243
<Compile Include="Helpers\Browser.cs" />
244-
<Compile Include="Helpers\Colors.cs" />
245-
<Compile Include="Helpers\Constants.cs" />
244+
<Compile Include="Settings\Colors.cs" />
245+
<Compile Include="Settings\Constants.cs" />
246246
<Compile Include="Services\ConnectionManager.cs" />
247+
<Compile Include="Settings\OptionsPage.cs">
248+
<SubType>Component</SubType>
249+
</Compile>
247250
<Compile Include="Services\Program.cs" />
248251
<Compile Include="Services\SharedResources.cs" />
249-
<Compile Include="Settings.cs" />
252+
<Compile Include="Settings\PackageSettings.cs" />
253+
<Compile Include="Settings\generated\PackageSettings.cs">
254+
<AutoGen>True</AutoGen>
255+
<DesignTime>True</DesignTime>
256+
<DependentUpon>PackageSettings.tt</DependentUpon>
257+
</Compile>
258+
<Compile Include="Settings\Settings.cs" />
250259
<Compile Include="Base\PackageBase.cs" />
251260
<Compile Include="Resources.Designer.cs">
252261
<AutoGen>True</AutoGen>
@@ -273,6 +282,9 @@
273282
<Compile Include="Base\EnsureLoggedInSection.cs" />
274283
<Compile Include="UI\DrawingExtensions.cs" />
275284
<Compile Include="UI\GitHubPane.cs" />
285+
<Compile Include="UI\Settings\OptionsControl.xaml.cs">
286+
<DependentUpon>OptionsControl.xaml</DependentUpon>
287+
</Compile>
276288
<Compile Include="UI\Views\Controls\RepositoryCloneControl.xaml.cs">
277289
<DependentUpon>RepositoryCloneControl.xaml</DependentUpon>
278290
</Compile>
@@ -333,9 +345,16 @@
333345
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
334346
<IncludeInVSIX>true</IncludeInVSIX>
335347
</Content>
348+
<Content Include="Settings\generated\PackageSettings.tt">
349+
<Generator>TextTemplatingFileGenerator</Generator>
350+
<CustomToolNamespace>GitHub.VisualStudio.Settings</CustomToolNamespace>
351+
</Content>
336352
<None Include="packages.config">
337353
<SubType>Designer</SubType>
338354
</None>
355+
<None Include="..\common\settings.json">
356+
<Link>Properties\settings.json</Link>
357+
</None>
339358
<None Include="source.extension.vsixmanifest">
340359
<SubType>Designer</SubType>
341360
</None>
@@ -410,6 +429,11 @@
410429
<Generator>MSBuild:Compile</Generator>
411430
<SubType>Designer</SubType>
412431
</Page>
432+
<Page Include="UI\Settings\OptionsControl.xaml">
433+
<SubType>Designer</SubType>
434+
<Generator>MSBuild:Compile</Generator>
435+
<CustomToolNamespace>GitHub.VisualStudio.UI</CustomToolNamespace>
436+
</Page>
413437
<Page Include="UI\Views\Controls\ActionLinkButton.xaml">
414438
<SubType>Designer</SubType>
415439
<Generator>MSBuild:Compile</Generator>
@@ -578,12 +602,18 @@
578602
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup;</IncludeOutputGroupsInVSIXLocalOnly>
579603
</ProjectReference>
580604
</ItemGroup>
605+
<ItemGroup>
606+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
607+
</ItemGroup>
581608
<PropertyGroup>
582609
<UseCodebase>true</UseCodebase>
583610
</PropertyGroup>
584611
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
585612
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
586613
<Import Project="packaging.targets" />
614+
<!-- For regenerating templates on build -->
615+
<Import Project="$(SolutionDir)\src\common\t4.targets" />
616+
<Import Project="$(SolutionDir)\lib\Microsoft.TextTemplating.targets" />
587617
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
588618
<PropertyGroup>
589619
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace GitHub.VisualStudio
3535
//[ProvideAutoLoad(UIContextGuids.NoSolution)]
3636
[ProvideAutoLoad("11B8E6D7-C08B-4385-B321-321078CDD1F8")]
3737
[ProvideToolWindow(typeof(GitHubPane), Orientation = ToolWindowOrientation.Right, Style = VsDockStyle.Tabbed, Window = EnvDTE.Constants.vsWindowKindSolutionExplorer)]
38+
[ProvideOptionPage(typeof(OptionsPage), "GitHub for Visual Studio", "General", 0, 0, supportsAutomation: true)]
3839
public class GitHubPackage : PackageBase
3940
{
4041
public GitHubPackage()

0 commit comments

Comments
 (0)