Bug 14777 - Need to check for incompatible PCL project references
Summary: Need to check for incompatible PCL project references
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: master
Assignee: Lluis Sanchez
Depends on:
Reported: 2013-09-16 11:33 UTC by Martin Baulig
Modified: 2013-09-16 18:33 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Martin Baulig 2013-09-16 11:33:20 UTC
When adding a reference to a PCL Project, Xamarin Studio needs to check whether it's compatible with the current project.

For instance, create a new PCL Project using Profile24 (.NET Framework 4.5, Silverlight 5, Xamarin.iOS, Xamarin.Android), then try to add it to a .NET 4 project.
Comment 1 Mikayla Hutchinson [MSFT] 2013-09-16 15:40:45 UTC
Are you certain this doesn't work already?

Comment 2 Martin Baulig 2013-09-16 16:32:02 UTC
Just ran this in the debugger and found the problem:

TargetFramework.CanReferenceAssembliesTargetingFramework() gets called with:

> this.id
	Identifier: ".NETFramework"
	Profile: (null)
	Version: "4.0"
> fx
{[TargetFramework: Hidden=False, Name=.NET Portable Subset (.NET Framework, Silverlight, Xamarin.Android, Xamarin.iOS), Id=.NETPortable,Version=v4.0,Profile=Profile23, ClrVersion=Net_4_0]}
	ClrVersion: MonoDevelop.Core.ClrVersion.Net_4_0
	Hidden: false
	Id: {.NETPortable,Version=v4.0,Profile=Profile23}
	Name: ".NET Portable Subset (.NET Framework, Silverlight, Xamarin.Android, Xamarin.iOS)"
	SupportedFrameworks: Count=4

So this calls ProfilePatternMatches (null, ".NET Framework"), which returns false, so it's not checking for the version.
Comment 3 Mikayla Hutchinson [MSFT] 2013-09-16 17:21:46 UTC
That doesn't make sense, that's not how ProfileMatchesPattern is called.

What are the SupportedFrameworks?
Comment 4 Mikayla Hutchinson [MSFT] 2013-09-16 17:22:21 UTC
Did you somehow create a SupportedFramework with a profile name of ".NET Framework"?
Comment 5 Martin Baulig 2013-09-16 17:30:24 UTC
Oops, it calls ProfilePatternMatches (null, "<profile>") which returns false.
Comment 6 Martin Baulig 2013-09-16 17:32:17 UTC
SupportedFrameworks contains .NET Framework 4.5.xml:
<Framework Name=".NET Framework 4.5" Identifier=".NETFramework" DisplayName=".NET Framework" Profile=".NET Framework" MinimumVersion="4.5" MinimumVersionDisplayName="4.5" />

I'm trying to reference that from a non-PCL .NET 4 console project.
Comment 7 Mikayla Hutchinson [MSFT] 2013-09-16 17:37:11 UTC
No, it looks to me like the match logic is correct, except the "FIXME hack" section. This should trivial to verify by stepping through with the debugger.

Comment 8 Martin Baulig 2013-09-16 18:33:00 UTC
This turned out to be a problem with the SupportedFrameworks/*.xml files.