Feature request: source formatting to order methods by call dependencies
As an advanced sufferer of Obsessive Compulsive Source Code Formatting Disorder*1, I like to have the methods in my C# source code files ordered with the high-level ones first, followed by the ones called by the high-level ones, etc., and the low-level methods that don't call other methods (in that source file) at the end.
Could you consider implementing this in ReSharper?
If not, would DotPeek be able to provide me with the necessary dependency links so I could try to do it myself?
Thanks.
1: http://haacked.com/archive/2011/05/22/an-obsessive-compulsive-guide-to-source-code-formatting.aspx
Please sign in to leave a comment.
Or would it maybe be easy to do this as a ReSharper plugin?
It should be possible to write a plugin that re-orders in this fashion (I think Uncle Bob describes this as the Step-Down Rule in Clean Code). The current reordering happens as part of code cleanup - it's implemented in the class ReorderTypeMembers, which implements ICodeCleanupModule. In the end, it calls into CSharpFormatterHelper's ReorderMembers extension method, which reorders members based on an XML file that describes various rules for ordering. (It's quite a meaty file - this blog post provides an introduction:http://blogs.jetbrains.com/dotnet/2011/01/in-depth-look-at-customizing-type-layout-with-resharper/) These classes should give you an idea of how it could be implemented.
Thanks
Matt
Matt, thank you very much for this information. I'll try to find the time to look into it.