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.89k stars 356 forks source link

CodeMaid adding tabs that shouldn't be there #858

Open jws305 opened 2 years ago

jws305 commented 2 years ago

Environment

Description

Cleanup Active Document causes block to add an indent every time it is run, i.e. if I run the task 5 times, I get 5 tabs in front of the block.

Steps to recreate

  1. Clone https://github.com/jws305/CodeMaidIndentIssue
  2. Run Cleanup Active Document on Program.cs

Current behavior

Erroneous tabs added

Expected behavior

The result of the cleanup should be deterministic.

AndreiYakovlev commented 2 years ago

Me too but codemaid adding spaces

codecadwallader commented 2 years ago

Thanks for reporting the issue. I am able to reproduce it and that is unexpected. I suspect it is something specific with this code segment:

        private static Lazy<int> Item { get; } = new Lazy<int>(() =>
        {
            return 1;
        });
codecadwallader commented 2 years ago

It looks to be tied to the insert explicit access modifiers logic on properties. If that option is turned off the behavior stops.

DamianSuess commented 2 years ago

It goes without saying, this is also affecting VS 2019 (16.11.4).

DamianSuess commented 2 years ago

To validate, this is the symptom of the bug, correct? The example is from our ViewModel using Prism Library, which as you can imagine uses a lot of DelegateCommand Properties.

Before:

    public DelegateCommand OnShowMain => new DelegateCommand(async () =>
    {
        await NavigationService.NavigateAsync($"../{nameof(MainView)}");
    });

After: (note single space indention after Ctrl+M+Space)

    public DelegateCommand OnShowMain => new DelegateCommand(async () =>
     {
         await NavigationService.NavigateAsync($"../{nameof(MainView)}");
     });
codecadwallader commented 2 years ago

Yes, I believe if you disable the options around inserting explicit access modifiers that will bypass the SDK bug and avoid the issue.

wx0322 commented 1 year ago

Yes, I believe if you disable the options around inserting explicit access modifiers that will bypass the SDK bug and avoid the issue.

thanks, solve my problem.