Search code examples
.netportable-class-library

How to understand which types will be available depending on supported platforms?


I'm converting my library to PCL. But I do not understand how available types depend on selected platforms.

With these settings:
enter image description here

I have fewer availabel types as with such configuration:
enter image description here

How is it possible?
Is there any service where I can see types and operations added|removed depending on selected options?


Update

As far as I understood there is some naming confusion.
Initially the term Portable Class Library related to these platforms: .NET Framework, Silverlight, Windows Phone and Xbox 360. At least documentation says so.
But in the next version they added Windows Store Applications. And here are some strange things.

How it looks for ICommand:
enter image description here

..for Type.IsInstanceOfType():
enter image description here

Wait! Wher is Windows Store? Why is it a separate line? If PCL includes Windows Store how can't WSA support this functionality?

One moew oddity: If I have .NET 4.5, SL5, WP8 and WSA enabled Type.IsInstanceOfType() exists and is accessible. But if I disable SL5 this method vanishes as it never was there. How on earth can that be?


This SO anwser may be helpful.


Solution

  • A few months ago, Vagif Abilov released his project pclanalyzer on Github. This tool allows you to scan an existing .NET class library or executable and identify which methods are available in a specific Portable Class Library configuration.

    The tool uses the information in this Excel file, listing all PCL compatible classes, methods, properties etc., and in which framework each one is available.

    You can read more about Vagif's tool on his blog. If you do not want to build the tool yourself, Vagif has also provided binaries here.

    EDIT

    As to your specific concerns about the Type.IsInstanceOfType()method being present when you include Silverlight 5 among the targets, while missing if you omit SL5, I do not have any definite answer. I can only make the observation that the combination with SL5 is identified as PCL profile 158, which is compatible with Visual Studio 2010, whereas the combination without SL5 is denoted as PCL profile 78 and is not compatible with VS 2010. For some reason the Type.IsInstanceOfType() must have been left out of profile 78. On the other hand, this profile seems to support a lot other functionality; you might want to take a look at the respective contents of these folders to get a better feeling for which assemblies the respective profiles support:

    • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.5\Profile\Profile78
    • C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETPortable\v4.0\Profile\Profile158

    Right out of my head I cannot say what a replacement implementation of Type.IsInstanceOfType() would look like, but it shouldn't be too hard to come up with one, I think.