The contents of the functions block is inserted at the very top of the class, with the familiar #line directives to pretend that it comes from the CSHTML.

Notice that none of the whitespace around the functions block is stripped; you can see the newline and indentation in the @functions line in the first WriteLiteral string, and the newline and indentation after the closing } in the second WriteLiteral string.

Sure enough, the rendered HTML contains an extra blank like:

<!DOCTYPE html><html><body>
55 characters have been written so far.
</body></html>

This means that putting a functions block before the <!DOCTYPE> will cause the HTML to start with an ugly blank line. Therefore, it’s best to put functions blocks at the end of the source, where the blank lines won’t matter.