Bug 13221 - PCL Project should implicitly reference all framework assemblies
Summary: PCL Project should implicitly reference all framework assemblies
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: Trunk
Hardware: Macintosh Mac OS
: High normal
Target Milestone: 4.2.3 (from master)
Assignee: Lluis Sanchez
Depends on:
Reported: 2013-07-12 17:46 UTC by Timothy Risi
Modified: 2014-01-07 08:24 UTC (History)
5 users (show)

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

Example project (9.00 KB, application/zip)
2013-07-12 17:46 UTC, Timothy Risi

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 Timothy Risi 2013-07-12 17:46:28 UTC
Created attachment 4341 [details]
Example project

A PCL project will build successfully even though there are errors as long as the only errors are due to missing references.  The code will still show errors in the text editor (red text, "Unknown Error"), but if you build the project, it displays Build Successful.  Any errors for other reasons still behave correctly.

Example code, builds successfully when references aren't included in the project.

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Net;

namespace TestPcl
	public class MyClass
		List<string> test;

		public MyClass ()
			WebRequest request = HttpWebRequest.Create ("");
			request.Credentials = new NetworkCredential ("foo", "bar");
			request.BeginGetResponse (null, null);

			string[] array = test.Where (s => s.ToLower () == "foo").ToArray ();

changing the last line to "string[] array = test.Where ().ToArray ()" will cause the build to fail with the error "No overload for method 'Where' takes '1' arguments"

I attached an example using the above code.

OS X 10.8.4
Xamarin Studio
Version 4.0.10 (build 3)
Installation UUID: 163f9b0a-f1be-4283-ae88-7b65a18efe5b
	Mono 3.1.1 ((no/c07cb68)
	GTK 2.24.20
	GTK# (
	Package version: 301010000
Comment 1 Mikayla Hutchinson [MSFT] 2013-07-12 23:27:14 UTC
I suspect this was introduced by:

Comment 2 Mikayla Hutchinson [MSFT] 2013-07-15 21:50:45 UTC
PCL projects implicitly reference all framework assemblies. VS displays ".NET Portable Subset" in the references folder and does not display these assemblies in the Edit References dialog. Additionally, the project files has a comment explaining that all the framework assemblies are implicitly referenced.
Comment 3 Mikayla Hutchinson [MSFT] 2013-07-15 21:51:05 UTC
So it's not a build bug, it a UI and code completion engine bug in XS.
Comment 4 Mikayla Hutchinson [MSFT] 2013-07-15 21:54:07 UTC
So it's not a build bug, it a UI and code completion engine bug in XS.

VS also display assemblies from "bigger" PCL profiles in the Edit References dialog, and adding one of these does not add an additional reference, but instead changes the profile. That seems like an enhancement TBH, I don't think it's worth worrying about.
Comment 5 Martin Baulig 2013-07-19 10:01:20 UTC
We need to distinguish PCL v1 and PCL v2 here:

For PCL v1, you still need to explicitly reference these assemblies in the UI.

PCL v2 doesn't give you this option anymore, but automatically references them all.
Comment 6 Mikayla Hutchinson [MSFT] 2013-07-19 23:06:59 UTC
No PCL v4.0 does it too in VS2012, try it.
Comment 7 Lluis Sanchez 2013-09-04 05:51:27 UTC
So in which cases should all framework assemblies be referenced? How can I detect which version of PCL a project is using?
Comment 8 Mikayla Hutchinson [MSFT] 2013-09-05 21:10:02 UTC
In my tests, PCL projects always reference all assemblies.

The list of references that comes from MSBuild is correct (we always use MSBuild for PCL), but MD's project system seems to be discarding them.
Comment 9 Martin Baulig 2013-09-06 19:14:50 UTC
Yeah, sorry for the confusion, Michael is right.
Comment 10 Martin Baulig 2013-09-10 20:18:46 UTC
In addition to that, XS should not allow you to add any references to framework assemblies and also hide them.

At the moment, when you create a new PCL project, it will list ".NET Portable Subset", System, System.Core and System.Xml as references.  You may right-click and select "Edit References", then "Packages" will contain all the framework assemblies from the currently selected PCL profile.

The "Edit References" option should be available, but only offer compatible PCL assemblies that the user installed in [FIXME: wherever the search patch is?].
Comment 11 Mikayla Hutchinson [MSFT] 2013-09-10 23:20:59 UTC
I fixed all those issues.
Comment 12 Sadik Ali 2014-01-07 05:51:53 UTC
I have checked this issue with attached project, followed Timothy's steps mentioned in bug description and still getting same error.

Refer screen shot: http://screencast.com/t/BB4jjHwc. Hence reopening the issue.

Checked With:

All Mac
XS 4.2.3 (build 24)
XA 4.12.0
Comment 13 Lluis Sanchez 2014-01-07 06:49:27 UTC
Sadik, that error message is expected, the bug is not about that message. The bug was that XS was marking some symbols in the text editor as unresolved when it shouldn't (red text this screenshot: http://screencast.com/t/WtX9GoLyo).
Comment 14 Sadik Ali 2014-01-07 08:24:06 UTC
@Lluis I have check this issue as per your comment and I am not getting "some symbols in the text editor as unresolved"

Refer screen shot: http://www.screencast.com/t/PyLBuNSgbuQ3