Determining Portable Class Library compatibility
| CommentsRecently I embarked on porting the TagLib# library to a Portable Class Library (PCL). In my efforts I noted some frustration I had of the “convert and compile” flow to find issues. Well, turns out I didn’t have to do that much pain as pointed out by Daniel in the comments! The .NET team has released a tool to help out us developers called the API Portability Analyzer (currently in Alpha). This tool basically looks at any existing .NET assembly and gives you a report to help you see where the APIs used are supported in the various .NET profiles available.
The tool is a single command-line exe and is as simple as launching:
ApiPort.exe path-to-your-assembly-file.dll
I recommend putting this in your path somewhere so you don’t have to remember the full path to launch. The output from the console tells you very little and only really about what you it is doing:
Microsoft (R) API Portability Analyzer version 1.0 (alpha) Copyright (C) Microsoft Corporation. All rights reserved. To learn more about how this tool works, including the data we are collecting, go here - http://go.microsoft.com/fwlink/?LinkId=397652 Identifying assemblies to scan. Done in 0.01s. Detecting assembly references. Processed 1/1 files.Done in 0.23s. Sending data to service. Done in 2.88s. Computing report. Processed 508 items.Done in 0.02s. Writing report. Done in 0.17s. Replaced output file "c:\ApiPortAnalysis.xlsx"
You may notice that the tool says ‘sending’ and yes, it is communicating with a public service. The team notes this in the download:
NOTE: During the process of identifying the .NET APIs used by a binary Microsoft collects the list of .NET APIs used by the user submitted binaries. Microsoft also collects the names of various user created APIs. The tool does not collect the binary code, only names of APIs are collected. Microsoft will also collect assembly information such as assembly references for the binary & the Target Framework Moniker (TFM).
The real value is in the output data conveniently formatted into a pre-filterable Excel document. The process was fairly fast for me, but I suspect might take longer for larger libraries (duh). An example of the output is like the one here directly showing the TagLib# data that I used above.
If you read my previous post you will see that the areas I had frustrations about are clearly identified in the Unsupported columns for my target platform. The tool attempts to recommend some alternatives when it can. I can imagine this gets better over time as the recommendations for TagLib# were only two, whereas it should have provided recommendations for XmlDocument/XmlElement/etc. to the XLINQ equivalent areas.
In the end though, this is a helpful tool for those looking to convert. I wish I had known about it in advance, but now that I know it is in my toolbox and my PATH!
Hope this helps!
Please enjoy some of these other recent posts...
Comments