.NET 中的类总数是多少?那个数字
位于下载的 .NET 2.0、.NET 3.0 和 .NET 运行时中
3.5 SP1。
我们正在写一篇关于应用程序的科学论文
基于.NET,目前声明还有更多
超过6000个班级。但我不确定这是否正确
数字。
例如这一页 http://codebetter.com/blogs/patricksmacchia/archive/2008/08/13/net-3-5-sp1-changes-overview.aspx说明集会的数量,
名称空间、方法等,但不是类的数量。
测试平台:Windows XP 64 位 SP2,8 GB RAM。
Update 4: 我们的论文发表了!我使用 9911 作为班级数量(请参阅下面的更新 3)。该期刊是蛋白质组研究杂志 http://en.wikipedia.org/wiki/Journal_of_Proteome_Research标题是:“MSQuant,基于质谱的定量蛋白质组学开源平台 http://pubs.acs.org/doi/abs/10.1021/pr900721e”。不幸的是,该论文的全文无法免费获取,只有摘要。
Update 3:我想我现在已经非常接近解决方案了:.NET 3.5 SP1 的 9911 个公共类。在更新 1 的基础上进行扩展,我使该函数成为递归函数并对其进行了扩展,以便报告任何子文件夹及其子文件夹的类型、类和公共类的数量。
在 C:\WINDOWS\Microsoft.NET 上运行
给出 40414 种类型,仅占 0.2%参考文章 http://codebetter.com/blogs/patricksmacchia/archive/2008/08/13/net-3-5-sp1-changes-overview.aspx.
完整成绩单 http://pmortensen.eu/1/until2039-12-31/SO/dorNetAssembliesSummary.html- HTML 源是制表符分隔的,因此可以导入到
电子表格,例如OpenOffice 计算 http://en.wikipedia.org/wiki/OpenOffice.org_Calc。
以下是公共课程的细分:
Framework:
Total: 6025
v1.1.4322
0
v2.0.50727
5265
v3.0
641
v3.5
119
Framework64:
Total: 3886
v2.0.50727
3126
v3.0
641
v3.5
119
Update 2:我尝试使用 NDepend 和 CQL 建议
lextm 为 .NET 2.0 提供了 10% 以上的数字(89 个 DLL)
在 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727): 5855
类。这是在不同的系统上
程序化解决方案(见下文)。
程序:
下载 NDepend (NDepend_2_12_1_3122.zip),
通过http://www.ndepend.com/NDependDownload.aspx http://www.ndepend.com/NDependDownload.aspx
使用 7-Zip 解压
运行 VisualNDepend.exe
菜单文件/选择要分析的 .NET 程序集/
/ / 确定。
-
按“创建查询”(右下角)并输入/粘贴:
从程序集中选择类型“Accessibility”、“cscompmgd”、“CustomMarshalers”、“IEExecRemote”、“IEHost”、“IIEHost”、“ISymWrapper”、“Microsoft.Build.Engine”、“Microsoft.Build.Framework”、“Microsoft .Build.Tasks”、“Microsoft.Build.Utilities”、“Microsoft.JScript”、“Microsoft.VisualBasic”、“Microsoft.VisualBasic.Compatibility”、“Microsoft.VisualBasic.Compatibility.Data”、“Microsoft.VisualBasic.Vsa” ”、“Microsoft.VisualC”、“Microsoft.Vsa”、“Microsoft.Vsa.Vb.CodeDOMProcessor”、“Microsoft_VsaVb”、“mscorlib”、“sysglobl”、“系统”、“System.configuration”、“System.Configuration .Install”、“System.Data”、“System.Data.OracleClient”、“System.Data.SqlXml”、“System.Deployment”、“System.Design”、“System.DirectoryServices”、“System.DirectoryServices.Protocols” ”、“System.Drawing”、“System.Drawing.Design”、“System.EnterpriseServices”、“System.Management”、“System.Messaging”、“System.Runtime.Remoting”、“System.Runtime.Serialization.Formatters” .Soap”、“System.Security”、“System.ServiceProcess”、“System.Transactions”、“System.Web”、“System.Web.Mobile”、“System.Web.RegularExpressions”、“System.Web.Services” "、"System.Windows.Forms"、"System.XML" 其中 IsPublic 和 IsClass
Update 1:根据 Jon Skeet 的回答,我开发了一个
功能(如下所列)。初步结果是5265
公共类,总共12626个类,.NET有18317种类型
2.0。 mscorlib.dll 中的 802 个公共类和 678 个公共类
System.dll 中的类。这是来自 89 个 DLL 文件,其中
40 因 Assembly.LoadFrom() 失败。但我不确定我
测量正确的事物或在正确的位置。
Call:
DotNetClassCount("C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727")
功能:
Imports System.Reflection 'For Assembly
Imports System.IO 'For Path
Private Function DotNetClassCount(ByRef aBaseDirectory As String) _
As Integer
Dim classCount As Integer = 0
Dim failCount As Integer = 0 'For statistics only.
Dim folderItems As String() = Directory.GetFiles(aBaseDirectory)
Dim someFolderItem As String
For Each someFolderItem In folderItems
Dim fileName As String = Path.GetFileName(someFolderItem)
If Path.GetExtension(fileName) = ".dll" Then
Try
Dim asm3 As Assembly = _
Assembly.LoadFrom(someFolderItem)
Dim types As System.Type() = asm3.GetTypes()
Dim DLLclassCount As Integer = 0
Dim someType As System.Type
For Each someType In types
If someType.IsClass AndAlso someType.IsPublic Then
DLLclassCount += 1
End If
Next
classCount += DLLclassCount
Catch ex As Exception
'Fail silently...
failCount += 1
End Try
End If
Next
Return classCount
End Function 'DotNetClassCount()