3 Replies Last post: Mar 7, 2013 9:35 PM by Rennie Petersen  
Rennie Petersen Newbie 20 posts since
Apr 5, 2011
Currently Being Moderated

Mar 4, 2013 5:16 PM

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?




1: http://haacked.com/archive/2011/05/22/an-obsessive-compulsive-guide-to-source-code-formatting.aspx

Matt Ellis Apprentice 571 posts since
Jul 5, 2009
Currently Being Moderated
Mar 6, 2013 5:43 PM in response to: Rennie Petersen
Re: Feature request: source formatting to order methods by call dependencies

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.



More Like This

  • Retrieving data ...