I am extracting parts of my Simple.Data OData adapter to make a portable class library (PCL). The goal is to create an OData library available for desktop .NET platforms, Windows Store, Silverlight, Windows Phone and even Android/iOS (using Xamarin Mono). To study platform-specific PCL capabilities I used an Excel worksheet provided by Daniel Plaisted (@dsplaisted). It’s a very helpful document, but it would be much easier if I could simply point some tool to an assembly file and it would show its portable and non-portable calls.
I haven’t found such tool, so I wrote one. It’s called PCL Compliance Analyzer. Select an assembly file, set of platforms you want to target, and it will show you if the assembly is PCL compliant and what calls are not. Here are the results for Mono.Cecil (that I used to scan assembly calls):
As you can see, only about 10% of Mono.Cecil is not portable to any of the .NET platforms.
Let’s try something completely different. Here’s RavenDB.
Note that non-portable calls include calls to third-party libraries, like NLog. This is not interesting because those third-party assemblies are subject to a separate check, and it’s reasonable to limit portability compliance check to only system API. So we check “Exclude third party libraries” check box and repeat the scan. Here’s the new result:
Exclusion of third-party libs reduce the number of non-portable calls from 1642 to 674. But we are targetting all platforms (even Xbox 360), and this is perhaps not a very good idea for a NoSQL database with LINQ support. If we limit supported platforms to only .NET 4.5, we will end up with this picture:
Of course the choice of one of RavenDB files is completely random here. I just had an old project folder with files left from Rob Ashton’s workshop on RavenDB, so I used one of the assembly files to demonstrate what you can do with PCL Compliance Analyzer.
Finally, if you point it to a true PCL assembly and select right set of target platforms, PCL Analyzer will confirm that all calls are portable. Like it did in case of my Simple.OData.Client: