I know there is no different between string
and String
in C# (except for the using System
that is added for System.String
). Still, same like in this SO-answer, I'd prefer to use string with a lowercase s
as type, and String with an uppercase S
when I call a String.SomeMethod (for example String.IsNullOrWhitespace(...)
; String.Format(...)
or String.Empty
.
I know I can add custom patterns in ReShaper using Visual Studio RESHARPER menu
-> Option
-> Code Inspection
-> Custom Patterns
-> Add pattern
. I've added the following custom pattern:
- Search pattern:
string.$method$
- Pattern severity:
Show as suggestion
- Match similar constructs:
Unchecked
- Search Description:
Check if string.SomeMethod is used instead of String.SomeMethod
- Replace pattern:
String.$method$
- Format after replace:
Checked
- Shorten reference:
Unchecked
- Replace Description:
Use String instead of string
On a line like string.IsNullOrWhitespace(...)
it does indeed give the suggestion and replaces it correctly to String.IsNullOrWhitespace(...)
. The problem however, is that it now also gives the suggestion when it's already correct or after I've replaced it. So is it possible to make the Search pattern case-sensitive? So it will only give the suggestion at string.SomeMethod
, instead of also at String.SomeMethod
?
EDIT: Also, is it possible to have an option to apply it to the entire project/solution, similar to the warning Remove unused directives in file
-> Remove unused directives in solution
(in v8.0 or higher)?