Is there a refactoring available to Refactor Static Methods to Extension methods using Visual Studio 2019 C#? for example I have .string;IsNullOrWhiteSpace( xxx );
in too many places, (1000+ ), I would like to refactor to the extension Method xxx.HasValue();
instead.
Edit: PS: I have the extension method bool HasValue(this string);
, just that everywhere in the code people have used .string.IsNullOrWhiteSpace
So now you want to replace all .string.IsNullOrWhiteSpace(str)
with str.HasValue()
? Maybe you can use regex to achieve it.
Press Ctrl + F
to open Find&Replace
and check Use Regular Expressions
Next, input (.string?IsNullOrWhiteSpace\((.<name>".*")\))
into Find...
,
and ${name}.HasValue()
into Replace...
.
Then click Replace All
.
For more info, you can refer to Use regular expressions in Visual Studio .
Not sure if this is what you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.