.NET is big, very big! So how many API's does it have? Let's find out!
The trigger
Some time ago (almost 5 years ago) there was a nice article on the GitHub repository of .NET and they stated:
We started in .NET Core 1.0 with a very minimal API set that only included ~18K of the .NET Framework APIs. With .NET Standard 2.0, we tried to make it much more viable to share code between .NET Framework, .NET Core, and Xamarin which resulted in approximately 38K .NET Frameworks APIs being available in .NET Core 2.0. We also built the Windows Compatibility Pack which made another 21K .NET Framework APIs available to .NET Core, resulting in almost 60K additional APIs. And in .NET Core 3.0 we added WPF and WinForms, which increased the number of .NET Framework APIs ported to .NET Core to over 120k, which is more than half of all .NET Framework APIs.
Source: https://github.com/dotnet/announcements/issues/130
120k API calls overall! Wow - that's a lot! It is up to you to decide whether or not that is something good or not. But what is the current state? Well - that isn't that easy to answer because Microsoft (to my knowledge) doesn't publish those numbers.
Let's check ASP.NET Core
We can start very simple: With ASP.NET Core. Why? Because they offer files called PublicAPI.Shipped.txt
(for example here) for each of their modules (like MVC, WebAssembly Components, Endpoints, ...). A public API is either a method, property or class that is somewhat publicly available. So basically almost everything that is accessible from user code (public
, protected
and so on). If a method has 2 overloads like Equals(object o)
and Equals(MyObject o)
it will count as two API calls. An enum
with 10 values will count as 10 API calls. A property with a public getter and setter would count as two API calls. Just that you get a picture.
I used the following command to get the total amount of API calls for ASP.NET Core (in the root of the repository):
find . -name "PublicAPI.Shipped.txt" -exec wc -l {} +
It basically counts the lines of all PublicAPI.Shipped.txt
files in the repository. Now the numbers I present are not 100% accurate and should give you only a rough idea of the size of the API.
For example, every PublicAPI.Shipped.txt
file contains nullability information (one line per file) and sometime an empty end line. So that could mean if you have 50 files, it would "inflate" the result by 100. But again, we are talking ball park numbers.
Version | # Public API's |
---|---|
3.1.32 | 4700 |
6.0.31 | 26000 |
7.0.20 | 26100 |
8.0.6 | 27100 |
9.0.0* | 27600 |
*For the 9.0 preview I included the PublicAPI.Unshipped.txt
files as well, because this is how public API works. The API of a preview is technically not shipped yet, therefore you wouldn't see any difference.
Of course 9.0.0 is the current preview version and the numbers might change. But it gives you a rough idea of the size of the API. 27k things like classes, structs, interfaces, enums and so on. That is a quite a number, but we can go bigger!
1637718
That is the number of total API's across all .NET Versions (including .NET Core, .NET Framework, Xamarin, ...) and Frameworks (like ASP.NET, WPF, WinForms, ...). The source for this "small" number is: https://apisof.net/
It basically lists all API's and gives you even the possibility to diff between versions and frameworks. So if you are interested in a specific API, you can look it up there. Of course not everything is public, but imagine only 20% being publicly available - that would still be a whopping 330k API's (across all versions and frameworks).
So yes, .NET is big! Very big! And it is growing. I look forward of finding better ways to count the API and maybe even get a more accurate number. But for now, this is what I have.