Skip to content

Wrong IDE0055 in combination with CRLF, XML comment and preprocessor directive #73122

@mus65

Description

@mus65

Version Used:

.NET SDK 8.0.204

Steps to Reproduce:

The following code will report IDE0055 on line 2, but only if the file has CRLF line endings:

namespace Ide0055Bug
{
    /// <summary>
    /// test.
    /// </summary>
#pragma warning disable TEST
    [Serializable]
#pragma warning restore TEST
    public class Class1
    {

    }
}

The warning disappears if you either:

  • change the file to LF
  • remove the XML comment
  • remove the pragma directive

I created a repo with a reproduction: https://github.com/mus65/Ide0055Bug

dotnet build reports:

Ide0055Bug/Class1.cs(2,2): error IDE0055: Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

dotnet format Ide0055Bug.csproj whitespace --verify-no-changes reports:

Ide0055Bug/Class1.cs(2,2): error WHITESPACE: Fix whitespace formatting. Replace 6 characters with '\n\s\s\s\s'. [Ide0055Bug/Ide0055Bug.csproj]
Ide0055Bug/Class1.cs(7,1): error WHITESPACE: Fix whitespace formatting. Replace 4 characters with '\s\s\s\s'. [Ide0055Bug/Ide0055Bug.csproj]

this was noticed in sshnet/SSH.NET#1380

Diagnostic Id:

IDE0055

Expected Behavior:

no IDE0055 warning.

Actual Behavior:

IDE0055 warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugResolution-Not ReproducibleThe described behavior could not be reproduced by developershelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    Status

    Completed

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions