Better code formatting rules for fluent interfaces and object initializers.

MpdreamzMpdreamz USMember

Fluent interfaces are very jumpy and I cannot control how they should behave in the editor.

expected behavior:

->keyword\n
->->.Method(a=>a
->->->.Method()
->->)
->->.AnotherMethod();

I cant control object initializers to put their opening bracket on the new line either.

Lastly it would be really cool if we could checkin the formatting rules as part of a project so that every developer formats the code the same without every developer having to dig through the code formatting window.

Posts

  • MpdreamzMpdreamz USMember

    I think part of the problem is that in the following peace of code:

    var mapResult = this._client.MapFluent<WorkOfArt>(m => m
        .IndexName(_currentIndexName)
        .MapFromAttributes()
        .Properties(WorkOfArtPropertyMapping)
    );
    

    Xamarin will try align the .IndexName() method call to the first m of m => m which is never what you want.

  • mhutchmhutch USMember, Xamarin Team Xamurai

    Regarding your last point, formatting policies are always embedded in the solution, so all developers working on a solution have the same formatting settings. So you should make sure you edit the solution formatting settings - your preferences only apply to new projects.

    If there are formatting behaviours you can't achieve with the current formatting settings, please file a bug.

Sign In or Register to comment.