Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2012 - Self Referencing Generics Parsing Errors

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.

like image 802
Marlon Avatar asked Sep 14 '12 14:09

Marlon


1 Answers

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.

like image 112
Simon Mourier Avatar answered Sep 21 '22 06:09

Simon Mourier