Application tool. NET Portability Analyzer analysis and migration of dotnet core, portabilitydotnet
Most developers prefer to write business logic code at one time and reuse it later. This method is easier than building different applications for multiple platforms. If you create a. NET standard library compatible with. NET Core, it is closer to this reality than ever before.
But what about the existing. NET Framework library? How much does it take to make these cross-platform compatibility and convert them into. NET standard libraries? Use the. NET Portability Analyzer tool for analysis. Using several simple technologies and modifying project files helps simplify this process.
The. NET Portability Analyzer tool is a Visual Studio extension created by the. NET Framework Team. You can use this tool with any latest version of Visual Studio that supports expansion. By directing Portability Analyzer to your assembly or project, the tool provides summaries, detailed reports, and recommendations for the APIS you should use to improve compatibility. For projects, this tool lists error messages and forwards you to the code lines to be changed.
. NET Portability Analyzer contains a same-level console application called API Portability Analyzer (which you can download from the https://github.com/Microsoft/dotnet-apiport/releases) that generates results similar to those generated by Portability Analyzer. In this article, I will focus on how to use Visual Studio extensions.
Set
For databases to be used across platforms, it should be properly decomposed and contain most of the business logic. UI code should be isolated from other projects. However, because. NET Core is a subset of. NET Framework, your library may be using APIs not supported in. NET Core even if your code is properly decomposed.
In some cases, there is a backup API that can do the same thing. In these cases, Portability Analyzer recommends using a backup API. In other cases, there is no API to replace and you need to break down platform-specific code. Finally, you can use Portability Analyzer to perform a quick evaluation even if you do not know the Assembly decomposition.
This extension supports Visual Studio 2013 or 2015. The next step is to install the extension. Search for. NET Portability Analyzer in the Visual Studio library or download the installation directly from the https://visualstudiogallery.msdn.microsoft.com/1177943e-cfb7-4822-a8a6-e56c7905292b.
Click "Download" and select "open ". In the next dialog box, you can select the Visual Studio version to which the extension is applied. Click "Install" to start the installation, and then click "close" to exit the dialog box. Now you can select your target platform and analyze the assembly or project.
Select Target Platform
By default, Portability Analyzer provides results for. NET Framework,. NET Core App,. NET Standard, ASP. NET Core, Mono, and Windows Phone. You can use the following steps to specify other options: access the. NET Portability Analyzer entry in the tools | Options menu of Visual Studio and select the platform set you want to target
Run Portability Analyzer
You can use either of the following methods to analyze a dataset or project:
- To analyze a built assembly or executable file, access Portability Analyzer from the analysis menu of Visual Studio and browse to the Assembly location. With this option, the tool generates a summary and a detailed report.
- To analyze a project, right-click the target project in Solution Explorer. Select "analysis" | "analysis Assembly portability, which is specific to the project you selected. With this option, the tool generates a summary, detailed report, and outputs the message to the error list that provides the file name and the row where the problem occurred. You can also double-click each message, and then the tool will navigate you to the specified code line.
To test the tool, I chose one. NET 4.5.2 project, test.. NET Core compatibility, Portability Analyzer allows me to view what I need to do without actually converting the project, changing the target, and trying to solve compilation errors.
I ran the tool and the results were encouraging.Displays the abstract, detailed report, error message, and report URL. According to the summary, I found that my library is very compatible with all of these platforms.
The detailed results show only one or more APIs not supported by the target platform in a spreadsheet-like format. You can easily Scan details. They are marked with a red X to indicate the locations that do not support the API, while the green mark indicates support. It is worth noting that the APIS supported by each platform without any reconstruction are not listed in this report.
The details also include the recommended change content column, which points to the standby API that can work across multiple platforms. At the bottom of the details, the report contains the "return to summary" link. This will navigate back to the summary at the top. Although my results are very short, the "Back to Top" function is very useful for long reports.
Since I have analyzed a project, my report contains the "Error List" message indicating the file and the row number used. If you click the message, the tool forwards it to the file and row specified in the message.
If you want to access these results outside Visual Studio, you can find these results in the HTML file (ApiPortabilityAnalysis.htm) in the same project directory as the target assembly. This location is specified in the URL section at the top of the report
In addition to this tool there is also an online analysis tool https://icanhasdot.net/, just put your project'spackages.config
,project.json
AndWhen the paket. dependencies file is uploaded, the website will show you whether the. NET Core of the third-party library on which your project depends already has a supported library.
Summary
Portability Analyzer not only helps me quickly evaluate what I need to do so that my library can be used across platforms, I also realized all platform-specific issues from my code to method calls and attribute usage. Which of the following Backup APIS is recommended to use to analyze whether the dependent third-party libraries are supported by. NET Core through online tools.