English original:Easing into .NET Core with the Windows Compatibility Pack
One major reason to migrate from .NET to .NET Core is the latter's ability to run on Linux. But for large-scale enterprise applications, it is impossible to achieve a one-step move in place. As a result, Microsoft recommends a gradual migration approach:
This approach is theoretically feasible, but in the second step there will be obstacles because of the lack of key APIs.Windows Compatibility Pack for .NET CoreThe launch, intended to solve this problem. The Compatibility Pack is a collection of NuGet packages containing nearly 20,000 APIs designed to address the needs of web application developers for great software libraries.
The newly introduced API can be roughly divided into two categories. One is the API for Windows only, and the other is a cross-platform software library. Among them, the Windows-only APIs include:
Most of these APIs are closely related to the Windows operating system, and the corresponding Linux APIs are often designed differently.
Cross-platform software libraries include:
It should be noted that these APIs are deliberately independent of the full release of .NET Core. In response, Microsoft's Immo Landwerth gives the following explanation:
The reason for being provided as a standalone package is that (a) many APIs are provided for compatibility reasons only. In the new code, should not rely on these API; (B) a lot of API only for Windows platform. We do not want to take users to a path that makes it more difficult to migrate applications across platforms.
To make it easy to distinguish between Windows-only and cross-platform APIs, there is oneAPI Compatibility Analysis ToolAvailable. The tool can mark out those applications in the API should not continue to rely on.
You can use the same suppression options as deprecated APIs, but you can also choose to give suppression warnings for specific platforms. This tool is useful if you plan to only support your code on a specific set of platforms, such as Windows and Linux only but not macOS. To do this, you simply edit the project file and add one
PlatformCompatIgnoreAttribute, and lists all the platforms to ignore in this attribute.