Page MenuHomePhabricator

[clang-format] Improved parser for C# properties
ClosedPublic

Authored by jbcoe on Apr 27 2020, 4:09 AM.

Details

Summary

Added some examples of properties from Microsoft documentation as test cases.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties

Configuration support will be added in a follow up patch to address whether automatic properties are formatted as

Type MyType { get; set }

or

Type MyType 
{ get; set }

Diff Detail

Event Timeline

jbcoe created this revision.Apr 27 2020, 4:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2020, 4:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MyDeveloperDay requested changes to this revision.Apr 27 2020, 6:56 AM

Can you please clang-format the patch

This revision now requires changes to proceed.Apr 27 2020, 6:56 AM
jbcoe updated this revision to Diff 260316.Apr 27 2020, 7:05 AM

Format patch.

I think if this code is only used by C# which the first if suggests, we should be OK, just tidy up a bit with the old code and I think this is fine.

Thank you, so great to have other C#'ers doing this ;-) "Clang format all the things..."

clang/lib/Format/UnwrappedLineParser.cpp
1516

the style in LLVM is to not have braces on single line if statements. (not my style but we need to keep to it)

1565

you need to remove old code

krasimir added inline comments.Apr 27 2020, 11:03 AM
clang/lib/Format/UnwrappedLineParser.cpp
1511

Add a comment illustrating is what is a trivial property accessor.

jbcoe updated this revision to Diff 260599.Apr 28 2020, 5:28 AM
jbcoe marked 3 inline comments as done.

Added missing comments.

Complied with LLVM style.

krasimir accepted this revision.Apr 28 2020, 5:31 AM

Thank you!

This revision was not accepted when it landed; it landed in state Needs Review.Apr 28 2020, 6:24 AM
This revision was automatically updated to reflect the committed changes.