Sometimes I get annoying pattern matching and indent 开发者_如何学JAVAwarnings when compiling F#. Is there a way to disable warnings? I'm pretty OCD over warnings.
In case you forget, you can type
let rec x = lazy(x.Value)
and get the warning
This and other recursive references to the object(s) being defined will be checked for initialization-soundness at runtime through the use of a delayed reference. This is because you are defining one or more recursive objects, rather than recursive functions. This warning may be suppressed by using '#nowarn "40"' or '--nowarn:40'.
which shows that you can use either the compiler flag --nowarn
on the command-line, or use the hash-directive #nowarn
in your code. The warning number for each warning will be part of the build output (the Visual Studio error list does not display the numbers, so if in VS, build and then inspect the build output). Also, if inside VS, you can go to the project properties page, "Build" tab, and use the "warning level" selector and "suppress warnings" field (a semicolon-delimited list of numbers) to control which warnings are diplayed via the VS UI.
(BTW, I believe #nowarn
only turns off the warning in the current file, whereas --nowarn
turns it off for the entire project being compiled.)
See: Compiler Options (F#)
--nowarn:<int-list>
:Disable specific warnings listed by number. Separate each warning number by a comma. You can discover the warning number for any warning from the compilation output.
This compiler option is equivalent to the C# compiler option of the same name. For more information, see /nowarn (C# Compiler Options).
精彩评论