1

Imagine the following: You have an external library that you want to use and it isn't documented that well. You know that there is a class "Parent" with a method Add. Add takes an Object of the interface "IChild".

How can I list all classes, especially in that library, that implement this interface? (By that I mean visually in the editor not in code)

I found some threads about this but none of them really answered my question. All of them were about listing your own implementations of an interface in your namespace (and that works fine for me).

Just to make the problem clearer: Let me take the ConfigurationBuilder from .Net core. The first thing I found about it in the internet is that I can call new ConfigurationBuilder().Add(IConfigurationSource). Then I wondered how I can get an IConfigurationSource. My next step would be to google for the documentation or some examples on this platform. But I imagine that that's not the completely right way of doing things. I think you should be able to go to IConfigurationSource, and look through classes from the ConfigurationBuilder that implement this interface so that you can find it yourself. Always googling for examples or docs can't be the only way to go.

(I use Visual Studio 2019 Community)

Fabian T.
  • 195
  • 2
  • 7
  • What you’re looking for is a . Net decompiler- have a look at these https://www.jetbrains.com/decompiler/ and https://www.microsoft.com/en-gb/p/ilspy/9mxfbkfvsq13?activetab=pivot:overviewtab – auburg Jul 02 '20 at 22:01
  • As you pointed out in the question listing classes that implement an interface is trivial task with code (and you seem to already found plenty of answers for that). To my knowledge there is no built in support for such reflection calls in VS directly. What you are asking may be interpreted as "tools recommendation" - not sure what can be done about it. – Alexei Levenkov Jul 02 '20 at 22:23
  • 1
    Does this answer your question? [How do you find all implementations of an interface?](https://stackoverflow.com/questions/620376/how-do-you-find-all-implementations-of-an-interface) –  Jul 02 '20 at 22:27
  • Use JetBrains Rider IDE, it's way better than visual studio in such cases. – Falah H. Abbas Jul 03 '20 at 00:09
  • @auburg Why do I need a decompiler for that problem? My understanding of libraries is the following: they deliver the "header" files (I don't know whats the C# word for that) and the maschine code to execute the methods and create the classes in the header file. The header files are what I can see when I take a look at some Class with peek (There I can just see the signature of the methods). A decompiler would present me what the source code could be but thats not what I want. The information about classes that implement an interface should be in these header files. Is that correct? – Fabian T. Jul 03 '20 at 06:45
  • @OlivierRogier Thats one of the threads I've looked through. It has two problems: 1. It's really old and 2. It does not answer my question. In the thread they discuss about implementations in your own source not about external libraries. – Fabian T. Jul 03 '20 at 06:48
  • @FalahH.Abbas that could solve the problem but it is the last I would do – Fabian T. Jul 03 '20 at 06:57

0 Answers0