Generic Property Breaking
Currently a generic property will break like this
public virtual ICollection<
SomeObject
> SomeLongNameThatForcesALineBreak { get; set; } =
new HashSet<SomeObject>();
Which is modeled after how prettier breaks the following typescript.
public SomeName: SomeLongGenericClassThatBreaks<
SomeRandomType,
SomeOtherRandomType
> = new SomeLongGenericClassThatBreaks(someValue, someOtherValue);
Should we do something different?
public virtual ICollection<SomeObject>
SomeLongNameThatForcesALineBreak { get; set; } =
new HashSet<SomeObject>();
Or maybe this if we decide to break before the =
public virtual ICollection<SomeObject>
SomeLongNameThatForcesALineBreak { get; set; }
= new HashSet<SomeObject>();
Would we ever want to break after the modifiers?
public virtual
ICollection<SomeLooooooooooooooooooooooooooongType>
SomeLongNameThatForcesALineBreak { get; set; } =
HashSet<SomeLooooooooooooooooooooooooooongType>
One heuristic that prettier uses is that if there is only type parameter, it isn't broken up, ever. Maybe, we can incorporate that.
More specifically, prettier keeps the LHS part of a declaration with at most one type parameter on a single line. If more than one, it may be broken up as you mentioned.
In a similar vein, we can also keep the LHS part of a declaration on a single line if there's at most one type parameter.
public virtual ICollection<SomeObject> SomeLongNameThatForcesALineBreak { get; set; } =
new HashSet<SomeObject>();
And if there's more than one, we can split along similar lines to prettier.
public virtual ICollection<
SomeObject,
ReallyLongTypeParameter> SomeLongNameThatForcesALineBreak { get; set; } =
new HashSet<SomeObject>();
I think
Group(
Group("public virtual", "ICollection<SomeLooooooooooooooooooooooooooongType>"),
Group("SomeLongNameThatForcesALineBreak", "{ get; set; } ="),
"HashSet<SomeLooooooooooooooooooooooooooongType>"
)
(with the contents in "" being printed recursively by syntax printers, of course) would achieve the # 3, right?