本文介绍了Omnisharp如何在其配置文件中使用通配符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与.我希望询问更多详细信息,但还没有声誉来发表评论.情况是相同的:我通过编辑Omnisharp的config.json文件的"IgnoredCodeIssues"部分来添加要忽略的代码检查警告.

This relates to an older stackoverflow question. I was hoping to ask for more details but haven't got the Reputation to write comments yet.Circumstances are the same: I'm adding codecheck warnings that I want to ignore, by editing the "IgnoredCodeIssues" section of Omnisharp's config.json file.

哪些通配符/正则表达式字符在这里起作用,以及如何起作用?也许这是一个众所周知的标准,在我可以阅读的地方有自己的文档?

如果我输入问题警告字样,则可以使用,但是使用通配符会更有效.例如,以下警告:

If I enter an issue warning verbatim it works, but it would be way more efficient to use wildcards. For example this warning:

Method 'Update' has the same with 'Start'

是我不关心的警告,它会弹出很多.一个好的解决方案是将其配置为适用于此问题的所有实例,即在更新"和开始"部分使用通配符.使用典型的正则表达式,它看起来像这样:

is a warning I don't care about and it's going to pop up a lot. A good solution would be to configure it to work for all instances of this issue, i.e. to use wildcards at the 'Update' and 'Start' parts.Using a typical regexp it would look like this:

/(Method)\s'\w+'\shas the same with\s'\w+'/g

但这显然不是这里的语法,只会破坏配置文件.因此,我希望了解该特定文件中通配符的特定语法.

but that's obviously not the syntax here and would just break the config file. So I'm hoping to understand the particular syntax of wildcards in this particular file.

我使用Omnisharp-sublime和Sublime Text 3.我已经阅读了文档并在GitHub页面上翻阅(没有链接,因为我的声誉对于2个以上的链接而言太低了),但是唯一相关的信息是示例配置文件,其中存在一些被忽略的问题:

I use Omnisharp-sublime and Sublime Text 3.I've read the docs and rummaged around the GitHub page (no links as my reputation is too low for 2+ links) but the only relevant information is an example config file with a couple of ignored issues:

"IgnoredCodeIssues": [
    "^Keyword 'private' is redundant. This is the default modifier.$",
    ".* should not separate words with an underscore.*"
  ],

使用

"Method '.*.' has the same with.*",

(注意.*.)会使警告消失,但我不知道是否有副作用或其他后果,例如隐藏了可能希望得到通知的警告.有人以前曾见过通配符扩展吗?在将更多内容添加到config.json

(note the .*.) makes the warnings go away but I have no idea if there are side-effects or other consequences like hiding warnings that I might do want to be notified of. Is there anyone who has seen wildcard expansions like that before? Would be great to be able to look it up and study it before adding more to my config.json

推荐答案

基于配置文件中的示例,您应该只在双引号内使用标准正则表达式.不要使用/regex/replace/options的Perl样式. config.json由用C#编写的OmniSharp服务器读取,因此,如果您想对正则表达式进行任何花哨的操作,请确保它们与C#兼容.

Based on the examples in the config file, you should just use standard regex inside double quotes. Don't use the Perl style of /regex/replace/options. config.json is read by the OmniSharp server, which is written in C#, so if you're looking to do anything fancy with your regexes, make sure they're C#-compatible.

例如,您的正则表达式示例如下所示:

So, for instance, your example regex would look like this:

"(Method)\s'\w+'\shas the same with\s'\w+'"

这篇关于Omnisharp如何在其配置文件中使用通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 01:17