Bug 961 - Code completion does not refresh new references
Summary: Code completion does not refresh new references
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 2.6 RC 1
Hardware: Macintosh Mac OS
: --- minor
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2011-09-21 10:15 UTC by Marcio Alexandroni
Modified: 2011-09-30 00:39 UTC (History)
3 users (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 Marcio Alexandroni 2011-09-21 10:15:48 UTC
When a DLL is referenced in the project, the namespace can´t be accessed through code completion in the text editor. The using code completion does not show the newly added namespace.

It works after closing and reopening the project.
Comment 1 Mike Krüger 2011-09-22 02:48:19 UTC
Works for me, but it can take some seconds till the code completion database updates.
Do you have a 'Gathering class information' message in the code completion window after adding the dll ?

If waiting some seconds for this message to disappear doesn't help I need more info about the exact use case (which dll etc.) since in my tests all seems to be working.
Comment 2 Marcio Alexandroni 2011-09-22 08:08:41 UTC
I´m using MonoDevelop The referenced DLL is the Newtonsoft.json.MonoDroid.dll available at GitHub https://github.com/chrisntr/Newtonsoft.Json

I´m adding the reference to the DLL to the MonoAndroid project in MonoDevelop and when I try to add the "using Newtonsoft..." clause it shows "No matches".

I have waited for more than a minute, tried to rebuild the project, tried to close all editor tabs and reopen the CS file, nothing helps.

When I close the solution and open it again, everything works fine, the "Newtonsoft" appears in the code completion and everything is fine.
Comment 3 Mikayla Hutchinson [MSFT] 2011-09-22 11:29:46 UTC
This probably has something to do with the fact the Mono for Android projects use MSBuild/xbuild, which means that assembly references are resolved using MSBuild/xbuild.

Mike, try enabling experimental xbuild support in MD prefs and restarting MD. Then you should be able to reproduce this for all project types.
Comment 4 Mike Krüger 2011-09-23 04:21:15 UTC

However we still have an underlying issue with that. The event chain doesn't work in that case

After the project reference added/removed events the references of the project are the ones before the event and are not updated until the msbuild project is saved.

The save occurs after the update & after the reference addde/remove event. That doesn't seem very trivial to fix. I would 'just' always take the info from the project structures and not from the msbuild file, but I don't change that because I don't know enough about side effects there. 

But that's a bug in the event chain.
Comment 5 Mikayla Hutchinson [MSFT] 2011-09-23 06:53:31 UTC
The reason that we resolve references from MSBuild is that it considers many more build variables, build conditions and reference sources than MD does. It's guaranteed to give us the references that'll be used by the compiler. VS does the same.
Comment 6 Mike Krüger 2011-09-23 10:29:49 UTC
@Michael: You mean that vs.net shares the bug that after the reference added event the list of references are wrong ? oO
Comment 7 Mikayla Hutchinson [MSFT] 2011-09-23 10:38:55 UTC
No, why do you say that? Using MSBuild to resolve doesn't mean that you have to have event chain bugs.
Comment 8 Mike Krüger 2011-09-23 11:52:44 UTC
> VS does the same.

I talked about the bug and not about MSBuild also I'm not really sure if a very complex case would be needed atm - we just have the refs in the dialog and monodevelop  knows which dll gets referenced. 

But in any case it'll be a bug if we've a case that's not easy resolveable and gets added with add project refrence because at that time it's atm not possible to get the msbuild resolved assemblies.
Comment 9 Mike Krüger 2011-09-30 00:39:34 UTC
*** Bug 1077 has been marked as a duplicate of this bug. ***