Trouble using classes in a shared project from portable library in same solution

LonnieMcCulloughLonnieMcCullough USMember
edited April 2016 in Visual Studio

Using VS2015 Update 2. Here is the basic project structure:

App.iOS.csproj
- Main platform dependent project. Platform dependent service implementations...
App.shproj
- Shared project referenced from App.iOS.csproj defining most of the app. XAML files, Images, code, Service interfaces used via DependencyService
App.Forms.csproj
- Portable Forms library for some custom Forms controls and shared UI logic
App.Data.csproj
- Portable shared business object library also used on the backend
App.Client.csproj
- Portable client access library that calls into the service backend

All my XAML and most app code is defined in the App.shproj shared project. I can't seem to access anything via syntax assist defined in App.Forms.csproj, App.Data.csproj or App.Client.csproj. I can get to classes defined in App.iOS.csproj so for example:

App.iOS.Application (the default container for Main() in the Xamarin Forms templates) is accessible via syntax assist from any cs file in the shared project. When I try to access App.Client.AppClient (a simple wrapper around HttpClient) all I get is

The type or namespace 'Client' does not exist in the namespace 'App'

Same if I add a 'using App.Client' at the top of the cs file. In short VS doesn't seem to be able to see those solution libraries from the shared project even tho they are being referenced from the App.iOS.csproj (which references the shared project).

Now this all compiles just fine. No compile time problems at all. I guess when the Xamarin Mac Agent compiles the solution it properly assembles all the shared files and everything resolves correctly. This also was working fine in Xamarin Studio on my Mac before I moved to VS.

Some hacks I tried:
1) Added ProjectReference elements to the App.projitems file that point at the 3 projects I care to reference from the shared project
2) Added ProjectReference elements to the App.shproj file that point at the 3 projects I care to reference from the shared project
3) Tried restructuring the whole thing converting the shared project to a portable project but there were just too many build errors to overcome especially since the shared project solution builds just fine.

More interesting tidbits:
1) Most of my Page level classes derive from a class called App.Forms.AppPage (which itself derives from Xamarin.Forms.Page) defined in the App.Forms.csproj. When editing the code behind of any pages defined in the shared project VS seems to know that X.F.Page is the ultimate base class and presents members from that class but doesn't make any of the members defined by App.Forms.AppPage available
2) Syntax assist does in fact seem to work properly for a small amount of time after the solution is initially loaded. So all the members defined in all the other solution projects are resolvable and syntax assist presents them to me while typing.
3) During the time after the solution is initially loaded and syntax assist appears to work none of the XAML defined members (InitializeComponent, anything with an x:Name in the XAML file) seems to be resolvable.
4) I think that performing a build seems to be the trigger that switches between syntax assist resolving things properly and not but can't be totally sure that is the only trigger.

Be really, really awesome to get syntax assist working here, I just can't seem to figure out how to make VS do what I expect it to do naturally and not sure if I got myself into this situation or if this is a product of churn due to the MSFT deal. Thanks for any help. Sorry for the essay

Sign In or Register to comment.