-
Notifications
You must be signed in to change notification settings - Fork 364
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
Order by access modifier now configurable. #359
Conversation
Signed-off-by: Adam Halassy <[email protected]>
[mod] Ordering by access level now can be configured
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.
Thanks again for putting these changes together. I've got a couple questions and a handful of nitpicks (as one would hopefully expect from a code cleaning project ;)), but overall looks good!
case vsCMAccess.vsCMAccessPrivate: return 6; | ||
default: return 0; | ||
} | ||
var itemsOrder = new[] { |
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.
Instead of starting in arrays, and converting to list.. why not just use lists?
vsCMAccess.vsCMAccessProtected, | ||
vsCMAccess.vsCMAccessPrivate | ||
}; | ||
if (!Settings.Default.Reorganizing_RevertAccessLevel) |
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.
Revert isn't a clear verb to me (means go back to an original state). I think you mean Reverse access level. In that case though, wouldn't this be a positive case where only if the flag was set would the reversal happen?
if (!Settings.Default.Reorganizing_RevertAccessLevel) | ||
itemsOrder = itemsOrder.Reverse().ToArray(); | ||
|
||
return itemsOrder.Contains(codeItemElement.Access) |
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.
IndexOf always returns -1 when no match is found, so you could remove the conditional and always return IndexOf+1.
@@ -15,6 +15,18 @@ | |||
<RadioButton Content="type then access" IsChecked="{Binding PrimaryOrderByAccessLevel, Converter={x:Static cnv:BooleanInverseConverter.Default}}" /> | |||
<RadioButton Content="access then type" IsChecked="{Binding PrimaryOrderByAccessLevel}" /> | |||
</StackPanel> | |||
<StackPanel |
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.
More nitpicks:
- Can we follow the formatting conventions of the rest of the file (e.g. attributes on same line)
- Can we use the same verbiage as other options.. (e.g. "Access levels should be ordered by" with the default option being first "public to private" and the alternate option being second "private to public")
@@ -25,7 +25,8 @@ public ReorganizingGeneralViewModel(CodeMaidPackage package, Settings activeSett | |||
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_KeepMembersWithinRegions, x => KeepMembersWithinRegions), | |||
new SettingToOptionMapping<int, AskYesNo>(x => ActiveSettings.Reorganizing_PerformWhenPreprocessorConditionals, x => PerformWhenPreprocessorConditionals), | |||
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_PrimaryOrderByAccessLevel, x => PrimaryOrderByAccessLevel), | |||
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RunAtStartOfCleanup, x => RunAtStartOfCleanup) | |||
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RunAtStartOfCleanup, x => RunAtStartOfCleanup), | |||
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RevertAccessLevel, x => RevertOrderByAccessLevel) |
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.
Will you please move this up to continue the alphabetical ordering.
/// <value> | ||
/// <c>true</c> if [revert order by access level]; otherwise, <c>false</c>. | ||
/// </value> | ||
public bool RevertOrderByAccessLevel |
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.
Will you please move this up to continue the alphabetical ordering. It would also be helpful to match the comment style to the others vs. auto-generated.
Perhaps a clearer name for this property would be ReverseAccessLevelOrdering
Thanks for all the notes I am going to fix the code keeping this in my mind. Also, I noticed that the code ordering puts the static members to the end of the code however I need the opposite ordering in my codes. Anyway, I also implemented configuration for for static member ordering in my fork. I am going to review that taking in consideration your notes and add those changes to this pull request within a few days. Do you agree or should I handle this on a different request? |
Sounds good. It's pretty closely related so I'm OK with it being on the same pull request. You may already be thinking it but it sounds like a separate configuration option to reverse static members. |
It definitely is a separate configuration option with it's own GUI option and setting field. |
# Conflicts: # CodeMaid/Properties/Settings.Designer.cs Signed-off-by: Adam Halassy <[email protected]>
Features/order by visibility
Hi! Sorry for the long delay, I was quite busy during the last few months. I made several changes to align with your conventions. Can you have a look? |
Looks good to me! Merging in to master now. :) Thanks again for your contribution! I hope you don't mind if I credit you during the next release? |
I made a couple formatting tweaks.. and I'm questioning the reversal logic now. The setting is off by default (i.e. public -> private).. yet in CodeItemTypeComparer it is reversing the items order when the setting is not true (i.e. off). Should the exclamation mark be removed, or am I looked at it backwards? |
I need to check this. Previously I planned to create a similar enhancement for static-instance level ordering - I am going to implement this. I'll check this as well, and I'll inform you if further alignments needed. My original intention was to keep your logic as default. |
Ok, sounds good. I went ahead and flipped that statement as I'm pretty sure from tracing through the logic it was inverted. Thanks for taking a look! |
I did retest that logic and confirm it's correct now. |
No description provided.