[PATCH] D148467: [clang-format] Add a new AfterCSharpProperty to BraceWrapping

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 18 12:25:59 PDT 2023


HazardyKnusperkeks added a comment.

In D148467#4277960 <https://reviews.llvm.org/D148467#4277960>, @MyDeveloperDay wrote:

>>>   public Foo {
>>>       set;
>>>       get;
>>>   }
>>
>> At least from my experience, the getter is specified before the setter, though I'm unsure how important this is in your eyes.
>
> Lets hold off the idea of swapping `set;get` around from this patch, but this is something that I think we could do..  (using the FormatTokenLexer.cpp to swap trivial `set;get` into `get;set` but lets leave that for another feature, as it would be code altering)
>
> honeslty I think we need another option  maybe
>
>   enum AllowShortCSharpProperties {
>         Leave,
>         Never,
>         Empty,
>         Always
>   }
>
> **Leave **= Don't touch them
> **Never **=  always break  (braces follow AfterCSharpProperty
>
>   set;
>   get;
>   
>   set { 
>     val = value; 
>   }
>   get { 
>     return = value; 
>   }
>
> **Empty**  = only one the same line when empty
>
>   set; get
>   
>   set { 
>      val = value; 
>   }
>   get { 
>     return = value;
>   }
>
> **Always **=  always short form for trivial
>
>   set; get;
>   
>   set {  val = value; }
>   get {  return = value; }
>
> I'm trying to decide if I put that option in this change or in a seperate change (thoughts @HazardyKnusperkeks, @owenpan )
>
> FYI, I've solved the indention issue in my branch which has been broken forever from what I can tell.
>
>   verifyFormat("class A\n"
>                "{\n"
>                "    string Bar {\n"
>                "        get;\n"
>                "        set\n"
>                "        {\n"
>                "            val = value;\n"
>                "        }\n"
>                "    }\n"
>                "}",
>                Style);

I'd say do it now. No need to introduce a new option, when we want to change it directly.

Or at least make it the enum right now, with just 2 values.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148467/new/

https://reviews.llvm.org/D148467



More information about the cfe-commits mailing list