Page 66 - MSDN Magazine, December 15, 2017
P. 66
Figure 3 API Port Results for Fabrikam.Shared
What’s in the Compatibility Pack?
The Windows Compatibility Pack is represented by the Microsoft.Windows.Compatibility NuGet package and contains about 40 components (see Figure 4 for the full list).
Given that .NET Framework was designed for Windows, about half of the compatibility pack is Windows-only as it depends on or wraps Windows technologies. But, as discussed earlier, the first step in migrating an existing .NET Framework code base should be to move to .NET Core but remain on Windows. For that step, not being able to use Windows-only technologies would just be a migration hurdle with zero architectural benefit.
If you want to migrate to Linux, the next step would be to assess how many tech- nologies you’re depending on that work only on Windows. You’ll either replace those with cross-platform technologies (for example, replacing EventLog with TraceSource), separate them (for example, separating ActiveDirectory lookup logic from your authentication and authori- zation code), or guard the calls behind a platform check (for example, reading the registry only if you’re on Windows).
To assist in that process, we’ve designed Microsoft.Windows.Compatibility as a meta package, which means it doesn’t contain any libraries itself but simply references other NuGet packages. This allows you to quickly add references to
the full list of components without having to install dozens of pack- ages. However, as you’re migrating and removing dependencies on legacy technologies, it can be useful to reference only the compo- nents you need and remove the ones you’ve migrated away from to make sure new code doesn’t take a dependency on them again.
Using the Compatibility Pack
Let’s look further at Fabrikam’s Asset Management system. The infrastructure and business logic component needs to be shared between .NET Framework and .NET Core, which is why the com- pany plans to convert it to target .NET Standard. After converting
Figure 4 Available and Upcoming Components in the Windows Compatibility Pack
Component
Status
Windows-Only
Component
Status
Windows-Only
Microsoft.Win32.Registry
Available
Yes
System.Management
Coming
Yes
Microsoft.Win32.Registry.AccessControl
Available
Yes
System.Runtime.Caching
Coming
System.CodeDom
Available
System.Security.AccessControl
Available
Yes
System.ComponentModel.Composition
Coming
System.Security.Cryptography.Cng
Available
Yes
System.Configuration.ConfigurationManager
Available
System.Security.Cryptography.Pkcs
Available
Yes
System.Data.DatasetExtensions
Coming
System.Security.Cryptography.ProtectedData
Available
Yes
System.Data.Odbc
Coming
System.Security.Cryptography.Xml
Available
Yes
System.Data.SqlClient
Available
System.Security.Permissions
Available
System.Diagnostics.EventLog
Coming
Yes
System.Security.Principal.Windows
Available
Yes
System.Diagnostics.PerformanceCounter
Coming
Yes
System.ServiceModel.Duplex
Available
System.DirectoryServices
Coming
Yes
System.ServiceModel.Http
Available
System.DirectoryServices.AccountManagement
Coming
Yes
System.ServiceModel.NetTcp
Available
System.DirectoryServices.Protocols
Coming
System.ServiceModel.Primitives
Available
System.Drawing
Coming
System.ServiceModel.Security
Available
System.Drawing.Common
Available
System.ServiceModel.Syndication
Coming
System.IO.FileSystem.AccessControl
Available
Yes
System.ServiceProcess.ServiceBase
Coming
Yes
System.IO.Packaging
Available
System.ServiceProcess.ServiceController
Available
Yes
System.IO.Pipes.AccessControl
Available
Yes
System.Text.Encoding.CodePages
Available
Yes
System.IO.Ports
Available
Yes
System.Threading.AccessControl
Available
Yes
62 msdn magazine .NET