views:

381

answers:

3

I'm starting a project which is broken up over multiple VS projects and I was planning on having separate testing projects for each of the projects, so I'd have a solution like this:

  • Project1
  • Project1.Test
  • Project2
  • Project2.Test

There are some internal classes which I want to have tested. So I used Visual Studio 2008 (SP1) to generate the test stubs in my test project and added the InternalsVisibleTo. But I get a red squiggly line under the internal class. If I compile I get a successful build, and looking at the test method the red squiggles are gone.

But if I tough the file the squiggles come back and I have no intellisense on the internal class.

The internal is within Project1 and the test is within Project1.Test. For completeness I decided to do the exact same manner of generating the test method but this time into Project2.Test, and this time it's shown to be completely working. I don't get red squiggles, I get intellisense, everything.

I've tried deleting Project1.Test and recreating the test method, everything I can think of, but no matter what I do I can't get the internal to be completely visible within its paired Test project, only in the one which is designed to be for another project.

It's doing my nut that it's not working!

A: 

It might be a problem with IntelliSense DB file. Try to delete it and have VS try and rebuild the DB.

To do this close the solution and delete (all?) .ncb files. To be on the safe side, just rename them to something like .nc4 or whatever. Reopen the solution and rebuild it. Let me know if it works.

EDIT: Apparently, ncb files are only for C++ projects. I don't know where the IntelliSense DB for C# projects are, nor could I find out. If I were you, I would still try to find a way to reset the DB.

Asaf

Asaf R
For C#, intellisense for foo.dll is in the foo.xml file generated if enabled; however, project references inside a solution don't use this - they can access the metadata directly.
Marc Gravell
+1  A: 

I've seen this too, especially when using strong names. To be honest, I didn't get excited; as long as it compiles and tests correctly, I can live with the odd glitch. For example, if you get one build problem, I've seen it complain that it can't find the other (internal) methods - but a clean build shows no errors. Again, I'm not to bothered by this... (maybe I'm too forgiving?).

In particular, it is only rarely that I need to use an internal type/member in the tests (most of the time I'll try to test via the public API); so the lack of 100% reliable intellisense isn't usually a big problem. I already know the type/member I am looking for (copy/paste ;-p).

Sure, it would be nice if it was fixed, but if I was the budget manager, I could probably live with it and focus on other features first.

Marc Gravell
Yeah it's not a hugh problem but it's annoying when you miss-type a member cuz intellisense died!
Slace
+2  A: 

Could you be using a string constant or something other than the exact literal stirng (without concatenation) in your InternalsVisibleTo attribute? We had the habit of using a string constant to define it, and that works fine for everything except intellisense. Replace by pasting as a simple string and it works.

Deleting your .suo file (same folder as your solution file) might help as well.

Kurt Schelfthout
using an exact string solved it for me.
Courtney de Lautour