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

Added an option to include access level in regions only for methods #828

Merged
merged 8 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CodeMaid/Logic/Reorganizing/GenerateRegionLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private CodeItemRegion ComposeRegionForCodeItem(BaseCodeItem codeItem)
if (Settings.Default.Reorganizing_RegionsIncludeAccessLevel)
{
var element = codeItem as BaseCodeItemElement;
if (element != null)
if (element != null && (!Settings.Default.Reorganizing_RegionsIncludeAccessLevelForMethodsOnly || element is CodeItemMethod))
{
var accessModifier = CodeElementHelper.GetAccessModifierKeyword(element.Access);
if (accessModifier != null)
Expand Down
9 changes: 9 additions & 0 deletions CodeMaid/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions CodeMaid/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>

</data>
There are any number of "resheader" rows that contain simple
name/value pairs.

Expand Down Expand Up @@ -929,4 +929,7 @@ Do you want to reorganize anyways (DANGEROUS)?</value>
<data name="RegularExpressionsThatMatchPathNamesToIncludeExResxOrLib" xml:space="preserve">
<value>Regular expressions that match path names to include or leave empty to include all files (ex: \.resx$ or \\lib\\ )</value>
</data>
<data name="OnlyForMethods" xml:space="preserve">
<value>Only for methods</value>
</data>
</root>
3 changes: 3 additions & 0 deletions CodeMaid/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -929,4 +929,7 @@ Do you want to reorganize anyways (DANGEROUS)?</value>
<data name="RegularExpressionsThatMatchPathNamesToIncludeExResxOrLib" xml:space="preserve">
<value>Regular expressions that match path names to include or leave empty to include all files (ex: \.resx$ or \\lib\\ )</value>
</data>
<data name="OnlyForMethods" xml:space="preserve">
<value>Only for methods</value>
</data>
</root>
11 changes: 7 additions & 4 deletions CodeMaid/Properties/Resources.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
</data>

There are any number of "resheader" rows that contain simple
name/value pairs.
Expand Down Expand Up @@ -924,4 +924,7 @@
<data name="YouHavePendingChangesDoYouWantToSaveThemBeforeContinuing" xml:space="preserve">
<value>您有挂起的更改。 是否要在继续之前保存它们?</value>
</data>
<data name="OnlyForMethods" xml:space="preserve">
<value>Only for methods (TBT)</value>
</data>
</root>
14 changes: 13 additions & 1 deletion CodeMaid/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions CodeMaid/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -573,5 +573,8 @@
<Setting Name="Cleaning_UpdateFileHeader_HeaderUpdateMode" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="Reorganizing_RegionsIncludeAccessLevelForMethodsOnly" Type="System.String" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<StackPanel>
<CheckBox Content="{x:Static p:Resources.IncludeAccessLevelInRegions}" IsChecked="{Binding IncludeAccessLevel}" />
<TextBlock Text="{x:Static p:Resources.ExRegionPublicMethodsRegionPrivateMethods}" Margin="35,0,5,10" />
<CheckBox Content="{x:Static p:Resources.OnlyForMethods}" IsChecked="{Binding IncludeAccessLevelForMethodsOnly}" Margin="35,0,5,10" IsEnabled="{Binding IncludeAccessLevel}" />

<CheckBox Content="{x:Static p:Resources.InsertKeepRegionsEvenIfTheyAreEmpty}" IsChecked="{Binding InsertKeepEvenIfEmpty}" />
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public ReorganizingRegionsViewModel(CodeMaidPackage package, Settings activeSett
Mappings = new SettingsToOptionsList(ActiveSettings, this)
{
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RegionsIncludeAccessLevel, x => IncludeAccessLevel),
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RegionsIncludeAccessLevelForMethodsOnly, x => IncludeAccessLevelForMethodsOnly),
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RegionsInsertKeepEvenIfEmpty, x => InsertKeepEvenIfEmpty),
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RegionsInsertNewRegions, x => InsertNewRegions),
new SettingToOptionMapping<bool, bool>(x => ActiveSettings.Reorganizing_RegionsRemoveExistingRegions, x => RemoveExistingRegions)
Expand Down Expand Up @@ -48,6 +49,12 @@ public bool IncludeAccessLevel
set { SetPropertyValue(value); }
}

public bool IncludeAccessLevelForMethodsOnly
{
get { return GetPropertyValue<bool>(); }
set { SetPropertyValue(value); }
}

/// <summary>
/// Gets or sets the flag indicating if regions should be inserted or kept even if they would be empty.
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions CodeMaid/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@
<setting name="Cleaning_UpdateFileHeader_HeaderUpdateMode" serializeAs="String">
<value />
</setting>
<setting name="Reorganizing_RegionsIncludeAccessLevelForMethodsOnly"
serializeAs="String">
<value>False</value>
</setting>
</SteveCadwallader.CodeMaid.Properties.Settings>
</userSettings>
<startup>
Expand Down