Skip to content

RCS0053 - does some strange formatting #1498

@prezaei

Description

@prezaei

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions