Skip to content

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

@Rudomitori

Description

@Rudomitori

Environments:

  • CSharpier Version: 0.27.0
  • Running CSharpier via: dotnet cli
  • Operating System: Windows 11
  • .csharpierrc Settings: No
  • .editorconfig Settings: No

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
  );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions