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

Commit 73be964

Browse files
Merge remote-tracking branch 'origin/master' into buildcrosscheck-updates
2 parents 95e091e + 2c79611 commit 73be964

File tree

11 files changed

+93
-20
lines changed

11 files changed

+93
-20
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

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

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ public Encoding GetEncoding(ILocalRepositoryModel repository, string relativePat
769769
}
770770
}
771771

772-
return Encoding.Default;
772+
return null;
773773
}
774774

775775
static bool HasPreamble(string file, Encoding encoding)
@@ -877,7 +877,15 @@ async Task ExtractToTempFile(
877877
}
878878

879879
Directory.CreateDirectory(Path.GetDirectoryName(tempFilePath));
880-
File.WriteAllText(tempFilePath, contents, encoding);
880+
881+
if (encoding != null)
882+
{
883+
File.WriteAllText(tempFilePath, contents, encoding);
884+
}
885+
else
886+
{
887+
File.WriteAllText(tempFilePath, contents);
888+
}
881889
}
882890

883891
IEnumerable<string> GetLocalBranchesInternal(
@@ -963,7 +971,7 @@ static string CalculateTempFileName(string relativePath, string commitSha, Encod
963971
{
964972
// The combination of relative path, commit SHA and encoding should be sufficient to uniquely identify a file.
965973
var relativeDir = Path.GetDirectoryName(relativePath) ?? string.Empty;
966-
var key = relativeDir + '|' + encoding.WebName;
974+
var key = relativeDir + '|' + (encoding?.WebName ?? "unknown");
967975
var relativePathHash = key.GetSha256Hash();
968976
var tempDir = Path.Combine(Path.GetTempPath(), "GitHubVisualStudio", "FileContents", relativePathHash);
969977
var tempFileName = Invariant($"{Path.GetFileNameWithoutExtension(relativePath)}@{commitSha}{Path.GetExtension(relativePath)}");

src/GitHub.App/ViewModels/PullRequestReviewCommentThreadViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public bool IsNewThread
7878
public async Task InitializeAsync(
7979
IPullRequestSession session,
8080
IPullRequestSessionFile file,
81-
PullRequestReviewModel review,
8281
IInlineCommentThreadModel thread,
8382
bool addPlaceholder)
8483
{
@@ -97,7 +96,7 @@ public async Task InitializeAsync(
9796
await vm.InitializeAsync(
9897
session,
9998
this,
100-
review,
99+
comment.Review,
101100
comment.Comment,
102101
CommentEditState.None).ConfigureAwait(false);
103102
Comments.Add(vm);
@@ -110,7 +109,7 @@ await vm.InitializeAsync(
110109
await vm.InitializeAsPlaceholderAsync(
111110
session,
112111
this,
113-
review.State == PullRequestReviewState.Pending,
112+
session.HasPendingReview,
114113
false).ConfigureAwait(true);
115114

116115
var (key, secondaryKey) = GetDraftKeys(vm);

src/GitHub.Exports.Reactive/Services/IPullRequestService.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ IObservable<IPullRequestModel> CreatePullRequest(IModelService modelService,
176176
IObservable<Tuple<string, int>> GetPullRequestForCurrentBranch(ILocalRepositoryModel repository);
177177

178178
/// <summary>
179-
/// Gets the encoding for the specified file.
179+
/// Gets the encoding for the specified local file.
180180
/// </summary>
181181
/// <param name="repository">The repository.</param>
182182
/// <param name="relativePath">The relative path to the file in the repository.</param>
183183
/// <returns>
184-
/// The file's encoding or <see cref="Encoding.Default"/> if the file doesn't exist.
184+
/// The file's encoding or null if the file doesn't exist locally.
185185
/// </returns>
186186
Encoding GetEncoding(ILocalRepositoryModel repository, string relativePath);
187187

@@ -192,7 +192,9 @@ IObservable<IPullRequestModel> CreatePullRequest(IModelService modelService,
192192
/// <param name="pullRequest">The pull request details.</param>
193193
/// <param name="relativePath">The path to the file, relative to the repository root.</param>
194194
/// <param name="commitSha">The SHA of the commit.</param>
195-
/// <param name="encoding">The encoding to use.</param>
195+
/// <param name="encoding">
196+
/// The encoding to save the file with. If null, will use the file's original encoding.
197+
/// </param>
196198
/// <returns>The path to the temporary file.</returns>
197199
Task<string> ExtractToTempFile(
198200
ILocalRepositoryModel repository,

src/GitHub.Exports.Reactive/ViewModels/IPullRequestReviewCommentThreadViewModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,13 @@ public interface IPullRequestReviewCommentThreadViewModel : ICommentThreadViewMo
4646
/// </summary>
4747
/// <param name="session">The pull request session.</param>
4848
/// <param name="file">The file that the comment is on.</param>
49-
/// <param name="review">The associated review.</param>
5049
/// <param name="thread">The thread.</param>
5150
/// <param name="addPlaceholder">
5251
/// Whether to add a placeholder comment at the end of the thread.
5352
/// </param>
5453
Task InitializeAsync(
5554
IPullRequestSession session,
5655
IPullRequestSessionFile file,
57-
PullRequestReviewModel review,
5856
IInlineCommentThreadModel thread,
5957
bool addPlaceholder);
6058

src/GitHub.InlineReviews/Services/PullRequestSessionService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ static void BuildPullRequestThreads(PullRequestDetailModel model)
845845
}
846846

847847
// Get the comments that are replies and place them into the relevant list.
848-
foreach (CommentAdapter comment in model.Reviews.SelectMany(x => x.Comments))
848+
foreach (CommentAdapter comment in model.Reviews.SelectMany(x => x.Comments).OrderBy(x => x.CreatedAt))
849849
{
850850
if (comment.ReplyTo != null)
851851
{

src/GitHub.InlineReviews/ViewModels/InlineCommentPeekViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async Task UpdateThread()
181181

182182
if (thread?.Comments.Count > 0)
183183
{
184-
await vm.InitializeAsync(session, file, thread.Comments[0].Review, thread, true);
184+
await vm.InitializeAsync(session, file, thread, true);
185185
}
186186
else
187187
{

src/GitHub.VisualStudio.UI/Views/CommentView.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
Account="{Binding Author}"/>
5757

5858
<TextBlock Foreground="{DynamicResource GitHubVsToolWindowText}" FontWeight="Bold" Text="{Binding Author.Login}" Margin="4 0"/>
59-
<ui:GitHubActionLink Content="{Binding UpdatedAt, Converter={ui:DurationToStringConverter}}"
59+
<ui:GitHubActionLink Content="{Binding CreatedAt, Converter={ui:DurationToStringConverter}}"
6060
Command="{Binding OpenOnGitHub}"
6161
Foreground="{DynamicResource GitHubVsToolWindowText}"
6262
Opacity="0.75" />

test/GitHub.App.UnitTests/ViewModels/PullRequestReviewCommentThreadViewModelTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,13 @@ async Task<PullRequestReviewCommentThreadViewModel> CreateTarget(
111111
IViewViewModelFactory factory = null,
112112
IPullRequestSession session = null,
113113
IPullRequestSessionFile file = null,
114-
PullRequestReviewModel review = null,
115114
IEnumerable<InlineCommentModel> comments = null,
116115
bool newThread = false)
117116
{
118117
draftStore = draftStore ?? Substitute.For<IMessageDraftStore>();
119118
factory = factory ?? CreateFactory();
120119
session = session ?? CreateSession();
121120
file = file ?? CreateFile();
122-
review = review ?? new PullRequestReviewModel();
123121
comments = comments ?? CreateComments();
124122

125123
var result = new PullRequestReviewCommentThreadViewModel(draftStore, factory);
@@ -134,7 +132,7 @@ async Task<PullRequestReviewCommentThreadViewModel> CreateTarget(
134132
thread.Comments.Returns(comments.ToList());
135133
thread.LineNumber.Returns(10);
136134

137-
await result.InitializeAsync(session, file, review, thread, true);
135+
await result.InitializeAsync(session, file, thread, true);
138136
}
139137

140138
return result;

0 commit comments

Comments
 (0)