I have a general method
public void Foo<T>(T arg) where T : ISomeInterface
This method is used quite a lot in the whole code, and I want to find where it is used when T is a specific type.
I can text-search for
"Foo<TheType>("
but most often the type argument was excluded from the call (inferred). Is there a way to find these method calls in VS2010 or maybe ReSharper?
In the next version of ReSharper, this will be covered by the Search With Template feature. http://youtrack.jetbrains.net/issue/RSRP-288080
You could get a compiler to help you find them using the old break-it-and-see-what-doesn't-compile method: if type T is your own code, try changing it so that it no longer implements ISomeInterface.
Run the build through ildasm and find the appropriate method signature, then reverse the operation through disassembly to get the source file and line number.
I tried to execute the ReSharper search pattern (ReSharper-> Tools-> PatternCatalog-> Add Pattern):
Search Pattern: Foo ($ arg $)Placeholder: arg = expression that is of type TheType
Then save it and click "Find Now."
Temporarily declare a non-generic method and find its use.
public void Foo(TheType arg) { }
After the declaration, the preferred method instead of the general one.
As you already mentioned, you can use text search for " Foo<TheType>( " and " Foo(TheType ", where it is displayed
Foo<TheType>(
Foo(TheType
Source: https://habr.com/ru/post/907204/More articles:When I click on another cell with a different value, the background color turns black in the DataGridView text box - c #Has anyone ever come to read or write the top for an Amazon S3 bucket? - cloudCreating a program logic log - javaCassandra - how to get all the keys in CF (Random Partitioner) - cassandraRetrieving all resources with a name starting with 001XXX.jpg - iosGetting all keys using the Cassandra API - analogy to "SELECT id FROM table"; - cassandraLess.js not working with CDN? - javascriptXMLHttpRequest origin not allowed Access-Control-Allow-Origin - javascriptAVplayer completely removes video from memory - iosHow to convert 'long long' (or __int64) to __m64 - visual-c ++All Articles