Invalid formatting when parameters have attributes with many values
Input:
public void Method(
[Attribute(
Something.Other,
SomethingElse.Other,
Something = Value,
SomeString = "String",
SomeNumber = 1
)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject)
Output:
public void Method(
[Attribute(
Something.Other,
SomethingElse.Other,
Something = Value,z
SomeString = "String",
SomeNumber = 1
)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject
)
Expected behavior: Both parameters, the one with attribute and the one without should have the same indentation
public void Method(
[Attribute(
Something.Other,
SomethingElse.Other,
Something = Value,
SomeString = "String",
SomeNumber = 1
)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject
)
This was done intentially, but changing it is open to debate. If the attributes line up with the parameters it is less clear how many parameters you are dealing with in an example like below. My guess is I ran into some examples from https://github.com/belav/csharpier-repos that I thought looked better with the parameters indented.
// lined up attributes and parameters
public void Method(
[Attribute(_________________________longValue, _________________________longValue)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject,
SomethingObject somethingObject,
[Attribute(_________________________longValue, _________________________longValue)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject
) { }
// indentation of parameters that have a long attribute
public void Method(
[Attribute(_________________________longValue, _________________________longValue)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject,
SomethingObject somethingObject,
[Attribute(_________________________longValue, _________________________longValue)]
IReadOnlyList<SomethingObject> somethingObjects,
SomethingObject somethingObject
) { }
My personal opinion is that indentation doesn't make sense there since it's not a block and there's no nesting of any kind (i.e. the attribute declaration does not "contain" the parameter).
I also think it's pretty similar to the following example with properties instead of parameters, which doesn't introduce any indentation on formatting:
[Attribute(
Something.Other,
SomethingElse.Other,
Something = Value,
SomeString = "String",
SomeNumber = 1
)]
public object Prop1 { get; }
[Attribute(
Something.Other,
SomethingElse.Other,
Something = Value,
SomeString = "String",
SomeNumber = 1
)]
public object Prop2 { get; }