Is there any way to make a ReSharper SSR pattern context sensitive
I have a (very simple) pattern - "" (two double quotes)
Replace with string.Empty
Unfortunately, but unsurprisingly, it highlights every occurrence.
Is there any way to create a pattern that identifies, in this case, non-const occurences?
Please sign in to leave a comment.
Hello Rachel
Could you please provide us with some samples of occurences which shouldn't be matched?
Thanks!
Alexander,
I know, you know, and, of course, the compiler knows when a constant must be used. I just wish to change the others. However, I can't do a global change/replace due to legacy requirements, but going forward we need to highlight the usages, and correct.
When used as default in Optional parameters - has to be a constant.
Likewise, in an attribute. e.g. [DefaultValue("")] should not match - if I apply the fix e.g. [DefaultValue(string.Empty)] - won't compile - "Constant expression is required"
Hope this helps
Rachel
Rachel, thanks for the reply!
I filed a new feature request to YouTrack https://youtrack.jetbrains.com/issue/RSRP-441725. Feel free to comment and vote for it.
Unfortunately, right now there is no way to get desired behavior.
Thanks!