[Bug] Portable Class Library compilation gets broken when a target is _removed_
Filing on behalf of @dsaf from https://github.com/dotnet/coreclr/issues/2651:
Steps to reproduce:
- Create a new PCL project targeting .NET 4.5, Win 8 and SL 5 (Profile47)
- Change
Class1.csto following code (notice it compiles):
public class Class1
{
private void Test()
{
IConvertible test;
}
}
-
Disable SL 5 target in project settings, notice a message "The following will be automatically targeted because they support the same set of portable APIs: ASP.NET Core 5.0". Project changes to Profile7
-
Compilation is now broken: "CS0246 The type or namespace name 'IConvertible' could not be found (are you missing a using directive or an assembly reference?)"
The code could be relying on value types inheriting IConvertible as well, so it needs the interface. There are likely to be other similar breaking changes around Reflection APIs.
Effectively there seems to be a bug in some piece of code that tells that a set of portable APIs is common when in fact it is not. I don't know where it is: in PCL profile configuration, Visual Studio or .NET Framework.
Removing a target should not be a breaking change.
@Pilchie This is a PCL VS experience issue. Essentially switching from old-style portable to new-style portable which does cause some APIs to be removed.
Tag @ericstj - I believe the metapackage was set up to exclude some libraries deliberately.
Wait, I take that back - this is from mscorlib portable -> system runtime portable, not system runtime portable -> nuget portable.
@davkean says this is by design. We had to keep IConvertible in mscorlib based portable due to dependencies from the VB compiler, but didn't carry it forward into system runtime.
FWIW we did add IConvertible to a later version of System.Runtime but that doesn't help this particular scenario.
@dsaf it is unfortunate but this is a result of some of the forking of the platforms where in some cases changing platforms can actually give you less APIs.
@Pilchie
...didn't carry it forward into system runtime.
Is IConvertible being deprecated due to a better design or it's simply a matter of time until it gets propagated everywhere?
It is a matter of time before it gets to the newer versions. We have already added it in our latest version of System.Runtime (https://github.com/dotnet/corefx/blob/master/src/System.Runtime/ref/System.Runtime.cs#L964).
@weshaggard
Thank you, last question if you don't mind: is it a matter of few months or might be a Visual Studio vNext kind of thing?
Actually I just tried this out locally and the the API does exist already in VS 2015 but you have to choose higher versions of platforms you are targeting. You will not be able target .NET 4.5 and Win8, but if you target .NET 4.6 and Windows Unversal 10, IConvertible is available. So it is already available in the newer versions of the targets. So depending on your scenario you may be good today.
Ideally would like to target Windows Phone 8 until my Lumia 920 gets upgraded over the air :).
Sorry we cannot go back in time and add support for that on Windows Phone 8. :)