如何配置 Resharper 以使其“允许”方法名称中有下划线吗?

发布于 2024-12-29 17:27:30 字数 496 浏览 5 评论 0原文

我正在将 NUnit 与 Resharper 结合使用。

对于普通方法,我使用 Pascal 大小写约定,例如 MethodName()。

我想在我的测试方法中使用以下模式,因为它们的名称会很长,因此变得更具可读性,但是,Resharper 抱怨该模式应该没有“_”。

[Test]
public void LoginRegisterPage_WithValidEmailAddress_ShouldSendReminderEmail()
{
}

如何配置 Resharper,使其允许在方法名称中包含下划线而不引发警告?

我去了Resharper>选项>语言> C#> C# 命名风格 >覆盖自定义设置/高级设置并添加一个带有“_”的选项,但发生的情况是,它现在要求我的所有方法都被很好地命名,而我只是希望能够允许这种语法。

希望问题清楚。

I'm using NUnit with Resharper.

For normal methods I'm using Pascal casing convention e.g. MethodName().

I'd like to use the below pattern for my test methods because they become more readable as their names would be long, however, Resharper complains that the pattern should be without "_".

[Test]
public void LoginRegisterPage_WithValidEmailAddress_ShouldSendReminderEmail()
{
}

How to configure Resharper so that it allows having underscore in method names without throwing warnings?

I went to Resharper > Options > Languages > C# > C# Naming Style > Override Custom Settings / Advanced Settings and added an option to have "_" but what happened is that it requires now that all my methods to be named well whereas I just like to be able to allow this syntax.

Hope the question is clear.

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

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

发布评论

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

评论(1

2025-01-05 17:27:30

输入图片此处描述

转到 Resharper 选项、C#(或支持的任何其他语言)和命名样式。
您可以选择“方法”并选择“all_lower”选项。

如果您将其添加为另一个选项,它不会给您带来任何麻烦。

enter image description here

Go to Resharper options, c# (or any other language supported) and naming style.
You can select "Method" and have the "all_lower" option selected.

If you add it as another option it should not give you any trouble.

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