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

Commit 57ea6b3

Browse files
authored
Merge branch 'master' into fixes/code-cleanup
2 parents f13d5ae + 507da9f commit 57ea6b3

24 files changed

+405
-266
lines changed

appveyor.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '{build}'
2+
install:
3+
- ps: >-
4+
$full_build = Test-Path env:GHFVS_KEY
5+
6+
git submodule init
7+
8+
if ($full_build) {
9+
$fileContent = "-----BEGIN RSA PRIVATE KEY-----`n"
10+
$fileContent += $env:GHFVS_KEY.Replace(' ', "`n")
11+
$fileContent += "`n-----END RSA PRIVATE KEY-----`n"
12+
Set-Content c:\users\appveyor\.ssh\id_rsa $fileContent
13+
} else {
14+
git submodule deinit script
15+
}
16+
17+
git submodule update
18+
19+
nuget restore GitHubVS.sln
20+
build_script:
21+
- cmd: msbuild "GitHubVS.sln" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Release /p:DeployExtension=false /verbosity:minimal /p:VisualStudioVersion=14.0
22+
test_script:
23+
- ps: >-
24+
scripts\Run-Nunit.ps1 TrackingCollectionTests 180 Release
25+
26+
scripts\Run-Xunit.ps1 UnitTests 180 Release

script

scripts/Run-NUnit.ps1

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<#
2+
.SYNOPSIS
3+
Runs NUnit
4+
#>
5+
6+
[CmdletBinding()]
7+
Param(
8+
[Parameter(Mandatory=$true)]
9+
[ValidateNotNullOrEmpty()]
10+
[string]
11+
$project,
12+
[int]$timeoutDuration,
13+
[string]$configuration
14+
)
15+
16+
$rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
17+
Push-Location $rootDirectory
18+
$dll = "src\$project\bin\$configuration\$project.dll"
19+
20+
$nunitDirectory = Join-Path $rootDirectory packages\NUnit.Runners.2.6.4\tools
21+
$consoleRunner = Join-Path $nunitDirectory nunit-console-x86.exe
22+
$xml = Join-Path $rootDirectory "nunit-$project.xml"
23+
$outputPath = [System.IO.Path]::GetTempFileName()
24+
25+
$args = "-noshadow", "-xml:$xml", "-framework:net-4.5", "-exclude:Timings", $dll
26+
[object[]] $output = "$consoleRunner " + ($args -join " ")
27+
28+
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
29+
Wait-Process -InputObject $process -Timeout $timeoutDuration -ErrorAction SilentlyContinue
30+
if ($process.HasExited) {
31+
$output += Get-Content $outputPath
32+
$exitCode = $process.ExitCode
33+
} else {
34+
$output += "Tests timed out. Backtrace:"
35+
$output += Get-DotNetStack $process.Id
36+
$exitCode = 9999
37+
}
38+
39+
Stop-Process -InputObject $process
40+
Remove-Item $outputPath
41+
Pop-Location
42+
43+
$result = New-Object System.Object
44+
$result | Add-Member -Type NoteProperty -Name Output -Value $output
45+
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
46+
$result
47+

scripts/Run-XUnit.ps1

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<#
2+
.SYNOPSIS
3+
Runs xUnit
4+
#>
5+
6+
[CmdletBinding()]
7+
Param(
8+
[Parameter(Mandatory=$true)]
9+
[ValidateNotNullOrEmpty()]
10+
[string]
11+
$project,
12+
[int]$timeoutDuration,
13+
[string]$configuration
14+
)
15+
16+
$rootDirectory = Split-Path (Split-Path $MyInvocation.MyCommand.Path)
17+
Push-Location $rootDirectory
18+
19+
$dll = "src\$project\bin\$configuration\$project.dll"
20+
21+
$xunitDirectory = Join-Path $rootDirectory packages\xunit.runner.console.2.1.0\tools
22+
$consoleRunner = Join-Path $xunitDirectory xunit.console.x86.exe
23+
$xml = Join-Path $rootDirectory "nunit-$project.xml"
24+
$outputPath = [System.IO.Path]::GetTempFileName()
25+
26+
$args = $dll, "-noshadow", "-xml", $xml, "-parallel", "all"
27+
[object[]] $output = "$consoleRunner " + ($args -join " ")
28+
29+
$process = Start-Process -PassThru -NoNewWindow -RedirectStandardOutput $outputPath $consoleRunner ($args | %{ "`"$_`"" })
30+
Wait-Process -InputObject $process -Timeout $timeoutDuration -ErrorAction SilentlyContinue
31+
if ($process.HasExited) {
32+
$output += Get-Content $outputPath
33+
$exitCode = $process.ExitCode
34+
} else {
35+
$output += "Tests timed out. Backtrace:"
36+
$output += Get-DotNetStack $process.Id
37+
$exitCode = 9999
38+
}
39+
Stop-Process -InputObject $process
40+
Remove-Item $outputPath
41+
Pop-Location
42+
43+
$result = New-Object System.Object
44+
$result | Add-Member -Type NoteProperty -Name Output -Value $output
45+
$result | Add-Member -Type NoteProperty -Name ExitCode -Value $exitCode
46+
$result
47+

src/GitHub.App/Api/ApiClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public IObservable<PullRequest> GetPullRequestsForRepository(string owner, strin
232232
{
233233
return gitHubClient.PullRequest.GetAllForRepository(owner, name,
234234
new PullRequestRequest {
235-
State = ItemState.All,
235+
State = ItemStateFilter.All,
236236
SortProperty = PullRequestSort.Updated,
237237
SortDirection = SortDirection.Descending
238238
});

src/GitHub.App/Services/ModelService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ public PullRequestCacheItem(PullRequest pr)
433433
{
434434
Title = pr.Title;
435435
Number = pr.Number;
436-
CommentCount = pr.Comments;
436+
CommentCount = pr.Comments + pr.ReviewComments;
437437
Author = new AccountCacheItem(pr.User);
438438
Assignee = pr.Assignee != null ? new AccountCacheItem(pr.Assignee) : null;
439439
CreatedAt = pr.CreatedAt;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using System.Windows;
2+
using System.Windows.Controls;
3+
4+
namespace GitHub.UI
5+
{
6+
/// <summary>
7+
/// A ComboBox that displays as a link with a dropdown.
8+
/// </summary>
9+
public class LinkDropDown : ComboBox
10+
{
11+
/// <summary>
12+
/// Defines the <see cref="LinkText"/> property.
13+
/// </summary>
14+
static readonly DependencyPropertyKey LinkTextPropertyKey =
15+
DependencyProperty.RegisterReadOnly(
16+
"LinkText",
17+
typeof(string),
18+
typeof(LinkDropDown),
19+
new FrameworkPropertyMetadata(string.Empty));
20+
21+
/// <summary>
22+
/// Defines the <see cref="Header"/> property.
23+
/// </summary>
24+
public static readonly DependencyProperty HeaderProperty =
25+
HeaderedItemsControl.HeaderProperty.AddOwner(
26+
typeof(LinkDropDown),
27+
new FrameworkPropertyMetadata(typeof(LinkDropDown), HeaderChanged));
28+
29+
/// <summary>
30+
/// Defines the readonly <see cref="LinkText"/> property.
31+
/// </summary>
32+
public static readonly DependencyProperty LinkTextProperty =
33+
LinkTextPropertyKey.DependencyProperty;
34+
35+
/// <summary>
36+
/// Initializes static members of the <see cref="LinkDropDown"/> class.
37+
/// </summary>
38+
static LinkDropDown()
39+
{
40+
DefaultStyleKeyProperty.OverrideMetadata(
41+
typeof(LinkDropDown),
42+
new FrameworkPropertyMetadata(typeof(LinkDropDown)));
43+
}
44+
45+
/// <summary>
46+
/// Gets or sets a header to use as the link text when no item is selected.
47+
/// </summary>
48+
public object Header
49+
{
50+
get { return GetValue(HeaderProperty); }
51+
set { SetValue(HeaderProperty, value); }
52+
}
53+
54+
/// <summary>
55+
/// Gets the text to display in the link.
56+
/// </summary>
57+
public string LinkText
58+
{
59+
get { return (string)GetValue(LinkTextProperty); }
60+
private set { SetValue(LinkTextPropertyKey, value); }
61+
}
62+
63+
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
64+
{
65+
UpdateLinkText();
66+
}
67+
68+
private static void HeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
69+
{
70+
var source = (LinkDropDown)d;
71+
source.UpdateLinkText();
72+
}
73+
74+
private void UpdateLinkText()
75+
{
76+
if (SelectedItem != null)
77+
{
78+
var item = SelectedItem;
79+
80+
// HACK: The correct way to do this is to use a ContentPresenter in the control
81+
// template to display the link text and do a:
82+
//
83+
// ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
84+
//
85+
// to correctly display the DisplayMemberPath. However I couldn't work out how
86+
// to do it like this and get the link text looking right. This is a hack that
87+
// will work as long as DisplayMemberPath is just a property name, which is
88+
// all we need right now.
89+
if (string.IsNullOrWhiteSpace(DisplayMemberPath))
90+
{
91+
LinkText = item.ToString();
92+
}
93+
else
94+
{
95+
var property = item.GetType().GetProperty(DisplayMemberPath);
96+
LinkText = property?.GetValue(item)?.ToString();
97+
}
98+
}
99+
else
100+
{
101+
LinkText = Header.ToString();
102+
}
103+
}
104+
}
105+
}

src/GitHub.UI/Converters/CountToVisibilityConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class CountToVisibilityConverter : ValueConverterMarkupExtension<CountToV
1515
{
1616
public override object Convert(object value, Type targetType, [AllowNull] object parameter, [AllowNull] CultureInfo culture)
1717
{
18-
return ((int)value == 0) ? Visibility.Visible : Visibility.Collapsed;
18+
return ((int)value > 0) ? Visibility.Visible : Visibility.Collapsed;
1919
}
2020
}
2121
}

src/GitHub.UI/GitHub.UI.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
<ItemGroup>
8080
<Compile Include="Behaviours\ClosePopupAction.cs" />
8181
<Compile Include="Behaviours\OpenPopupAction.cs" />
82+
<Compile Include="Controls\ComboBoxes\LinkDropDown.cs" />
8283
<Compile Include="Controls\Octicons\OcticonPaths.Designer.cs">
8384
<AutoGen>True</AutoGen>
8485
<DesignTime>True</DesignTime>

src/GitHub.VisualStudio/GitHub.VisualStudio.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@
378378
<SubType>Designer</SubType>
379379
<Generator>MSBuild:Compile</Generator>
380380
</Page>
381+
<Page Include="Styles\LinkDropDown.xaml">
382+
<Generator>MSBuild:Compile</Generator>
383+
<SubType>Designer</SubType>
384+
</Page>
381385
<Page Include="Styles\Buttons.xaml">
382386
<SubType>Designer</SubType>
383387
<Generator>MSBuild:Compile</Generator>

src/GitHub.VisualStudio/SharedDictionary.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio;component/Styles/Buttons.xaml" />
1313
<cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio;component/Styles/GitHubTabControl.xaml" />
1414
<cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio;component/Styles/TextBlocks.xaml" />
15+
<cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.VisualStudio;component/Styles/LinkDropDown.xaml" />
1516
</ResourceDictionary.MergedDictionaries>
1617

1718
<Style x:Key="VSStyledButton" BasedOn="{StaticResource VsButtonStyleKey}" TargetType="{x:Type Button}" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:cache="clr-namespace:GitHub.VisualStudio.Helpers"
4+
xmlns:ui="clr-namespace:GitHub.UI;assembly=GitHub.UI">
5+
6+
<ResourceDictionary.MergedDictionaries>
7+
<cache:SharedDictionaryManager Source="pack://application:,,,/GitHub.UI;component/SharedDictionary.xaml" />
8+
</ResourceDictionary.MergedDictionaries>
9+
10+
<Style x:Key="HyperLinkToggleButton" TargetType="ToggleButton">
11+
<Setter Property="Template">
12+
<Setter.Value>
13+
<ControlTemplate TargetType="ToggleButton">
14+
<TextBlock>
15+
<TextBlock.Style>
16+
<Style TargetType="TextBlock">
17+
<Style.Triggers>
18+
<MultiDataTrigger>
19+
<MultiDataTrigger.Conditions>
20+
<Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
21+
<Condition Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}}" Value="true" />
22+
<Condition Binding="{Binding Path=IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Value="false" />
23+
</MultiDataTrigger.Conditions>
24+
<MultiDataTrigger.Setters>
25+
<Setter Property="TextDecorations" Value="Underline" />
26+
<Setter Property="FrameworkElement.Cursor" Value="Hand" />
27+
</MultiDataTrigger.Setters>
28+
</MultiDataTrigger>
29+
<DataTrigger Binding="{Binding Path=IsPressed, RelativeSource={RelativeSource TemplatedParent}}" Value="true">
30+
<Setter Property="TextDecorations" Value="Underline" />
31+
<Setter Property="FrameworkElement.Cursor" Value="Hand" />
32+
</DataTrigger>
33+
</Style.Triggers>
34+
<Setter Property="Cursor" Value="Hand" />
35+
</Style>
36+
</TextBlock.Style>
37+
<Run Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />
38+
<Polygon Margin="2,0,0,1"
39+
Fill="{TemplateBinding Foreground}"
40+
Points="0,0 8,0 4,4 0,0"/>
41+
</TextBlock>
42+
</ControlTemplate>
43+
</Setter.Value>
44+
</Setter>
45+
</Style>
46+
47+
<Style TargetType="{x:Type ui:LinkDropDown}">
48+
<Setter Property="Foreground" Value="{DynamicResource GitHubActionLinkItemBrush}"/>
49+
<Setter Property="Template">
50+
<Setter.Value>
51+
<ControlTemplate TargetType="ui:LinkDropDown">
52+
<Grid>
53+
<ToggleButton Style="{StaticResource HyperLinkToggleButton}"
54+
Content="{TemplateBinding LinkText}"
55+
Foreground="{TemplateBinding Foreground}"
56+
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
57+
IsTabStop="False"/>
58+
<Popup Name="PART_Popup"
59+
AllowsTransparency="True"
60+
IsOpen="{TemplateBinding IsDropDownOpen}"
61+
Placement="Bottom">
62+
<Popup.Resources>
63+
<Style BasedOn="{StaticResource {x:Type ComboBoxItem}}" TargetType="{x:Type ComboBoxItem}">
64+
<Setter Property="Foreground" Value="{DynamicResource GitHubButtonForegroundBrush}" />
65+
<Setter Property="Padding" Value="3" />
66+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
67+
</Style>
68+
</Popup.Resources>
69+
<Border Style="{DynamicResource GitHubComboBoxBorder}">
70+
<DockPanel Style="{DynamicResource GitHubComboBoxDockPanelContainer}"
71+
MinWidth="100">
72+
<ScrollViewer VerticalScrollBarVisibility="Auto">
73+
<ItemsPresenter/>
74+
</ScrollViewer>
75+
</DockPanel>
76+
</Border>
77+
</Popup>
78+
</Grid>
79+
</ControlTemplate>
80+
</Setter.Value>
81+
</Setter>
82+
</Style>
83+
84+
</ResourceDictionary>

0 commit comments

Comments
 (0)