microsoft / wil

Windows Implementation Library
MIT License
2.58k stars 236 forks source link

Add a .clang-format file to WIL #412

Closed dunhor closed 10 months ago

dunhor commented 10 months ago

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 runs clang-format over all our code with the version of clang-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:

A few additional things I plan to address/look into:

A few additional notes/questions:

dunhor commented 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