Pattern Catalog Wishlist

This seems to me to be like a great idea, but the current implementation has
so many limitations that in every instance I've tried to use it, I've been
unable to.

The first instance I've already posted about... I want to flag every single
use of "" as a warning to replace with string.Empty ... but ONLY within
method bodies (not in attributes).

I would also like to be able to flag any use of string.Format() that doesn't
pass the CulturInfo argument (for fixing code analysis warnings related to
globalization/internationalization).  But there's no way to construct a
'pattern' that isn't a complete statement that seems to match anything.
Since Format() has a variable number of parameters... I can't figure out how
to construct it.  I'd like to just do something like this:

Flag:  string.Format($strexp$,

Replace with: string.Format(CultureInfo.InvariantCulture, $strexp$,

Note the incomplete expression... I can't think of a reason why it shouldn't
work.  But if for some reason that won't work, then allowing a "..."
placeholder in order to be able to just say "everything else" would be nice.
Something.  Anything.

Additionally, I'd like to offer multiple "replace with" options (so the user
can select InvariantCulture or CurrentCulture, as appropriate in the
context).

On this last point, could ReSharper itself add this functionality without
requiring individual developers to add a pattern (once patterns support it)?
Since it's one of the most common warnings I see when running Code Analysis
in Visual Studio, it'd be nice if ReSharper could just flag all the uses of
string methods that don't include the CulutureInfo parameter, and offer a
quick fix or two, to easily add either Invariant or Current Culture.



Please sign in to leave a comment.