简体   繁体   English

ReSharper Search With Pattern-不重播模式

[英]ReSharper Search With Pattern - not replaying pattern

I've been trying to use ReSharper's search with pattern tool to append a [UriSample] to each endpoint using the existing [Route] prefix. 我一直在尝试使用ReSharper的带模式搜索工具,以使用现有的[Route]前缀将[UriSample]附加到每个端点。 This currently does not replace anything: 目前,这不能替代任何内容:

Search Pattern: 搜索模式:

[Route($route$)] 
[Obsolete($obsolete$)]

replace Pattern: 替换模式:

[Route($route$)] 
[Obsolete($obsolete$)]
**[UriSample("devices/$route$")]**

I've looked at a lot of documentation but it seems like I can not find a solution to this. 我看了很多文档,但似乎找不到解决方案。 Thank you for the help :) 感谢您的帮助 :)

** it usually says "Pattern is unambiguous" ** **通常会说“模式是明确的” **

This is a current limitation of this system. 这是该系统的当前限制。 It's made to perform syntactic changes on your code, and it doesn't support symbolic operations for now. 它是为了对代码执行语法更改而创建的,并且目前不支持符号操作。

In your case Visual Studio Find and Replace dialog will help. 在您的情况下,Visual Studio的“查找和替换”对话框会有所帮助。 You can use this pattern to look for the attribute: 您可以使用此模式来查找属性:

\[Route\(\"(.+?)\"\)\]

And this one for replace action: 而这个替换动作:

[Route("$1")]\n[UriSample("devices/$1")]

After the replacement just execute formatting action to fix any layout issues according to your project settings. 替换后,只需执行格式化操作即可根据您的项目设置解决所有布局问题。

Before: 之前:

在此处输入图片说明

After: 后:

在此处输入图片说明

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

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