codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.88k stars 353 forks source link

"Insert explicit modifiers on methods" overrides "Place single line method braces on separate lines" #986

Open TimothyMakkison opened 1 year ago

TimothyMakkison commented 1 year ago

Environment

Description

Insert explicit modifiers on methods overrides update single line methods by placing them on new lines

Steps to recreate

  1. Enable Insert explicit modifiers on methods and update single line methods by placing them on new lines.
  2. Cleanup code with a single line method. ie:
    public class MyClass
    {
    public void Do() { Console.WriteLine("Hello World"); }
    }
    // Becomes 
    public void Do() 
    { Console.WriteLine("Hello World"); }
    // Instead of 
    public void Do() 
    { 
    Console.WriteLine("Hello World"); 
    }

Current behavior

Method body is moved to a new line without placing braces on separate lines.

Expected behavior

Braces should be placed on separate lines.

Solution

InvokeUpdateSingleLineMethods before InsertExplicitAccessModifiersOnMethods:

...
_insertExplicitAccessModifierLogic.InsertExplicitAccessModifiersOnStructs(structs);

_updateLogic.UpdateSingleLineMethods(methods);

_insertExplicitAccessModifierLogic.InsertExplicitAccessModifiersOnMethods(methods);
...
codecadwallader commented 1 year ago

Thanks for reporting the issue. I believe similar to the previous issue (#983) the root cause of why it is getting split onto a separate line may be related to the VS SDK issue (see #879 for details).