How to find out the list of types in the base class library that implement a specific interface?

Sometimes I want to know a list of all the standard .NET types that implement a particular interface. This is usually out of curiosity, sometimes there are some practical goals (but this is not so).

I tried to get this from MSDN, but on the type page there are only links to child types of types, not types that implement the interface.

Do you know any trick how to do this (or a tool that will help)?

I wrote this code ( ICollection- the type being investigated):

        var result =
            from assembly in AppDomain.CurrentDomain.GetAssemblies().ToList()
            from type in assembly.GetTypes()
            where typeof(ICollection).IsAssignableFrom(type)
            select type;

        foreach (var type in result)
        {
            Console.Out.WriteLine(type.FullName);
        }

But this has some limitations:

  • It searches only the currently loaded builds.
  • I could not figure out how to do this for generic interfaces ( ICollection<>not working).
  • , MSDN ( , ).

!

+3
1

.

" ", : .NET.

, (ICollection < > )

:

from assembly in AppDomain.CurrentDomain.GetAssemblies()
from type in assembly.GetTypes()
where type.GetInterfaces()
          .Any(i => i.IsGenericType
                 && i.GetGenericTypeDefinition() == typeof(ICollection<>))
select type;

, MSDN.

.NET Reflector , ( " " ), MSDN ( "Search MSDN" ).

, , , -, - MSDN . , - , MSDN .

+2

All Articles