-
Notifications
You must be signed in to change notification settings - Fork 845
Description
If you change the Build Action of an F# file inside Visual Studio to None, and you open it, it will still show syntax errors and the Error List will still show errors.
Comparing this to other languages, i.e. C#, they don't show the errors. In fact, I think it makes sense that if the Build Action is None it should not even be parsed (though admittedly, the syntax coloring is useful, albeit confusing: it suggests it is build, a dimmed color would make more sense).
Repro steps
Create a solution with an *.fs file that contains errors. Change the Build Action to None, open the file in Visual Studio.
Expected behavior
No errors are shown.
Actual behavior
Errors are shown.
Known workarounds
Ignore the errors (you can build, when you build the errors don't show up in the build log, but this is confusing).
Related information
Tested this with VS2015 Update 3, but it was apparent on earlier versions of F# and VS. Tested this with devenv.exe /SafeMode.
For the C# comparison, some syntax errors are caught regardless, like a missing semicolon, but incorrect identifiers, duplicate definitions, non-existing usings, invalid operators etc won't show any error. I think the C# parser does too much here, it shouldn't show any error (build action None means None), but that is outside the scope of this forum.
(Aside: I use the Build Action: None a lot as a quick way of removing files from the build, if removing from the build but keeping them makes more sense than removing them completely. This is simply because the F# build is quite slow esp. when files contain a lot of inlining or static member constraints. When not needed, excluding them can save seconds, even minutes during builds.)
(Another reason for using this if you have two versions of one source, where depending on build settings you need one of them and you flip the build action from None with MSBuild conditionals.)