4

How can I set Resharper to wrap, say, the generated equality members with regions when selected from the Alt+Insert menu?

Thanks

4

3 回答 3

7

对话框底部通常有一个“在区域中换行”选项,但不是针对此选项。我会将其作为请求提交给 JetBrains。目前,您必须选择生成的方法并使用 ctrl->E,U,5 (环绕快捷方式)来获得预期的结果。

于 2008-11-07T22:19:25.997 回答
4

it doesn't really answer your question, but I just can't resist to try to convince you NOT to use regions. Why would you want to do it? The obvious disadvantages of regions are:

  • they don't compile, so you can never know if the name of the region really describes what is inside
  • regions are often used to hide rubbish code. The thinking here is: you can't see the rubbish bits, so it is as if they didn't exist. But guess what, they still exist...
  • regions are just textual, they don't have any semantic meaning. That means that the code inside the region can change the state of another region - which doesn't help to figure out what is happening in the class at all
  • if you structure your code correctly, it should be obvious what it is doing anyway

I believe using regions makes sense pretty much only for automatically generated parts, e.g. WinForms designer stuff. In most (all?) other cases it is much better to refactor the code, extract some extra classes or methods, etc. to make it clear.

于 2008-11-05T10:27:18.380 回答
4

您可以突出显示您感兴趣的文本,并使用 CTRL + k 的 Visual Studio 快捷键,从菜单中选择#region。

于 2008-11-07T22:25:52.190 回答