Different formatting (xml like) for different cs files.



For most of the project, we use stylecop like formatting let's say with default rules from rider.

But at another side of the project, we use a declarative way of defining internal business logic, which looks quite similar to the XML tree with different attributes, and inner objects.
For example, there is a UIWidget library for unity, and here is a code example from there.

         class ExampleState : State<ExampleApp> {
             int counter = 0;

             public override Widget build(BuildContext context) {
                 return new Column(
                     children: new List<Widget> {
                         new Text("Counter: " + this.counter),
                         new GestureDetector(
                             onTap: () => {
                                     => {
                             child: new Container(
                                 padding: EdgeInsets.symmetric(20, 20),
                                 color: Colors.blue,
                                 child: new Text("Click Me")

And several rules from this syntax is quite critical for us, to improve the readability of the block

1. Named arguments everywhere

2. Max one line  with object instantiation, or factory method

3. Indention as on the example,

So. Is it possible to define the different rule set for different parts of the project and is it possible, to apply different rulesets based on folder, or namespace, or at least on selection? Or maybe there is an official name for this syntax and there is already a plugin for that?




1 comment
Comment actions Permalink

Hi @Nicolay! 

Thank you for contacting us. You can EditorConfig for this purpose. Here are the details. Here you can find the list of EditorConfig Properties for Rider. 

Let us know if you need any help with it. Have a nice day!  


Please sign in to leave a comment.