ReSharper的定制模式的改变方法名 [英] Resharper custom patterns change method name

查看:134
本文介绍了ReSharper的定制模式的改变方法名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从

公共静态异步任务负载()

公共静态异步任务LoadAsync()

如何在ReSharper的自定义一个模式?

How to define a custom patterns in ReSharper?

推荐答案

如果我理解正确的话,你,要定义一个自定义模式来改变异步任务法()签名异步任务MethodAsync()。如果是这样,这是可以通过使用自定义模式!

If I understood you correctly, you want to define a custom pattern to change async Task Method() signature to async Task MethodAsync(). If so, this is possible by using Custom Patterns!

有关这一点,到ReSharper的的选项,然后代码检验→自定义模式

For this, go to ReSharper's Options, then Code Inspection → Custom Patterns:


  • 点击添加模式

在新的对话框中,确保替换选择结果

In the new dialog, make sure Replace is selected

键入搜索和它们出现在下面的图片正是替换的模式。根据您的ReSharper的版本中,占位符参数会自动出现。如果没有,请按添加占位符按钮。

Type the Search and Replace pattern exactly as they appear in the image below. Depending on your ReSharper versions, the placeholder parameters should appear automatically. If not, press the Add Placeholder button.

双击 placehoder,并添加以下正则表达式: \b\w +; \b (小于异步?!) - 这只是告诉匹配方法名在异步没有不散了。

Double click the method placehoder, and add the following RegEx: \b\w+(?<!Async)\b - this tells only to match method names NOT ending in Async already.

模式严重性组合框中选择显示为提示显示为建议,视您的喜好。

In the Pattern Severity combobox select Show as Hint or Show as Suggestion, depending on your preference.

点击添加,然后保存(或另存为 - 团队共享,有这种模式存储在团队共享设置,适用于所有你的队友)。

Click Add, then Save (or Save To → Team Shared, to have this pattern stored in the team-shared settings, available to all your teammates).

ReSharper的现在将标志出所有的公共异步任务那些尚未与异步结束的方法:

ReSharper will now flag all public async Task methods that are not already end with Async:

和你现在可以按Alt-Enter键,快速修复它!

And you can now press Alt-Enter to quick-fix it!

这篇关于ReSharper的定制模式的改变方法名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆