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

Hunter T. via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 18 09:44:35 PDT 2023


StrangeRanger added a comment.

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

> for default `set;get` or `get;set` for when `AfterCSharpProperty` is true,
>
>   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.
If we assume the above sentence is always true, and the brace doesn't break after the property name, the following are the options in formatting that I've seen:

When autoproperty is used:

  public Foo {
      get;
      set;
  }
  
  // OR
  
  public FooTwo { set; get; }  // What I prefer.

When a non-autoproperty is used:

  /* When only one thing is provided in the getter and setter. */
  
  public Foo {
      get { return _next; }  
      set { _next = value; }
  }  // What I prefer.
  
  // OR
  
  public Foo {
      get => return _next; 
      set => _next = value;
  }  // Another option that I like (which really doesn't apply to this code change).
  
  // OR
  
  public Foo {
      get 
      { 
          return _next; 
      }  
  
      set 
      { 
          _next = value; 
      }
  }
  
  // ----------------------------------
  
  /* When more than one thing is provided in the getter and setter. */
  
  public Foo {
      get 
      { 
          // ...
          return _next; 
      }  
  
      set 
      { 
          _next = value;
          // ...
      }
  }

Please note that the above examples *slightly* ignore the different variations in how the braces could be set (new line or not).

I hope this input is enough/helps. Please let me know if you'd like any clarification.


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

https://reviews.llvm.org/D148467



More information about the cfe-commits mailing list