开发者

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

Ok, we have a 'pseudo-c#' file that we've added to the solution for reference. While it does have a .cs extension (to let VS take a stab at color-coding it since it's pretty big and that helps with readability) the file itself isn't marked to be compiled with the action set to 'none'.

Now, when we do a full build, everything builds just fine and the file is ignored as it's supposed to be. However, the error windo开发者_如何学Pythonw is showing all the errors from the faux code. We of course can change the extension which gets rid of the errors, but then we lose syntax coloring.

Now I'd assume since we explicitly marked that file as 'do not compile' and since the errors are actually ignored by the compiler, they wouldn't show up, but obviously that isn't the case.

So anyone have any idea on how to hide errors that are generated in files that are marked to be excluded from the compiler?


Update:

Because people keep suggesting work-arounds, I want to be clear that we're already using work-arounds. That's not what I'm after here. I'm trying to find out specifically if there is some setting or feature in VS that we can enable/disable that says 'Hey, you're not being compiled so you don't get to be in the error list!' Not sure there even is such a thing, but if so, that's what I'm trying to find.


You can:

  1. Exclude the file from your project. Right click the file in question, and choose "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.
  2. Use a preprocessor #ifdef to conditionally include and exclude blocks (or files) of code. Note that non-included blocks of code will not be highlighted (and checked for errors).


One workaround could be to exclude the file from the project and ensure 'show all files' is on in visual studio. That way you will be able to see the file and still get syntax highlighting when you open it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜