BT

Easing into .NET Core with the Windows Compatibility Pack

| by Jonathan Allen Follow 523 Followers on Dec 12, 2017. Estimated reading time: 2 minutes |

A major reason for switching from .NET to .NET Core is the ability to run on Linux. But for large enterprise applications, performing a migration in a single step isn’t feasible. For this reason, Microsoft recommends an incremental transition:

  • Migrate to ASP.NET Core (while still targeting the .NET Framework)
  • Migrate to .NET Core (while staying on Windows)
  • Migrate to Linux
  • Migrate to [Linux hosted on] Azure

While that sounds good in theory, the lack of mission critical APIs can still prevent projects from making it to step 2. Which is where the Windows Compatibility Pack for .NET Core comes into play. Encompassing 20,000 APIs, this collection of NuGet packages intends to address the outstanding library needs for web app developers.

The newly ported APIs are roughly divided into two categories: Windows-only and cross platform. The Windows-only APIs include:

  • Active directory
  • Cryptography
  • Event logs and performance counters
  • File system security
  • Named pipes
  • Registry Access
  • Windows Services

For the most part these are deeply linked to the Windows operating system, with the Linux equivalents are often fundamentally different in design.

The cross-platform libraries include:

  • Caching
  • ConfigurationManager (i.e. processing legacy app.config/web.config files)
  • DatasetExtensions (used for database access without an ORM)
  • ODBC database access
  • System.Configuration.ConfigurationManager (MEF v1)
  • System.Drawing
  • System.IO.Packaging (used for interacting with MS Office style Zip files)
  • System.ServiceModel (i.e. WCF)

It should be noted that these APIs are being intentionally omitted from the full .NET Core distribution. Immo Landwerth of Microsoft explains,

The reason it’s a separate package is because (1) many of the APIs are provided for compatibility reasons only. New code shouldn’t depend on them (2) many of the APIs are Windows-only. We don’t want to lead you down a path that makes a cross-platform evolution of your app harder.

In order to make it easier to distinguish between Windows-only and cross-platform APIs, an API compatibility analyzer can be used to flag APIs that applications should no longer rely on.

You have the same suppression options as with deprecated APIs but you also have the option to suppress warnings for specific platforms. This is useful if you’re only planning to support your code on a specific subset of platforms (e.g. only Windows and Linux, but not macOS). To do so, you just need to edit your project file and add a property PlatformCompatIgnore that lists all platforms to be ignored.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT