Reputation: 13983
I'm converting my library to PCL. But I do not understand how available types depend on selected platforms.
With these settings:
I have fewer availabel types as with such configuration:
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
:
..for Type.IsInstanceOfType()
:
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.
Upvotes: 0
Views: 194
Reputation: 5772
First things first, just because something is available in portable, does not make it available in all platforms that support portable. For example, MEF (System.ComponentModel.Composition.dll) is available when targeting Silverlight and .NET Framework, but add Windows Store or Phone to your targeted platforms, and it disappears because it is not supported on those platforms.
However, in saying that, what you are seeing above, is the leaky abstraction between the legacy surface and new surface as called on this page: What is .NET Portable Subset (Legacy)?.
In the new surface area, the System.Reflection surface area (including System.Type) has changed from the old surface area. Some functionality has been changed, moved or completely removed. Most members that were on Type have been replaced with functionality on TypeInfo. You can go from a Type -> TypeInfo by adding a using statement "using System.Reflection", and then calling GetTypeInfo.
If Windows Store doesn't have the old APIs, when why does it show up in portable in some situations when including Windows Store? Windows Store "implicitly" supports these APIs. It doesn't expose them at build time when targeting just Windows Store, but we guarantee that these APIs are available at runtime.
Upvotes: 2
Reputation: 15971
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:
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.
Upvotes: 3