Closed dunhor closed 10 months ago
I don't have strong opinions about the questions you asked in the PR description. do what you think is best.
I found some annotations that were missing. Otherwise, couldn't figure out any non-hacky way to get the rest to work. The Macros
vector seems to work decently well, but isn't available until version 17, which is higher than the version that ships with VS. I'll delay those for now. I'll leave everything else as-is. We can go back and re/un-format if we get too annoyed with it later
Previous draft PR was here: https://github.com/microsoft/wil/pull/401, which has a few comments. I've created a new one as that one had a bit of experimentation and got a little messy. The biggest topic of conversation from before was the outer-most namespace contents not getting tabbed causing a lot of whitespace changes. For now the plan is to roll with it, however that may make merge conflicts a little tricky in the short term.
NOTE: The
.clang-format
file has been take from the OS repo with very minimal additions to ensure that some of WIL's macros don't cause weird formatting. This is not a request for comment on personal style preferences. Comments and feedback should be focused on issues with the formatting (e.g. macros being handled incorrectly, etc.).For now, all I've done is add the
.clang-format
(with additions mentioned above), add a script that runsclang-format
over all our code with the version ofclang-format
that ships with Visual Studio (as an attempt to get some consistency), and then run said script. No manual code changes have been made (I'll call out any I end up making). A few things I plan to look into for the future:clang-format
was not run, or just runsclang-format
and submits the result. For now, we can ask people to runclang-format
if it's obvious that they didn't, but otherwise just run it ourselves periodically (likely on an OS sync)lclang-format
)A few additional things I plan to address/look into:
^
) pointers get formatted like they are XOR operations. I plan to do a global search for__cplusplus_winrt
and wrap them withclang-format off
/clang-format on
and fix the pointer formatting. That way the code is still formatted initially, but will require manual intervention in the futureworkarounds
directory from auto-formattingtemplate <...>
lines seem to not be getting wrapped (though others are for some reason). I plan to investigate those__R*
macros inresult_macros.h
sometimes cause line breaks, sometimes notRESULT_NORETURN
/__declspec(noinline)
sometimes get formatted weirdly#define FUNCTION(ret, name) ...
) sometimes gets formatted weirdlyA few additional notes/questions:
WI_NOEXCEPT
sometimes causes interesting formatting side effects. In particular, on constructors that contain initializers and functions with trailing return types (e.g.auto fn() WI_NOEXCEPT -> int
) where the->
gets formatted like a pointer access. There's a way to tellclang-format
that this is a macro fornoexcept
which fixes the formatting, however it's relatively new and the version ofclang-format
that ships with Visual Studio does not include it.result_macros.h
andtracelogging.h
that doesn't necessarily make the code easier to read/understand. Are there any places where we want to disable formatting in those files?