Conversation
| var t = ParseComplete; | ||
| if (t != null) | ||
| t(this, e); | ||
| ParseComplete?.Invoke(this, e); |
There was a problem hiding this comment.
@sharwell Why do you assign to local before calling?
There was a problem hiding this comment.
➡️ the ?. operator also assigns to a local. It prevents a NullReferenceException if the field is assigned between the null check and the invocation.
|
Looks like a fun PR. I'll go through it! |
sharwell
left a comment
There was a problem hiding this comment.
Run R# default full cleanup
This commit is more than I can deal with. Hopefully it's all correct... 😄
|
@sharwell Nice ! But I am not finished |
@sharwell I will split this PR in multiple one ok ? |
|
My biggest recommendation is if you are hoping/planning to settle on a consistent style, use StyleCop Analyzers to enforce the desired style during the build. Otherwise it's too easy for the project to start to deviate. |
sharwell
left a comment
There was a problem hiding this comment.
@laurentkempe In the end, the decision is up to you. I'm not a fan of the way this tool applies formatting, but it's not my project so I don't make the rules. 😄
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
📝 I don't like how the missing newline at the end is presented by tools to look like an error.
| { | ||
| private readonly SVsServiceProvider _serviceProvider; | ||
| private readonly IVsEditorAdaptersFactoryService _editorAdaptersFactoryService; | ||
| private readonly SVsServiceProvider _serviceProvider; |
There was a problem hiding this comment.
❔ Why was this reordered? Previously the fields, the constructor parameters, and the assignments in the constructor all appeared in the same order. Now they are inconsistent.
| { | ||
| protected GitDiffMarginCommandHandler(GitDiffMarginCommand commandId) | ||
| : base(new Guid(GitDiffMarginCommandHandler.GitDiffMarginCommandSet), (uint)commandId) | ||
| : base(new Guid(GitDiffMarginCommandHandler.GitDiffMarginCommandSet), (uint) commandId) |
There was a problem hiding this comment.
📝 Unexpected space after cast. If this is a style you want to use, you'll want to add it to a .editorconfig file because it's not the default behavior of Visual Studio.
| ThreadHelper.ThrowIfNotOnUIThread(); | ||
|
|
||
| OLECMD[] command = { new OLECMD { cmdID = _commandId } }; | ||
| OLECMD[] command = {new OLECMD {cmdID = _commandId}}; |
There was a problem hiding this comment.
📝 Unexpected removal of spaces inside braces
|
|
||
| return (command[0].cmdf & (uint) OLECMDF.OLECMDF_ENABLED) == 0 | ||
| ? CommandState.Unavailable | ||
| : CommandState.Available; |
There was a problem hiding this comment.
💭 This is not wrong, but I don't like how some of this method uses an if with early return, while another part uses a ternary. Given the complexity of the condition expressions, I believe the original form was preferable.
| if (e.ChangedItems.Contains(DiffFormatNames.Addition) | ||
| || e.ChangedItems.Contains(DiffFormatNames.Modification) | ||
| || e.ChangedItems.Contains(DiffFormatNames.Removed)) | ||
| UpdateBrushes(); |
There was a problem hiding this comment.
📝 missing braces for multi-line condition. This situation is similar to the one that led to SA1519, and IMO it was a mistake to omit this from the design of that rule (see DotNetAnalyzers/StyleCopAnalyzers#1488).
| { | ||
| if (hunkRangeInfo.NewHunkRange.NumberOfLines <= 0) | ||
| { | ||
| // if visible, it would have been as a deletion |
There was a problem hiding this comment.
❓ Where did this comment go? Looks like the tool performed an auto-destroy on this method.
|
|
||
| double center = followingTop; | ||
| double height = TextView.LineHeight; | ||
| diffViewModel.Top = center - (height / 2.0); |
There was a problem hiding this comment.
📝 These parentheses improve readability IMO
| var retrieveStatus = repo.RetrieveStatus(originalPath); | ||
| if (retrieveStatus == FileStatus.Nonexistent) | ||
| { | ||
| // this occurs if a file within the repository itself (not the working copy) is opened. |
There was a problem hiding this comment.
📝 Comment handling in whatever tool formatted this method is a serious problem. It's severe enough that I would recommend reporting this as a bug to the tool vendor.
| [assembly: InternalsVisibleTo("GitDiffMargin.LegacyCommands, PublicKey=00240000048000009400000006020000002400005253413100040000010001007df3fa608a609f848a39944defc0b31e504b3e84fc5c7cd6008277f4c323cc8332ce97434c483558e43fb4d6b5c6e4c4ddb3711dabafef0e79bda1f02d49621c7bc1da4b6847707f70417455e6b76cb27c08f4d32ad29a20233124023b809d2be10d3b0a003edeee23c0d8758b384103a18c95ba323c63a451052d84dc7672d0")] | ||
| [assembly: | ||
| InternalsVisibleTo( | ||
| "GitDiffMargin.Commands, PublicKey=00240000048000009400000006020000002400005253413100040000010001007df3fa608a609f848a39944defc0b31e504b3e84fc5c7cd6008277f4c323cc8332ce97434c483558e43fb4d6b5c6e4c4ddb3711dabafef0e79bda1f02d49621c7bc1da4b6847707f70417455e6b76cb27c08f4d32ad29a20233124023b809d2be10d3b0a003edeee23c0d8758b384103a18c95ba323c63a451052d84dc7672d0")] |
There was a problem hiding this comment.
📝 I understand how this happened, but at this point it seems to make more sense to just leave it on one line.
@sharwell I have to say that I am not a big fan neither at the moment of the formatting! It might be not your project but your participate quite a lot on it, so it is always good to get your ideas/feeling... I will reconsider all of this and will first make a PR which just change the whole thing to C# 7.3! For the rest we will see |
No description provided.