Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find empty methods in visual studio

How do you find all the empty methods of a specific type defined in a project? an example use case would be to find all empty Page_Load methods defined in an Asp.Net application.

like image 225
ravinsp Avatar asked Feb 15 '23 18:02

ravinsp


1 Answers

In the visual studio find-tool, set it to use Regular Expressions. Use this expression to find empty methods.

void\ .*\(*\)(\ |(\r\n))*{(\ |(\r\n))*}

To find empty Page_Load methods:

void\ (Page_Load).*\(*\)(\ |(\r\n))*{(\ |(\r\n))*}

All these approaches would work for "void" methods. For other types, you can change the expression or further generalize the expression to match any kind of return type.

like image 170
ravinsp Avatar answered Feb 19 '23 09:02

ravinsp