how many namespaces/classes are there in .NET Framework?

  • Thread starter Thread starter Hazzard
  • Start date Start date
Hello Hazzard,

Thanks for posting in the group.

You could check this web link for a complete list of them:
http://msdn.microsoft.com/library/en-us/cpref/html/cpref_start.asp?frame=tru
e

All the classes, interfaces, and value types that are included in the
Microsoft .NET Framework SDK are listed there.

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Hazzard" <[email protected]>
!Subject: how many namespaces/classes are there in .NET Framework?
!Date: Mon, 25 Aug 2003 06:23:31 -0700
!Lines: 2
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: dial-209-148-114-24.sonic.net 209.148.114.24
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52128
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!
!
!
 
here's what I get for the .NET Framework v1.1:

of the 27 modules I counted (see the list below),
136 namespaces
4051 public types
7838 total types
429 public interfaces
593 public enums
2882 public classes

=====================================
here's the full data: (csv, you can import it into Excel)

namespace name,#namespaces,public types, all types,public ifcs,all ifcs,pub
enums, all enums, pub classes, all classes
Microsoft.JScript, 3, 190, 326, 26, 26, 10, 19,154,275
Microsoft.VisualBasic, 2, 76, 122, 6, 8, 22, 32,41,74
Microsoft.VisualBasic.Compatibility, 1, 52, 76, 0, 0, 7, 9,45,59
Microsoft.VisualBasic.Vsa, 1, 8, 9, 0, 0, 0, 0,8,9
Microsoft.VisualC, 1, 10, 10, 0, 0, 0, 0,10,10
Microsoft.Vsa, 1, 20, 20, 13, 13, 4, 4,3,3
Microsoft.Vsa.Vb.CodeDOMProcessor, 1, 4, 4, 2, 2, 0, 0,2,2
mscorlib, 36, 874,1446, 124, 141, 111, 167,572,975
System, 21, 490, 842, 51, 56, 57, 95,376,641
System.Configuration.Install, 2, 14, 24, 1, 1, 1, 1,12,22
System.Data, 7, 213, 530, 15, 50, 60, 84,125,367
System.Design, 8, 188, 465, 44, 53, 8, 14,132,389
System.DirectoryServices, 1, 30, 63, 7, 7, 6, 11,17,38
System.Drawing, 6, 205, 261, 5, 6, 60, 67,128,161
System.Drawing.Design, 1, 13, 33, 0, 0, 0, 0,13,32
System.EnterpriseServices, 3, 105, 237, 19, 69, 20, 30,64,136
System.Management, 2, 77, 233, 2, 46, 11, 55,64,123
System.Messaging, 2, 53, 88, 1, 6, 17, 17,34,64
System.Runtime.Remoting, 5, 28, 194, 0, 5, 3, 16,25,173
System.Runtime.Serialization.Formatters.Soap, 1, 1, 50, 0, 2, 0,
15,1,32
System.Security, 1, 21, 41, 0, 0, 0, 2,21,38
System.ServiceProcess, 2, 30, 41, 0, 0, 8, 8,21,32
System.Web, 12, 326, 710, 20, 27, 45, 76,258,577
System.Web.RegularExpressions, 1, 15, 45, 0, 0, 0, 0,15,45
System.Web.Services, 5, 144, 294, 0, 3, 10, 16,134,271
System.Windows.Forms, 5, 648, 925, 87, 89, 104, 111,427,677
System.XML, 5, 216, 749, 6, 11, 29, 64,180,654
Total,136,4051,7838,429,621,593,913,2882,5879



=============================================
the code used to compute these numbers:

// CountClasses.cs
//
// Counts the number of classes in a selected list of assemblies for the
..NET framework.
// Uses the config file countClasses.xml to store the list of libraries to
load.
//
// to build:
// csc /target:exe CountClasses.cs
//
//
// dino chiesa
//
// Wed, 26 Jun 2002 16:35
//


using System;
using System.IO;
using System.Xml.Serialization;
using System.Reflection;

namespace dinoch.demo {

public struct TypeCounts {
public int enums;
public int interfaces;
public int classes;
public int types;
}

public struct TypeStats {
public TypeCounts Public;
public TypeCounts All;
public int Namespaces;

public void Add(TypeStats ts) {
this.Public.enums += ts.Public.enums;
this.Public.interfaces += ts.Public.interfaces;
this.Public.classes += ts.Public.classes;
this.Public.types += ts.Public.types;

this.All.enums += ts.All.enums;
this.All.interfaces += ts.All.interfaces;
this.All.classes += ts.All.classes;
this.All.types += ts.All.types;

this.Namespaces += ts.Namespaces;
}
}


[XmlType(TypeName="Libraries")]
[XmlRootAttribute(Namespace="", IsNullable=false)]
public class LibraryList {
[XmlElementAttribute("Library",
Form=System.Xml.Schema.XmlSchemaForm.Unqualified,
IsNullable=true)]
public string[] Entry;
}



public class CountClasses {

LibraryList ModuleList;
public int Verbosity= 0;


void ReadLibraryList() {
FileStream fs = new FileStream("CountClasses.xml", FileMode.Open);
XmlSerializer s= new XmlSerializer(typeof(LibraryList));
ModuleList= (LibraryList) s.Deserialize(fs);
fs.Close();
}


void Run() {

TypeStats totals = new TypeStats();

ReadLibraryList();

//produce csv for display in MS Excel
Console.WriteLine("namespace name,#namespaces,public types, all
types,public ifcs,all ifcs,pub enums, all enums, pub classes, all classes");
for (int y = 0; y < ModuleList.Entry.Length; y++) {
TypeStats mts=
DisplayNamespacesForModule(ModuleList.Entry[y].ToString().Trim());
if (Verbosity==0) {

Console.WriteLine("{0},{1,3},{2,4},{3,4},{4,4},{5,4},{6,4},{7,4},{8},{9}",
ModuleList.Entry[y].ToString().Trim(),
mts.Namespaces,
mts.Public.types,
mts.All.types,
mts.Public.interfaces,
mts.All.interfaces,
mts.Public.enums,
mts.All.enums,
mts.Public.classes,
mts.All.classes);
}
totals.Add(mts);
}


Console.WriteLine("Total,{0},{1},{2},{3},{4},{5},{6},{7},{8}",
totals.Namespaces,
totals.Public.types,
totals.All.types,
totals.Public.interfaces,
totals.All.interfaces,
totals.Public.enums,
totals.All.enums,
totals.Public.classes,
totals.All.classes);

Console.WriteLine("module count: " + ModuleList.Entry.Length);
}




private TypeStats DisplayNamespacesForModule(String moduleName) {

System.Collections.ArrayList NameSpaceList = new
System.Collections.ArrayList();
System.Collections.Hashtable NameSpaceHash = new
System.Collections.Hashtable();
Type[] types;
TypeStats ts= new TypeStats();

try {
if (Verbosity>0) Console.WriteLine("loading module '" + moduleName +
"'");
// LoadWithPartialName = loads from GAC even without version info
for the assembly
Module[] modules =
Assembly.LoadWithPartialName(moduleName).GetModules();
if (Verbosity>0) {
Console.WriteLine("Successfully loaded module '" + moduleName +
"'");
Console.WriteLine("found {0} modules in this assembly", +
modules.Length);
Console.WriteLine("looking at module '{0}'", modules[0].Name);
}

types = modules[0].GetTypes(); // only the first ? why

ts.All.types = types.Length ;

foreach (Type t in types) {
if (t.IsEnum) ts.All.enums++;
if (t.IsInterface) ts.All.interfaces++;
if (t.IsClass) ts.All.classes++;

if (Verbosity>1) {
Console.WriteLine(" {0}", t.FullName);
}

if (t.IsPublic || t.IsNestedPublic || t.IsNestedFamily) {
ts.Public.types++;
if (t.IsEnum) ts.Public.enums++;
if (t.IsInterface) ts.Public.interfaces++;
if (t.IsClass) ts.Public.classes++;
}

if ( t.Namespace != null && t.IsPublic) {
if (!NameSpaceHash.ContainsKey(t.Namespace)) {
NameSpaceHash.Add(t.Namespace,"");
ts.Namespaces++;
}
}
}

}
catch (System.IO.FileNotFoundException e1) {
Console.WriteLine("Cannot load assembly, File not found:\n \"" +
e1.FileName + "\"");
}
catch ( System.NullReferenceException e2) {
Console.WriteLine("Cannot load assembly, bad name?:\n \"" +
moduleName + "\"" + e2);
}

if (Verbosity>0) {
System.Collections.SortedList sl = new
System.Collections.SortedList(NameSpaceHash);
Console.WriteLine("Namespaces: (" + sl.Keys.Count + ")");
foreach (object o in sl.Keys)
Console.WriteLine(" " + o.ToString());

}
return ts;
}


private static void DisplayUsage() {
System.Console.WriteLine("usage::\n countClasses.exe [-v]");
}



public static int Main(string[] args) {
int verbose= 0;
if (args.Length != 0) {
foreach (string a in args) {
if (a=="-v") {
verbose++;
}
else {
DisplayUsage();
return 0;
}
}
}

CountClasses c = new CountClasses();
c.Verbosity= verbose;
c.Run();
return 0;
}
}
}


=============================================
here's the XML file I used as input:

<?xml version="1.0" encoding="UTF-8"?>
<Libraries>

<Library> Microsoft.JScript </Library>
<Library> Microsoft.VisualBasic </Library>
<Library> Microsoft.VisualBasic.Vsa </Library>
<Library> Microsoft.VisualBasic.Compatibility </Library>
<Library> Microsoft.VisualC </Library>
<Library> Microsoft.Vsa </Library>
<Library> Microsoft.Vsa.Vb.CodeDOMProcessor </Library>
<Library> System </Library>
<Library> System.Configuration.Install </Library>
<Library> System.Data </Library>
<Library> System.Design </Library>
<Library> System.DirectoryServices </Library>
<Library> System.Drawing </Library>
<Library> System.Drawing.Design </Library>
<Library> System.EnterpriseServices </Library>
<Library> System.Management </Library>
<Library> System.Messaging </Library>
<Library> System.Runtime.Remoting </Library>
<Library> System.Runtime.Serialization.Formatters.Soap </Library>
<Library> System.Security </Library>
<Library> System.ServiceProcess </Library>
<Library> System.Web </Library>
<Library> System.Web.RegularExpressions </Library>
<Library> System.Web.Services </Library>
<Library> System.Windows.Forms </Library>
<Library> System.XML </Library>
<Library> mscorlib </Library>
</Libraries>
 
Back
Top