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

Commit fb7fd99

Browse files
Merge branch 'features/check-suite-annotations-inline' into donokuda/check-suite-polish
# Conflicts: # src/GitHub.VisualStudio.UI/Views/CommentView.xaml
2 parents d2b1532 + b829ea7 commit fb7fd99

37 files changed

+341
-257
lines changed

.editorconfig

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,73 @@
11
# top-most EditorConfig file
22
root = true
33

4-
[*.cs]
4+
[*.{cs,vb}]
5+
56
indent_style = space
6-
indent_size = 4
7+
indent_size = 4
8+
9+
# Organize usings
10+
dotnet_sort_system_directives_first = true
11+
12+
# this. preferences
13+
dotnet_style_qualification_for_field = false:silent
14+
dotnet_style_qualification_for_property = false:silent
15+
dotnet_style_qualification_for_method = false:silent
16+
dotnet_style_qualification_for_event = false:silent
17+
18+
# Language keywords vs BCL types preferences
19+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
20+
dotnet_style_predefined_type_for_member_access = true:suggestion
21+
22+
# Parentheses preferences
23+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
24+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
25+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
26+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
27+
28+
# Modifier preferences
29+
dotnet_style_require_accessibility_modifiers = never:silent
30+
dotnet_style_readonly_field = true:suggestion
31+
32+
# Expression-level preferences
33+
dotnet_style_object_initializer = true:suggestion
34+
dotnet_style_collection_initializer = true:suggestion
35+
dotnet_style_explicit_tuple_names = true:suggestion
36+
dotnet_style_null_propagation = true:suggestion
37+
dotnet_style_coalesce_expression = true:suggestion
38+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
39+
dotnet_style_prefer_auto_properties = true:silent
40+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
41+
dotnet_style_prefer_conditional_expression_over_return = true:silent
42+
43+
[*.cs]
44+
45+
# var preferences
46+
csharp_style_var_for_built_in_types = true:suggestion
47+
csharp_style_var_when_type_is_apparent = true:suggestion
48+
csharp_style_var_elsewhere = true:suggestion
49+
50+
# Expression-bodied members
51+
csharp_style_expression_bodied_methods = false:none
52+
csharp_style_expression_bodied_constructors = false:none
53+
csharp_style_expression_bodied_operators = false:none
54+
csharp_style_expression_bodied_properties = false:none
55+
csharp_style_expression_bodied_indexers = false:none
56+
csharp_style_expression_bodied_accessors = false:none
57+
58+
# Pattern matching preferences
59+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
60+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
61+
62+
# Null-checking preferences
63+
csharp_style_throw_expression = true:suggestion
64+
csharp_style_conditional_delegate_call = true:suggestion
65+
66+
# Expression-level preferences
67+
csharp_prefer_braces = true:suggestion
68+
csharp_style_deconstructed_variable_declaration = true:suggestion
69+
csharp_prefer_simple_default_expression = true:suggestion
70+
csharp_style_inlined_variable_declaration = true:suggestion
71+
72+
# Spacing options
73+
csharp_space_after_keywords_in_control_flow_statements = true

Directory.Build.Props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<Product>GitHub Extension for Visual Studio</Product>
4-
<Version>2.5.9.0</Version>
4+
<Version>2.6.0.0</Version>
55
<Copyright>Copyright © GitHub, Inc. 2014-2018</Copyright>
66
<LangVersion>7.3</LangVersion>
77
</PropertyGroup>
8-
</Project>
8+
</Project>

GitHubVS.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.VisualStudio", "src\
1010
EndProject
1111
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Meta", "Meta", "{72036B62-2FA6-4A22-8B33-69F698A18CF1}"
1212
ProjectSection(SolutionItems) = preProject
13+
.editorconfig = .editorconfig
1314
README.md = README.md
1415
EndProjectSection
1516
EndProject

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
os: Visual Studio 2017
2-
version: '2.5.9.{build}'
2+
version: '2.6.0.{build}'
33
skip_tags: true
44
install:
55
- ps: |
1006 Bytes
Binary file not shown.

src/GitHub.App/SampleData/InlineAnnotationViewModelDesigner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public InlineAnnotationViewModelDesigner()
3535
Model= new InlineAnnotationModel(checkSuiteModel, checkRunModel, checkRunAnnotationModel);
3636
}
3737

38-
public IInlineAnnotationModel Model { get; }
38+
public InlineAnnotationModel Model { get; }
3939
}
4040
}

src/GitHub.App/SampleData/PullRequestAnnotationsViewModelDesigner.cs

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,72 @@ public sealed class PullRequestAnnotationsViewModelDesigner : PanePageViewModelB
1616
public ILocalRepositoryModel LocalRepository { get; set; }
1717
public string RemoteRepositoryOwner { get; set; }
1818
public int PullRequestNumber { get; set; } = 123;
19-
public int CheckRunId { get; set; }
19+
public string CheckRunId { get; set; }
2020
public ReactiveCommand<Unit, Unit> NavigateToPullRequest { get; }
2121
public string PullRequestTitle { get; } = "Fixing stuff in this PR";
2222
public string CheckSuiteName { get; } = "Awesome Check Suite";
23-
public string CheckRunName { get; } = "Psuedo Check Run";
24-
public IReadOnlyList<IPullRequestAnnotationItemViewModel> Annotations { get; } = new[]
25-
{
26-
new PullRequestAnnotationItemViewModelDesigner{
27-
Annotation = new CheckRunAnnotationModel
23+
public IReadOnlyDictionary<string, IPullRequestAnnotationItemViewModel[]> AnnotationsDictionary { get; }
24+
= new Dictionary<string, IPullRequestAnnotationItemViewModel[]>
25+
{
2826
{
29-
AnnotationLevel = CheckAnnotationLevel.Notice,
30-
StartLine = 3,
31-
EndLine = 4,
32-
Path = "asdf/asdf.cs",
33-
Message = "; is expected",
34-
Title = "CS 12345"
27+
"asdf/asdf.cs",
28+
new IPullRequestAnnotationItemViewModel[]
29+
{
30+
new PullRequestAnnotationItemViewModelDesigner
31+
{
32+
Annotation = new CheckRunAnnotationModel
33+
{
34+
AnnotationLevel = CheckAnnotationLevel.Warning,
35+
StartLine = 3,
36+
EndLine = 4,
37+
Path = "asdf/asdf.cs",
38+
Message = "; is expected",
39+
Title = "CS 12345"
40+
},
41+
IsExpanded = true,
42+
IsFileInPullRequest = true
43+
},
44+
new PullRequestAnnotationItemViewModelDesigner
45+
{
46+
Annotation = new CheckRunAnnotationModel
47+
{
48+
AnnotationLevel = CheckAnnotationLevel.Failure,
49+
StartLine = 3,
50+
EndLine = 4,
51+
Path = "asdf/asdf.cs",
52+
Message = "; is expected",
53+
Title = "CS 12345"
54+
},
55+
IsExpanded = true,
56+
IsFileInPullRequest = true
57+
},
58+
}
3559
},
36-
IsExpanded = true,
37-
IsFileInPullRequest = true
38-
},
39-
new PullRequestAnnotationItemViewModelDesigner{
40-
Annotation = new CheckRunAnnotationModel
4160
{
42-
AnnotationLevel = CheckAnnotationLevel.Warning,
43-
StartLine = 3,
44-
EndLine = 4,
45-
Path = "asdf/asdf.cs",
46-
Message = "; is expected",
47-
Title = "CS 12345"
61+
"blah.cs",
62+
new IPullRequestAnnotationItemViewModel[]
63+
{
64+
new PullRequestAnnotationItemViewModelDesigner
65+
{
66+
Annotation = new CheckRunAnnotationModel
67+
{
68+
AnnotationLevel = CheckAnnotationLevel.Notice,
69+
StartLine = 3,
70+
EndLine = 4,
71+
Path = "blah.cs",
72+
Message = "; is expected",
73+
Title = "CS 12345"
74+
},
75+
IsExpanded = true,
76+
}
77+
}
4878
},
49-
IsExpanded = true
50-
},
51-
new PullRequestAnnotationItemViewModelDesigner{
52-
Annotation = new CheckRunAnnotationModel
53-
{
54-
AnnotationLevel = CheckAnnotationLevel.Failure,
55-
StartLine = 3,
56-
EndLine = 4,
57-
Path = "blah.cs",
58-
Message = "; is expected",
59-
Title = "CS 12345"
60-
}
61-
}
62-
};
79+
};
80+
81+
public string CheckRunName { get; } = "Psuedo Check Run";
6382

6483
public Task InitializeAsync(ILocalRepositoryModel localRepository, IConnection connection, string owner, string repo,
65-
int pullRequestNumber, int checkRunId)
84+
int pullRequestNumber, string checkRunId)
6685
{
6786
return Task.CompletedTask;
6887
}

src/GitHub.App/SampleData/PullRequestCheckViewModelDesigner.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Reactive;
3-
using System.Windows.Media.Imaging;
43
using GitHub.Models;
54
using GitHub.ViewModels;
65
using GitHub.ViewModels.GitHubPane;
@@ -22,7 +21,7 @@ public sealed class PullRequestCheckViewModelDesigner : ViewModelBase, IPullRequ
2221

2322
public PullRequestCheckType CheckType { get; set; } = PullRequestCheckType.ChecksApi;
2423

25-
public int CheckRunId { get; set; }
24+
public string CheckRunId { get; set; }
2625

2726
public bool HasAnnotations { get; } = true;
2827
}

src/GitHub.App/ViewModels/GitHubPane/GitHubPaneViewModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public async Task NavigateTo(Uri uri)
272272
var owner = match.Groups["owner"].Value;
273273
var repo = match.Groups["repo"].Value;
274274
var number = int.Parse(match.Groups["number"].Value);
275-
var id = int.Parse(match.Groups["id"].Value);
275+
var id = match.Groups["id"].Value;
276276

277277
await ShowPullRequestCheckRun(owner, repo, number, id);
278278
}
@@ -330,7 +330,7 @@ public Task ShowPullRequestReviews(string owner, string repo, int number, string
330330
}
331331

332332
/// <inheritdoc/>
333-
public Task ShowPullRequestCheckRun(string owner, string repo, int number, int checkRunId)
333+
public Task ShowPullRequestCheckRun(string owner, string repo, int number, string checkRunId)
334334
{
335335
Guard.ArgumentNotNull(owner, nameof(owner));
336336
Guard.ArgumentNotNull(repo, nameof(repo));
@@ -513,8 +513,8 @@ static async Task<bool> IsValidRepository(ISimpleApiClient client)
513513

514514
static Regex CreateRoute(string route)
515515
{
516-
// Build RegEx from route (:foo to named group (?<foo>[\w_.-]+)).
517-
var routeFormat = "^" + new Regex("(:([a-z]+))\\b").Replace(route, @"(?<$2>[\w_.-]+)") + "$";
516+
// Build RegEx from route (:foo to named group (?<foo>[\w_.-=]+)).
517+
var routeFormat = "^" + new Regex("(:([a-z]+))\\b").Replace(route, @"(?<$2>[\w_.\-=]+)") + "$";
518518
return new Regex(routeFormat, RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
519519
}
520520
}

src/GitHub.App/ViewModels/GitHubPane/PullRequestAnnotationsViewModel.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class PullRequestAnnotationsViewModel : PanePageViewModelBase, IPullReque
2525
string title;
2626
string checkSuiteName;
2727
string checkRunName;
28-
IReadOnlyList<IPullRequestAnnotationItemViewModel> annotations;
28+
IReadOnlyDictionary<string, IPullRequestAnnotationItemViewModel[]> annotationsDictionary;
2929

3030
/// <summary>
3131
/// Initializes a new instance of the <see cref="PullRequestAnnotationsViewModel"/> class.
@@ -45,7 +45,7 @@ public PullRequestAnnotationsViewModel(IPullRequestSessionManager sessionManager
4545

4646
/// <inheritdoc/>
4747
public async Task InitializeAsync(ILocalRepositoryModel localRepository, IConnection connection, string owner,
48-
string repo, int pullRequestNumber, int checkRunId)
48+
string repo, int pullRequestNumber, string checkRunId)
4949
{
5050
if (repo != localRepository.Name)
5151
{
@@ -79,7 +79,7 @@ public async Task InitializeAsync(ILocalRepositoryModel localRepository, IConnec
7979
public int PullRequestNumber { get; private set; }
8080

8181
/// <inheritdoc/>
82-
public int CheckRunId { get; private set; }
82+
public string CheckRunId { get; private set; }
8383

8484
/// <inheritdoc/>
8585
public ReactiveCommand<Unit, Unit> NavigateToPullRequest { get; private set; }
@@ -105,11 +105,10 @@ public string CheckRunName
105105
private set { this.RaiseAndSetIfChanged(ref checkRunName, value); }
106106
}
107107

108-
/// <inheritdoc/>
109-
public IReadOnlyList<IPullRequestAnnotationItemViewModel> Annotations
108+
public IReadOnlyDictionary<string, IPullRequestAnnotationItemViewModel[]> AnnotationsDictionary
110109
{
111-
get { return annotations; }
112-
private set { this.RaiseAndSetIfChanged(ref annotations, value); }
110+
get { return annotationsDictionary; }
111+
private set { this.RaiseAndSetIfChanged(ref annotationsDictionary, value); }
113112
}
114113

115114
void Load(PullRequestDetailModel pullRequest)
@@ -123,18 +122,26 @@ void Load(PullRequestDetailModel pullRequest)
123122
var checkSuiteRun = pullRequest
124123
.CheckSuites.SelectMany(checkSuite => checkSuite.CheckRuns
125124
.Select(checkRun => new{checkSuite, checkRun}))
126-
.First(arg => arg.checkRun.DatabaseId == CheckRunId);
125+
.First(arg => arg.checkRun.CheckRunId == CheckRunId);
127126

128127
CheckSuiteName = checkSuiteRun.checkSuite.ApplicationName;
129128
CheckRunName = checkSuiteRun.checkRun.Name;
130-
Annotations = checkSuiteRun.checkRun.Annotations
131-
.Select(annotation => new PullRequestAnnotationItemViewModel(checkSuiteRun.checkSuite, checkSuiteRun.checkRun, annotation, session, pullRequestEditorService))
132-
.ToArray();
129+
130+
AnnotationsDictionary = checkSuiteRun.checkRun.Annotations
131+
.GroupBy(annotation => annotation.Path)
132+
.ToDictionary(
133+
grouping => grouping.Key,
134+
grouping => grouping
135+
.Select(annotation => new PullRequestAnnotationItemViewModel(checkSuiteRun.checkSuite, checkSuiteRun.checkRun, annotation, session, pullRequestEditorService))
136+
.Cast<IPullRequestAnnotationItemViewModel>()
137+
.ToArray()
138+
);
133139
}
134140
finally
135141
{
136142
IsBusy = false;
137143
}
138144
}
145+
139146
}
140147
}

0 commit comments

Comments
 (0)