Bug 57991 - Intellisense for a class library project in same solution fails to load in Xamarin.Android
Summary: Intellisense for a class library project in same solution fails to load in Xa...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.4 (15.3)
Hardware: PC Windows
: --- normal
Target Milestone: 15.5
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-07-06 22:47 UTC by Jon Goldberger [MSFT]
Modified: 2017-12-07 11:24 UTC (History)
8 users (show)

Tags:
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:
Status:
VERIFIED FIXED

Description Jon Goldberger [MSFT] 2017-07-06 22:47:23 UTC
## Description

When I add an Android class library to a solution with an Android app project, and then reference the Android class library from the app project, there is not intellisense/auto-complete. Sometimes building the solution will enable the intellisense /  auto-complete but not always. But one should not have to build the library project or the solution before getting intellisense. You don't have to with iOS app and iOS class library in Visual Studio (Windows), or if you use Visual Studio for Mac. 


Also this occurs in VS 2015 Enterprise Version 14.0.25431.01 Update 3 (and same Xamarin version 4.5.0.486). 

## steps to reproduce 

1. Open VS 2017 or VS 2015 and create a new Android project (tested with Single View template)

2. Add a Android class library to the solution

3. Add a reference to the class library from the android app project.

4. Open MainActivity.cs and add a using statement to reference the new class library namespace.

Expected result: Auto-complete will offer the name of the class library namespace.

Actual result: Auto-complete does not offer the namespace for class library added in step 2. 


## Additional notes.

Build and deploy work fine. If I add a method to the default class in the class library, and call that method from OnCreate, it does run and return as expected, so this is just an intellisense/auto-complete issue. 

Once, and only once, I was able to resolve this issue by closing and re-opening the solution, and intermittently by building the solution. Otherwise I was able to resolve this issue by adding a second Android app project to the solution and referencing the class library from that app project. Then intellisense/auto-complete also worked in the first app project.

Also might be worth noting that with an iOS app project and an iOS class library, all works as expected. Auto-complete and intellisense work as soon as the reference to the iOS lass library is add to the iSO app project, no build or any other actions are necessary. 

I tried to get the Design time build output using the steps outlined in https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#visual-studio-2017 
but I did not get the Build - Design Time option in the output window even though the command ran successfully according to the console output.

## Possible workarounds

1. Build the solution

2. Add a new Android app project to the solution and reference the relevant class library from that new app project. Once everything resolves and intellisense is working in the original app project, you can remove the newly added template app project. 

## Environment

Microsoft Visual Studio Enterprise 2017 
Version 15.2 (26430.15) Release
VisualStudio.15.Release/15.2.0+26430.15
Microsoft .NET Framework
Version 4.6.01586

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00369-60000-00001-AA405
Microsoft Architecture Diagrams and Analysis Tools

Visual Basic 2017   00369-60000-00001-AA405
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA405
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA405
Microsoft Visual C++ 2017

Visual F# 4.1   00369-60000-00001-AA405
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.6.00404.2
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30503.0
ASP.NET and Web Tools 2017

ASP.NET Web Frameworks and Tools 2012   4.0.11203.0
For additional information, visit https://www.asp.net/

ASP.NET Web Frameworks and Tools 2017   5.2.50303.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30209.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools   1.9
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure Hive Query Language Service   2.2.5000.0
Language service for Hive query

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50131.1

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.2.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61702.140
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.2.2.0
TypeScript tools for Visual Studio

Visual C++ for Cross Platform Mobile Development (Android)   15.0.26228.00
Visual C++ for Cross Platform Mobile Development (Android)

Visual C++ for Cross Platform Mobile Development (iOS)   15.0.26228.00
Visual C++ for Cross Platform Mobile Development (iOS)

Visual Studio Tools for Universal Windows Apps   15.0.26430.06
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Xamarin   4.5.0.486 (fec6f88)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.3.1.2 (9dbc4c5)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.10.0.37 (ad35de4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Comment 1 Jon Douglas [MSFT] 2017-07-10 15:32:06 UTC
CONFIRMING this behavior based on the reproduction in https://bugzilla.xamarin.com/show_bug.cgi?id=57991#c0

The behavior for Class Library and Binding Library references are quite finicky and typically do not provide intellisense.
Comment 2 Joaquin Jares 2017-07-12 16:14:48 UTC
I'm getting this on the errors window:
Severity	Code	Description	Project	File	Line	Suppression State
Warning		The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'ClassLibrary1, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'ClassLibrary1.dll'
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection`1 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
   at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	App27	C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets	1062	

Moving to Android so Dean can provide some insight.
Comment 3 Cody Beyer (MSFT) 2017-09-18 18:56:07 UTC
This should be fixed on master