-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Charp73 #173
base: master
Are you sure you want to change the base?
Charp73 #173
Conversation
var t = ParseComplete; | ||
if (t != null) | ||
t(this, e); | ||
ParseComplete?.Invoke(this, e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sharwell Why do you assign to local before calling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➡️ 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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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. 😄
textView.Properties.AddProperty(typeof(GitDiffMarginCommandHandler), filter); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 I don't like how the missing newline at the end is presented by tools to look like an error.
private readonly IVsEditorAdaptersFactoryService _editorAdaptersFactoryService; | ||
private readonly SVsServiceProvider _serviceProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ 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.
internal abstract class GitDiffMarginCommandHandler<T> : ShimCommandHandler<T> | ||
where T : EditorCommandArgs | ||
{ | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 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.
|
||
public virtual CommandState GetCommandState(T args) | ||
{ | ||
ThreadHelper.ThrowIfNotOnUIThread(); | ||
|
||
OLECMD[] command = { new OLECMD { cmdID = _commandId } }; | ||
OLECMD[] command = {new OLECMD {cmdID = _commandId}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 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).
@@ -48,11 +45,7 @@ private void UpdateDiffDimensions(DiffViewModel diffViewModel, HunkRangeInfo hun | |||
|
|||
private bool? UpdateNormalDiffDimensions(DiffViewModel diffViewModel, HunkRangeInfo hunkRangeInfo) | |||
{ | |||
if (hunkRangeInfo.NewHunkRange.NumberOfLines <= 0) | |||
{ | |||
// if visible, it would have been as a deletion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Where did this comment go? Looks like the tool performed an auto-destroy on this method.
@@ -194,9 +165,9 @@ private void UpdateDiffDimensions(DiffViewModel diffViewModel, HunkRangeInfo hun | |||
return false; | |||
} | |||
|
|||
double center = followingTop; | |||
double height = TextView.LineHeight; | |||
diffViewModel.Top = center - (height / 2.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 These parentheses improve readability IMO
@@ -47,27 +39,14 @@ public IEnumerable<HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, stri | |||
yield break; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 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.