为什么 Resharper 重命名变量以下划线开头?

发布于 2024-09-10 04:30:00 字数 161 浏览 5 评论 0原文

我从来没有理解这一点,坦率地说,在代码中看到它让我很生气:以下划线开头的变量名称。

这有什么意义呢?

我刚刚安装了 Resharper 5.1,尝试了一下,看起来不错,尽管这一件事对我来说毁了它。

我还没有检查过,但我希望我能把它关掉。但为什么首先要这样做呢?

I've never understood this, and frankly, it pisses me off to see it in code: variable names that begin with an underscore.

What is the point of this?

I've just installed Resharper 5.1, trying it out and it seems nice, though this one thing is ruining it for me.

I haven't checked, but I'm hoping I can turn it off. But why is it done in the first place?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

友谊不毕业 2024-09-17 04:30:00

这是私有字段的一种非常常见的样式,有些使用 m_lowerCamelCase,有些仅使用 _lowerCamelCase,还有一些使用 lowerCamelCase。对于函数内部的变量来说,它更加罕见,并且默认使用 lowerCamelCase 来重塑它们。

请注意,设计指南的命名部分不鼓励使用前缀公共成员但私有成员不关心(并且公共字段应该仅在真正特定的情况下使用,因为无论如何它们都是危险的)。

在重塑器选项中,所有这些都可以用语言>进行更改。常见>命名风格

您还可以将参数保存在解决方案或文件中并导入/导出它们。使用它,您可以为团队中的每个人一次性设置参数。

It's a pretty common style for private fields, some use m_lowerCamelCase, others only _lowerCamelCase and still others lowerCamelCase. For variables inside a functions it's a lot more rare and reshaper by default use lowerCamelCase for them.

Note that the naming section of the design guidelines discourage the use of prefixes for public members but private members are not concerned (And public fields should be used only in really specific cases due to their dangers anyway).

In the reshaper options all of that could be changed in Languages > Common > Naming Style.

You could also save your parameters in the solution or in a file and import/export them. Using that you could set the parameters once and for all for everyone in your team.

傲影 2024-09-17 04:30:00

用下划线作为私有实例和/或各种静态成员的前缀是一种广泛采用的做法(显然,[需要引用],但确实如此);这里不是我讨论其是非的地方。

在 ReSharper 中 |选项您将看到语言|常见 |命名样式(以及每种语言的覆盖)将允许您指示 ReSharper 完全按照您的意愿进行操作。

Prefixing private instance and/or static members of various kinds with an underscore is a widely-adopted practice ([citation needed], obviously, but it is); this is not the place for me to discuss its rights and wrongs.

In ReSharper | Options you will see Languages | Common | Naming Style (and per-language overrides) that will allow you to instruct ReSharper to do exactly as you wish instead.

初见你 2024-09-17 04:30:00

使用下划线来表示类变量是一种常见的做法。

ReSharper 中应该有一个选项来配置您希望类变量开始的内容(如果有的话)。我没有在这台机器上安装它,所以我无法轻松检查该选项是什么。

It's a common practice to use underscores to denote class variables.

There should be an option in ReSharper to configure what, if anything, you want your class variables to start with. I don't have it installed on this machine so I can't easily check what that option is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文