The following C# method will list all IDisposable types found in a certain assembly. (Used namespaces: System, System.Collections.Generic, System.IO, System.Reflection)
static void PrintDisposableTypesFromFile(String path)
{
Assembly assembly = Assembly.LoadFrom(path);
foreach (Type type in assembly.GetTypes())
if (type.GetInterface("IDisposable") != null)
Console.WriteLine(type.FullName);
}
The following C# method makes use of the previous one to do the same for all assemblies in a directory and its subdirectories, e.g. "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727":
static void PrintDisposableTypesFromDirectory(DirectoryInfo dir, bool warn)
{
foreach (FileInfo file in dir.GetFiles("*.dll"))
{
try
{
PrintDisposableTypesFromFile(file.FullName);
}
catch (Exception ex)
{
if (warn)
{
Console.Error.WriteLine(
String.Format(
"WARNING: Skipped {0}: {1}",
new object[] { file.FullName, ex.Message }));
}
}
}
// recurse
foreach (DirectoryInfo subdir in dir.GetDirectories())
PrintDisposableTypesFromDirectory(subdir, warn);
}
I'm not sure the list of all disposables is very useful, but I've used similar code to find other interesting things like the full list of text encodings supported by the .NET framework.