.NET Core 2.1 and ASP.NET Core 2.1 Preview1 have just been released (see here the official announcement) and we are going to explore new APIs in this post. We’ll found out many of the new features announced in the .NET Core 2.1 Roadmap and ASP.NET Core 2.1 Roadmap on the MSDN blog.

We just released NDepend v2018.1 and we took a chance to support analysis of .NET Core 2.1 and ASP.NET Core 2.1 applications. NDepend is often deemed as the Swiss-Army Knife for .NET developers thanks to its code query language (CQLinq). CQLinq can be used to write code rules, quality gates, trend code metrics, explore dependencies or advanced code search. One thing CQLinq excels at is exploring the diff between two snapshots of a code base. Exploring new APIs is a sub-task of exploring what was changed. Let’s harness this capability to explore new .NET Core 2.1 APIs.

New .NET Core 2.1 Preview1 APIs

We could have downloaded sources files of both .NET Core 2.1.0 Preview1 and 2.0.0, recompile and then do the diff. Instead, since NDepend can analyze raw assemblies even without sources available, we compared assemblies in these two folders:

C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.0-preview1-26216-03

C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.5

Here is the CQLinq code query that lists all new public classes and types. It is also refined to match public members (methods and fields) of each new type in the result.

// <Name>New .NET Core 2.1 API Types</Name> from t in Application.Types where t.IsPubliclyVisible // we want only public API && t.WasAdded() // added since baseline (which is .NET Core 2.0.5) select new { t, publicMembers = t.Members.Where(m => m.IsPubliclyVisible), t.NbILInstructions } 1 2 3 4 5 6 7 8 9 // <Name>New .NET Core 2.1 API Types</Name> from t in Application . Types where t . IsPubliclyVisible // we want only public API && t . WasAdded ( ) // added since baseline (which is .NET Core 2.0.5) select new { t , publicMembers = t . Members . Where ( m = > m . IsPubliclyVisible ) , t . NbILInstructions }

Find the whole list here .NET Core 2.1 new public classes. Here is a first glimpse in the screenshot below. We highlighted the new great Span<T> capability.

Not only new public classes list is interesting, but also new public methods added on existing public classes. This query does list these 1.500 methods:

// <Name>New .NET Core 2.1 public methods in existing types</Name> from m in Application.Methods where m.IsPubliclyVisible // we want only public API && m.WasAdded() // added since baseline (which is .NET Core 2.0.5) && !m.ParentType.WasAdded() // in existing type select new { m, m.NbILInstructions } 1 2 3 4 5 6 7 8 9 // <Name>New .NET Core 2.1 public methods in existing types</Name> from m in Application . Methods where m . IsPubliclyVisible // we want only public API && m . WasAdded ( ) // added since baseline (which is .NET Core 2.0.5) && ! m . ParentType . WasAdded ( ) // in existing type select new { m , m . NbILInstructions }

Here also find a screenshot below and the whole list here: .NET Core 2.1 new public methods on existing public classes. For this screenshot we used the new Dark theme support of NDepend v2018.1.

Interestingly enough let’s list new namespaces that contain at least one public type:

// <Name>New .NET Core 2.1 API Namespaces</Name> from n in Application.Namespaces where n.IsPublic // We want namespaces that contain at least one public type && n.WasAdded() // added since baseline (which is .NET Core 2.0.5) select new { n, publicTypes = n.ChildTypes.Where(t => t.IsPublic), n.NbILInstructions } 1 2 3 4 5 6 7 8 9 // <Name>New .NET Core 2.1 API Namespaces</Name> from n in Application . Namespaces where n . IsPublic // We want namespaces that contain at least one public type && n . WasAdded ( ) // added since baseline (which is .NET Core 2.0.5) select new { n , publicTypes = n . ChildTypes . Where ( t = > t . IsPublic ) , n . NbILInstructions }

New ASP.NET Core 2.1 Preview1 APIs

To analyze ASP.NET Core assemblies it was a bit more difficult than just comparing assemblies in 2 folders. ASP.NET Core assemblies are stored in NuGet packages so we did explore assemblies in the folder C:\Program Files\dotnet\sdk\NuGetFallbackFolder and then tinker a bit to get the wanted versions in both 2.1 and 2.0 cases.

Let’s use the same code query to match ASP.NET Core 2.1 new public classes :

The same way here is the ASP.NET Core 2.1 new public methods on existing public classes :

And finally, here are the new ASP.NET Core 2.1 namespaces that contain at least one public classes.