How I can find all extension methods in solution ?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
I'd look at the generated assemblies using reflection; iterate through the static types looking for methods with
[ExtensionAttribute]
...If I were doing it I would search all files for the string "( this " -- your search string may differ based on your formatting options.
EDIT: After a little bit of experimentation, the following seems to work for me with high precision using "Find in Files" (Ctrl-Shift-F)
\( this [A-Za-z]
" (minus quotes, of course)Solution wide text search with a regex matching your coding style. Something like
"( *this +"
(added the first optional space to get some error tollerance).Do you just want to check the sourcecode (just look for
(this ...
in the files) or your running programm by reflection (in this case, this this discussion can help you)?Maybe the code in this article about how to find extension methods targeting object could be used? Could for example be rewritten slightly and use it to dump all extension methods instead of just those targeting
object
.