thanks for your respond.I've looked at your example, and I do get the same behaviour. Reformatting is working fine, just not the reordering of the code. For example. moving properties to the top of the file.
I know regions are a common issue with reordering, so my idea was as following:
- comment all regions as 1st step
- run all Telerik JustCode clean steps
- uncomment all region as last step
For that, I've written 2 custom codeclean steps in 2 separate codecleaning classes.
1 for commenting regions, Order = 1
1 for uncommenting regions, Order = 99999
If I run the above steps with both my custom codeclean steps, the ordering of the code does not work (the Telerik JustCode reordering).
If I disable my 'uncomment all region as last step' then it all works. Regions do get commented, and the code gets reordered as well.
So somehow my step conflicts with the reordering. So I wonder if it has something to do with the execute order of the steps. Or perhaps I replace the lines in the 'comment all regions as 1st step' wrong.
Here the code I use to comment the regions, and this is how it is called in the step:
public static void Comment(this IPreProcessorDirectiveLine line)
line.FileModel.ReplaceTextually(line.TextualCodeSpan, "/*" + line.Text.ToLower().Trim() + "*/");
public override void ExecuteCodeCleaningStep(CodeCleaningStep step, FileModel fileModel, CodeSpan span)
.Where(line => line.IsRegion())
.ForEach(region => region.Comment());
Note: I'm aware that I have no guarantee the regions will remain intact in the code, or that code I moved / reordered inside regions, but that is ok :).