views:

17

answers:

1

I have some cs files in my project that are not set to be built (Properties -> Build Action = None). They contain bits of code that don't compile as a whole and are there merely for reference. I don't care about any compilation errors in them, but they appear in the "Error List" window. The errors don't stop compilation, merely clutter the window. Is there some way to tell VS to ignore errors in that file? Or in all files not set to be built, at that ?

I'm using VS 2010

Thanks

To reproduce this:

  1. Create a new C# project.
  2. Add a new .CS file to the project. Type some garbage in between the class Class { and the closing }.
  3. Don't build the project
  4. Note that the Error List window says something like "Invalid token '}' in class, struct, or interface member declaration".
  5. Set the Build Action for the .CS file to "None".
  6. Notice that the Error List still displays the error.
+1  A: 

That doesn't make a heckofalot of sense, can't repro it. What version of VS? Are you sure these aren't IntelliSense errors? Another way to tackle it is right-clicking the file in the Explorer window, Exclude from Project. Then click the Show all Files icon (top of window) to make it visible again.

Hans Passant
I'm not sure what qualifies as an "IntelliSense" error? They don't prevent compilation, if that's what you mean
ohadsc
You'll need to provide some reliable repro steps to get a better answer.
Hans Passant
I've added repro steps, since I can repro it. Cheers.
Roger Lipscombe
Yes, that's an IntelliSense error, I forgot to press Enter. My suggested workaround suppresses them. VS2010 does it as well, you could post to connect.microsoft.com. I doubt a fix for it will be easy.
Hans Passant
Thanks, maybe I will
ohadsc