Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Resharper实现编码准则_C#_Resharper_Configure - Fatal编程技术网

C# 使用Resharper实现编码准则

C# 使用Resharper实现编码准则,c#,resharper,configure,C#,Resharper,Configure,在我的项目中,我们需要遵循一些Web Api的编码标准。 有没有办法在Resharper中配置这些指令?我使用的是Resharper终极版。我们还可以将resharper配置为这样一种方式:如果不遵循这些指令,它将抛出错误并显示建议 该指南包含以下常见说明: Use Camel case in Payload Use camel case for the data elements in the payload. Eg:firstName,lastName

在我的项目中,我们需要遵循一些Web Api的编码标准。 有没有办法在Resharper中配置这些指令?我使用的是Resharper终极版。我们还可以将resharper配置为这样一种方式:如果不遵循这些指令,它将抛出错误并显示建议

该指南包含以下常见说明:

Use Camel case in Payload
    Use camel case for the data elements in the payload.    Eg:firstName,lastName                                                                                                                                                 
Use lowercase in Endpoints
    Use only lower case when defining the endpoints.                
    Eg:  GET \api\v1\customers\{CustomerID}\rewards                                                                

Use hyphen for compound words in Endpoints
    Use hyphen for compound words in Endpoints.                 
    Eg: GET \api\v1\customers\{CustomerId}\order-history    

Use Nouns not verbs 
    Noun based endpoint should be used rather than verb based endpoint for CRUD operations.                                              
    Eg:     GET \api\v1\\customers, GET \api\v1\customers\{CustomerID}                                                        
            GET \api\v1\GetAllCustomers

Use verb followed by noun in case of certain functions.                                    
    Eg: PUT \api\v1\customers\{CustomerID}\send-email

如果在VisualStudio中从Resharper打开选项菜单,则可以配置这些内容。如果滚动到选项列表的底部,您可以找到支持的每种语言的不同节点。例如,您可以在其中配置大写、小写或大括号布局。屏幕截图显示了C#的一些约定

我不知道有什么方法可以为此启用错误通知。但是有一个快捷方式,它使用您为整个文件配置的样式(在我的例子中是Strg+E+F)。因此,如果有人没有使用您的约定,而您打开了他的一个类,您只需按组合键,文档就会被样式化。也许这也可以通过Jenkins或其他方式集成到构建过程中,但我还没有尝试过

如果转到“重新竖琴->管理选项”,则可以将新设置导出到文件。同事可以使用与导出相同的方式导入此设置


我希望这对您有所帮助。

我相信您正在寻找StyleCop及其Resharper插件。StyleCop“分析C#源代码以强制执行一组样式和一致性规则”,包括您可以自己编写的规则


谢谢大家的快速回复。但我需要更多的定制。e、 g.如果有人将端点定义为大写字母[Route(“Seller/Search/{Page}/{PageSize}”)],那么它应该抛出错误并向IPElement建议为[Route(“Seller/Search/{Page}/{PageSize}”)],谢谢帮助。这可以通过使用StyleCop编写自定义规则来实现,谢谢您的帮助。