In this article, I will try to do a portage of PayPal .NET SDK to both .NET Core and .NET Standard. I took the PayPal .NET SDK as a good sample to analyze the level of the portability. There is a useful extension for Visual Studio .NET Portability Analyzer.
What is the PayPal .NET SDK?
The PayPal .NET SDK makes it easy to add PayPal support to your .NET web application and is built on PayPal's REST APIs.
NOTE: Before using this SDK, please be aware of the existing issues and currently unavailable or upcoming features for the PayPal REST APIs.
First, I go the Visual Studio main menu, select Tools then Options. After that, I choose the target platforms : .NET Core and .NETPlatform.
What is the .NET Standard?
The .NET Standard Library is a formal specification of .NET APIs that are intented to be available on all .NET runtimes. The motivation behind the Standard Library is establishing greater uniformity in the .NET ecosystem.
Why should you use the .NET Standard?
The .NET Standard Library enables the following key scenarios:
- Defines uniform set of BCL (Base Class Library) APIs for all .NET platforms to implement, independent of workload.
- Enables developers to produce portable libraries that are usable across .NET runtimes, using this same set of APIs.
- Reduces and hopefully eliminates conditional compilation of shared source due to .NET APIs, only for OS APIs.
After the target platforms configuration, you select the project and select the Analyze in the main menu. You click on the Analyze Assembly Portability. Then, you have to select you dll file. Here I suppose you did a build for your selected project. And in a few seconds, you will get a nice report for the portability process.
This report encouraged me to do the portage. So, I create a new .NET Cor Class Library project. Then I copied all the project files from PayPal.SDK.NET451 solution to PayPal.SDK.NETCore. Unfortunately, I go a lot of errors when I did compilation. This was posted as an issue on the github repository of PayPal .NET SDK.