belav / csharpier

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

"Failed syntax tree validation" for raw string literals #1129

Closed Rudomitori closed 10 months ago

Rudomitori commented 10 months ago

Environments:

Steps to reproduce: Try to format the following code:

var expectedTypeProp = "otherTestComponent";
var expectedLabel = StableRandom.Shared.GetString();
var expectedText = StableRandom.Shared.GetString();
var expectedDisplayName = StableRandom.Shared.GetString();

var node = JsonSerializer.Deserialize<SerializedNode>(
    $$"""
      {
          "props": {
              "type": "{{expectedTypeProp}}",
              "label": "{{expectedLabel}}",
              "text": "{{expectedText}}"
          },
          "hidden": false,
          "nodes": [],
          "linkedNodes": {},
          "displayName": "{{expectedDisplayName}}",
          "type": {
              "resolvedName": "testComponent"
          }
      }
      """,
    _options
);

Expected behavior: No error is outputed

Actual behavior: CSharpier formats the code and outputs an error:

Failed syntax tree validation.
  ----------------------------- Original: Around Line 20 -----------------------------
                "resolvedName": "testComponent"
            }
        }
        """,
      _options
  );
  ----------------------------- Formatted: Around Line 20 -----------------------------
              "resolvedName": "testComponent"
          }
      }
      """,
      _options
  );