19

I'm having a bit of trouble here, in our company we have a self rolled DA layer which uses self referencing generics. In Visual Studio 2010, the IDE was perfectly happy with this, however 2012 seems to be having difficulty, even though when we build, it succeeds.

Here is an example:

Example of parsing error

The DataObject definition is as follows:

[TypeDescriptionProvider(typeof(HyperTypeDescriptor.HyperTypeDescriptionProvider))]
public class DataObject<T> : 
    INotifyPropertyChanged, 
    IDataErrorInfo, 
    IEditableObject, 
    IDataObject 
    where T : 
        DataObject<T>, 
        new()

I realise it isn't the simplest of definitions, but its legal, and it builds perfectly fine.

However, this 'issue' causes intellisense to fail, as well as the 'Go To Definition' function, which needless to say is frustrating.

I've tried removing and re-adding the references, but the issue persists.

VS2010 is perfectly happy and is what I have gone back to using, VS2012 is very nice and responsive but if this issue persists its a deal breaker.

Anyone got any ideas?


Want to make a couple of things clear, this issue is an intermittent one (which is a pain as its really hard to track the root cause).

It breaks intellisense and 'go to definition' everywhere, not just for the class with the error.

I'll have a go at building a example solution to submit to connect, but time isn't on my side lately.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Marlon
  • 2,129
  • 3
  • 21
  • 40
  • 1
    What is the error or exception you receive? – Alireza Maddah Sep 14 '12 at 14:51
  • I've just re-opened VS20112 again to try to copy the error that the above squiggly red line is indicating and its not doing it at the moment, but it will do it again at some point. Basically the error for the above was it couldn't find the class definition - as in if I did ctrl+. it would offer to generate the type for me, despite being in the type needed. – Marlon Sep 14 '12 at 14:58
  • 7
    Select the full framework instead of the client profile. If that doesn't help then you really need to post this to connect.microsoft.com, the only guys that can fix this. They'll need a good repro project. – Hans Passant Sep 14 '12 at 15:14
  • 1
    Fully agree. If a full rebuild/closing & reopening does not fix this, file it as a bug ASAP. – Stu Sep 26 '12 at 17:34
  • just a guess, have you tried making BusRoute class partial? one part with no inheritance and no implementation and another part with inheritance and full implementation. – Bizhan Oct 10 '12 at 14:52
  • Sorry, but I don't understand what is the intended purpose of doing this kind of object hierarchy. May I get some explanation? – LightStriker Oct 17 '12 at 06:00
  • @Marc-AndréJutras - This is a base / abstract class which all our DA objects inherit from. Doing this enables me to have type aware lambda functions available to the sub classes. – Marlon Oct 19 '12 at 13:32
  • Are you sure you're not opening two Visual Studio instances on the same project? (for example VS 2010 and VS 2012 on the same project) This notably breaks intellisense because of the shared .NCB intellisense file – Simon Mourier Nov 04 '12 at 17:11
  • @SimonMourier I feel like a n00b now but I think your right. I didn't know they shared the intellisense files. I didn't have the same solution open in both, but our solutions share some projects, so your explanation is still valid. I'll do some more testing, but if you write that as an answer I'll probably accept it. – Marlon Nov 06 '12 at 14:37
  • Do you have any kind of customization to the csproj, or are you using any kind of code generation (e.g. T4)? – fsimonazzi Nov 06 '12 at 16:53

3 Answers3

1

Sounds silly, but I run into similar issues with new code that gets introduced or changed with intellisense. I tracked it down to basically needing to perform a save all, or sometimes even clean and rebuild / compile before it intellisense properly acknowledges the code being valid.

A similar that happens on occasion in VS2010 too that can be duplicated if you make a class structure, then edit code on another class to use it, then bounce back, hack out class functions and add new ones without any saving.

Dave
  • 1,823
  • 2
  • 16
  • 26
1

Sometimes, and this isn't always the case ReSharper can cause issues with references and GTD functionality. Do you have it installed?

DRobertE
  • 3,478
  • 3
  • 26
  • 43
  • nope, clean VS install, no plugins installed apart from the Microsoft ones that come pre-installed. – Marlon Oct 08 '12 at 08:28
1

This can happen if you open the same solution/project with two instances of Visual Studio (even two Visual Studio 2010 for example). The Intellisense mechanism uses .NCB files that Visual Studio instances cannot really share. In this case, Intellisense behavior is strange.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • Simon, out of interest, do you know if unloading / reloading the project causes VS to rebuild these .NCB files - as doing it seemed to resolve the intellisense issue when it happened. – Marlon Nov 07 '12 at 09:07
  • No, I'm not aware of this, but that would not surprise me. I think the result of opening the same project twice is undetermined (with regards to Intellisense) – Simon Mourier Nov 07 '12 at 09:32