Eggins.com
Powershell, .Net, Visual Studio, Team Foundation Server, Windows Communication Foundation

Count the number of properties, methods, events, etc on all types in all assemblies loaded into Powershell

While writing my earlier blogs on loading assemblies and finding types, I was playing around with the functions that allow me to count the total available members on all types in all loaded assembles. This may not be of great use, but it is interesting nonetheless.

So this command will show the total number of members  (properties, methods, events, etc) that are available on all of the assemblies loaded into Powershell.
  ([Threading.Thread]::GetDomain().GetAssemblies() |
    Foreach-Object {$_.GetTypes()} |
      Foreach-object {$_.GetMembers()}).Count

In my case there are 164,697.

And this command will show the total number of methods that are available on all of the assemblies loaded into Powershell.
  ([Threading.Thread]::GetDomain().GetAssemblies() |
    Foreach-Object {$_.GetTypes()} |
     Foreach-Object {$_.GetMembers()}).Count

In my case there are 116,574.

And If I run my commands from here which loads all of the assemblies in the GAC, and run the GetMembers command above, I now have a total of 545,413 members!

Hmm, I wonder if I can commit them all to memory before my next interview Smile


Posted May 30 2007, 09:20 PM by David
Filed under:

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Copyright eggins.com, 1998 - 2008
Powered by Community Server (Non-Commercial Edition), by Telligent Systems