简体   繁体   English

ReSharper C# DTO 的命名约定

[英]ReSharper C# Naming Convention for DTOs

I try to customize the naming rule for classes that when I see or create a DTO that the name is actually FooDTO and not FooDto .我尝试自定义类的命名规则,当我看到或创建名称实际上是FooDTO而不是FooDto的 DTO 时。 But I couldn't solve the problem that ReSharper checks every class and marks every class that has not a Dto in its name.但是我无法解决 ReSharper 检查每个 class 并标记每个名称中没有 Dto 的 class 的问题。

Can I create conditional rules that are only triggered on actual DTOs?我可以创建仅在实际 DTO 上触发的条件规则吗?

The best thing to do in your case would be simply the following:在您的情况下,最好的办法就是:

Add another rule with the DTO suffix添加另一个带有 DTO 后缀的规则

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Now R# is happy again as if nothing happened.现在R#又开心起来了,好像什么都没发生过一样。

Alternatively, you can turn these warnings off in different ways:或者,您可以通过不同的方式关闭这些警告:

Add the abbreviation to team-shared settings将缩写添加到团队共享设置

在此处输入图像描述

Use SuppressMessage使用SuppressMessage

[SuppressMessage("ReSharper", "InconsistentNaming")]
class WhateverDTO
{
    
}    

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM