In C # / VS 2010, how can I suppress error messages for files not marked for compilation?

Well, we have a pseudo-C # file that we added to the solution for reference. Although it has a .cs extension (so that VS can hit the color coding as it is quite large and helps with readability), the file itself is not marked for compilation with the action set to "none".

Now, when we do the full assembly, everything builds just fine, and the file is ignored, as expected. However, the error window displays all errors from the artificial code. Of course, we can change the extension, which gets rid of errors, but then we lose the syntax coloring.

Now I assume that since we explicitly mark this file as β€œdo not compile”, and since errors are actually ignored by the compiler, they will not appear, but obviously this is not so.

So, does anyone know how to hide errors that are generated in files that are marked as excluded from the compiler?


Update:

Because people continue to offer workarounds, I want to clearly say that we already use workarounds. This is not what I'm here for. I'm trying to find out if there are any settings or functions in VS that we can enable / disable, which says: "Hey, you are not compiling, so as not to get into the error list!" Not sure if there is even such a thing, but if so, then what I am trying to find.

+4
source share
2 answers

You can:

  • Exclude file from your project. Right-click the appropriate file and select Exclude. To view this file, select "Show All Files" at the top of your Solution Explorer, and you can edit your code with full syntax highlighting.
  • Use the #ifdef preprocessor to conditionally include and exclude blocks (or files) of code. Please note that unincluded code blocks will not be highlighted (and checked for errors).
0
source

One way to solve the problem may be to exclude the file from the project and ensure that all files are displayed on the visual studio. This way you can see the file and still get syntax highlighting when it is opened.

0
source

All Articles