Skip to content
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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Charp73 #173

wants to merge 18 commits into from

Conversation

laurentkempe
Copy link
Owner

No description provided.

var t = ParseComplete;
if (t != null)
t(this, e);
ParseComplete?.Invoke(this, e);
Copy link
Owner Author

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?

Copy link
Collaborator

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.

@sharwell
Copy link
Collaborator

Looks like a fun PR. I'll go through it!

Copy link
Collaborator

@sharwell sharwell left a 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... 😄

@laurentkempe
Copy link
Owner Author

@sharwell Nice ! But I am not finished

@laurentkempe
Copy link
Owner Author

This commit is more than I can deal with. Hopefully it's all correct...

@sharwell I will split this PR in multiple one ok ?

@sharwell
Copy link
Collaborator

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.

Copy link
Collaborator

@sharwell sharwell left a 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);
}
}
}
}
Copy link
Collaborator

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;
Copy link
Collaborator

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)
Copy link
Collaborator

@sharwell sharwell Aug 28, 2018

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}};
Copy link
Collaborator

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;
Copy link
Collaborator

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();
Copy link
Collaborator

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
Copy link
Collaborator

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);
Copy link
Collaborator

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.
Copy link
Collaborator

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")]
Copy link
Collaborator

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.

@laurentkempe
Copy link
Owner Author

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

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants