Why StyleCop rule does not allow using #region in

2019-07-22 10:05发布

I get the warning as below screenshot and I don't understand why it would be treated like that. I often need to "regionize" my codes.

What do you think?

alt text

2条回答
走好不送
2楼-- · 2019-07-22 10:47

While it is true that this StyleCop rule is just a recommendation, I would not disable it though. More often than not, these #region blocks are used as a visual and reading aid. It is usually a sign that a certain function or subroutine is too long and/or composed of multiple parts. You can use this as a guide or trigger to refactor that very long code.

查看更多
爷的心禁止访问
3楼-- · 2019-07-22 10:53

The default StyleCop rules are not set in stone.
I don't remember the link anymore, but someone from the StyleCop team once said that the default rules are just suggestions.

So feel free to disable rule SA1123 if you don't like it.

查看更多
登录 后发表回答