Closed Smooth-E closed 4 months ago
The only editorconfig options CSharpier takes into consideration are
indent_style = space
indent_size = 4
max_line_length = 100
If you want to keep the formatting of your attributes you'd need to use some form of ignoring code
I would need to add this a lot of times then. Unity components have a lot of private-but-serialized fields and all of them use this one-line formatting. I found CSharpier to be the only formatter that does not require solution files and can work with just code, which allows to format before building in CI.
It's been a while since I've used Unity, but I imagine it won't care if you just let csharpier format the files. Attributes on their own line seems to be the standard in c#.
I know but it is way more convenient when attributes are located on the same line. I think this should be possible to change this behavior of the formatter, especially conidering that it understands attributes and their position. Just a simple flag like preserve_attribute_formatting
would be a good addition.
Example: Attributes above fields. This is how CSharpier formats the code.
public class EventCard : MonoBehaviour
{
[SerializeField]
private Image _image;
[SerializeField]
private TMP_Text _title;
[SerializeField]
private TMP_Text _description;
[SerializeField]
private TMP_Text _rewards;
[SerializeField]
private TMP_Text _requiredMoney;
[SerializeField]
private TMP_Text _duration;
[SerializeField]
private Button _button;
private EventData _eventData;
public void UpdateUI()
{
// Reflect new data in the UI
}
}
Example: Attributes inline with fields. This is how JB Rider formats the code.
public class EventCard : MonoBehaviour
{
[SerializeField] private Image _image;
[SerializeField] private TMP_Text _title;
[SerializeField] private TMP_Text _description;
[SerializeField] private TMP_Text _rewards;
[SerializeField] private TMP_Text _requiredMoney;
[SerializeField] private TMP_Text _duration;
[SerializeField] private Button _button;
private EventData _eventData;
public void UpdateUI()
{
// Reflect new data in the UI
}
}
Option requests are out of scope for csharpier.
I want CSharpier to keep the attributes formatted as they are. Somewhere on the same line, somewhere - on different lines. Basically, I want constructions like this to be considered okay:
I use the following in my
.editorconfig
:Input:
Output:
Expected behavior:
Should not change, basically.
Notes
Issue template says "option requests are out of scope". Does this count as an option request?
I leave the possibility that this may be an issue on my side. I use the following command in CI to lint-check my Unity project:
The
.editorconfig
file is located at the root of the repository.