Removing regions from code

I would like to remove regions completely from the C# code. It seems R# can do this region by region but I want to remove all of them either in the file or across the solution.

Any suggestions? I would like to add this feature to the cleanup code template.

11 comments
Comment actions Permalink

This is controlled by a setting in the code cleanup template, so if you take a look in there you'll see where to flip the switch.

0
Comment actions Permalink

Hello abdu,

Please check the following article: http://codebetter.com/blogs/kyle.baley/archive/2007/12/17/removing-regions-or-quot-how-to-keep-your-code-expanded-quot.aspx

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


IR> I would like to remove regions completely from the C# code. It seems
IR> R# can do this region by region but I want to remove all of them
IR> either in the file or across the solution.
IR>
IR> Any suggestions? I would like to add this feature to the cleanup
IR> code template.
IR>


0
Comment actions Permalink

Can anyone confirm that this works with Resharper 4? I have just tried this but still seem to be getting regions around code when using the code cleanup function.

0
Comment actions Permalink

Using custom code cleanup profile, ReSharper can remove all regions inside
classes. Regions outside classes will remain

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"a" <andrew.cropper@gmail.com> wrote in message
news:23412211.94771215528904395.JavaMail.jive@app4.labs.intellij.net...

Can anyone confirm that this works with Resharper 4? I have just tried
this but still seem to be getting regions around code when using the code
cleanup function.



0
Comment actions Permalink

Eugene,

When RS removes regions is it removing just the #region and #endregion statements or does it remove the code inside the region as well? I suppose I could try it but I'd like to investigate why you'd want to remove the regions. I could probably remove the regions myself quickly enough using the editor. Writing generally, where I have used regions I've had a particular need for them and seldom have I needed to remove them.

0
Comment actions Permalink

Jeremy,

Can you explain that to me? For example, I select a source file in the IDE and right-click to open the Cleanup Code... context menu. It displays the dialogs containing the profiles but none of them have a setting that targets regions specifically. Unless, of course, I'm looking in the wrong place?

0
Comment actions Permalink

You need to change the R# configuration's Type Members Layout to not use the default patterns (uncheck the checkbox) and then edit the configuration. Within that configuration you can do all sorts of wonderful things (in some ways more limited than a tool like Regionerate but in many ways less limited and in all ways more reliable ;) ) to customize the organization of a give source file against which the cleanup is executed. Each of the resulting groupings of source file content can be set to be enclosed or not enclosed in regions and that region generation can even be customized in a number of interesting ways that the example patterns and minimal in-example documentation only barely begin to describe (hint to JetBrains: please provide decent documentation for this feature. There is too much capability here to have such little documentation.)

0
Comment actions Permalink

I see what you mean. I looked at the configuration and to be honest, I would not know what to change, when, or why. As you imply, if it's not documented then it's not so intuitive to work out or appreciate what it has to offer. To be honest, I feel a little uneasy changing other RS settings that I do understand. As for changing settings I don't understand these ones are best left hidden in the bushes. If you won't tell the sheriff, neither will I.

0
Comment actions Permalink

Just #region/#endregion directives

--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Peter Hamilton-Scott" <no_reply@jetbrains.com> wrote in message
news:29068088.97921215602204351.JavaMail.jive@app4.labs.intellij.net...

Eugene,

>

When RS removes regions is it removing just the #region and #endregion
statements or does it remove the code inside the region as well? I
suppose I could try it but I'd like to investigate why you'd want to
remove the regions. I could probably remove the regions myself quickly
enough using the editor. Writing generally, where I have used regions I've
had a particular need for them and seldom have I needed to remove them.



0
Comment actions Permalink

Ilya,

I've used the template trick in the link and it removes regions (some) fine.  If I have a region inside a method for example, it does not remove it.

Do you know if there is another way to do this in the type members layout?

0
Comment actions Permalink

My template is simply this:

<?xml version="1.0" encoding="utf-8" ?>
<Patterns xmlns="urn:shemas-jetbrains-com:member-reordering-patterns">
<Pattern RemoveAllRegions="true">
     <Entry />
  </Pattern>
</Patterns>


Regions within a method does not get removed.

0

Please sign in to leave a comment.