roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

RCS0053 - does some strange formatting

Open prezaei opened this issue 6 months ago • 4 comments

Product and Version Used: NuGet package - 4.12.4

Steps to Reproduce: Enable the rule

Example 1

Actual Behavior:

    private static readonly FrozenSet<string?> SomeThing =
        SomeFunction
            .Concat(
                [
                    // some comment
                    null,
                    ])
            .ToFrozenSet();

Expected Behavior:

    private static readonly FrozenSet<string?> SomeThing =
        SomeFunction
            .Concat(
            [
                // some comment
                null,
            ])
            .ToFrozenSet();

Example 2

Actual Behavior:

        return new DefaultAzureCredential(new DefaultAzureCredentialOptions
            {
                ManagedIdentityClientId = clientId,
                ExcludeWorkloadIdentityCredential = true,
                Diagnostics =
                        {
                            IsAccountIdentifierLoggingEnabled = diagnosticsEnabled,
                            IsDistributedTracingEnabled = diagnosticsEnabled,
                            IsLoggingEnabled = diagnosticsEnabled
                        }
            });

Expected Behavior:

        return new DefaultAzureCredential(new DefaultAzureCredentialOptions
        {
            ManagedIdentityClientId = clientId,
            ExcludeWorkloadIdentityCredential = true,
            Diagnostics =
            {
                IsAccountIdentifierLoggingEnabled = diagnosticsEnabled,
                IsDistributedTracingEnabled = diagnosticsEnabled,
                IsLoggingEnabled = diagnosticsEnabled
            }
        });

Issue:

So, what is wrong with the above?

  • In example 1 open and end brackets have different indentations
  • It adds an extra indentation level when one is not needed (see the outer layer in example 2). This conflicts with the default formatter in VS as well.
  • If dotnet format is run more than once, it seems to indent Diagnostics in example 2 more than once.

prezaei avatar Aug 10 '24 23:08 prezaei