belav / csharpier

CSharpier is an opinionated code formatter for c#.
https://csharpier.com
MIT License
1.41k stars 98 forks source link

"Failed syntax tree validation" when using `dotnet csharpier .` #1389

Open rcdailey opened 16 hours ago

rcdailey commented 16 hours ago

Environments:

Steps to reproduce:

Run dotnet csharpier . at the root of my project.

Expected behavior:

No errors.

Actual behavior:

PS C:\code\recyclarr> dotnet csharpier .
Error ./tests/Recyclarr.Tests/Config/ConfigExtensionsTest.cs - Failed syntax tree validation.
  ----------------------------- Original: Around Line 35 -----------------------------
              new RadarrConfiguration
              {
                  InstanceName = "valid_NAME" // Comparison should be case-insensitive
              }
          };

          var invalidInstanceNames = configs.GetInvalidInstanceNames(new ConfigFilterCriteria
          {
  ----------------------------- Formatted: Around Line 0 -----------------------------
  using Recyclarr.Config;
  using Recyclarr.Config.Models;
  using Recyclarr.TrashGuide;

  namespace Recyclarr.Tests.Config;

  [TestFixture]
  public class ConfigExtensionsTest
Formatted 485 files in 617ms.

Here's the test fixture method in question:

[Test]
public void Filter_invalid_instances()
{
    var configs = new[]
    {
        new RadarrConfiguration
        {
            InstanceName = "valid_NAME", // Comparison should be case-insensitive
        },
    };

    var invalidInstanceNames = configs.GetInvalidInstanceNames(
        new ConfigFilterCriteria { Instances = ["valid_name", "invalid_name"] }
    );

    invalidInstanceNames.Should().BeEquivalentTo("invalid_name");
}

I don't know what the error means, and it doesn't appear again when I run the command a second time. I wanted to share the issue here in case it might be a bug. If it's not, please feel free to close this.