How does Omnisharp use wildcards in its config files?

梦想的初衷 提交于 2019-12-08 11:44:47

问题


Background

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.

The question

What wildcard/regexp characters work here and how? Is it perhaps a known standard with its own docs somewhere that I can read?

Example

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.

More details

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.*"
  ],

EDIT: Using

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

(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


回答1:


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+'"


来源:https://stackoverflow.com/questions/34706847/how-does-omnisharp-use-wildcards-in-its-config-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!