The following code triggers a formatting warning on each let (“possible incorrect indentation”):
module UtilTests =
[<Test>] let simpleWithNth ()= true |> should be True
[<Test>] let negIndex () = true |> should be True
[<Test>] let tooBigIndex () = true |> should be True
[<Test>] let lastIndex () = true |> should be True
The following does not:
module UtilTests =
[<Test>] let simpleWithNth ()= true |> should be True
[<Test>] let negIndex () = true |> should be True
[<Test>] let tooBigIndex () = true |> should be True
[<Test>] let lastIndex () = true |> should be True
Why does it want each let to be more indented than the one above it? (Is there some way to have Visual Studio 2012 auto-format?)
As Brian said in the comment, the usual way of applying attributes to a
letfunction is to write the attribute on the line before theletbinding. I would also expect the code you wrote to work, because the body of the function is on the same line, but apparently, the compiler does not think so….However, there is another way to apply attributes to
letfunctions that works well in your example:This style is needed if you’re writing recursive functions – then attributes on previous lines do not work and you need to write
let rec [<Foo>] foo () = ... and [<Bar>] bar () = ....