Skip to content

C# formatter returning invalid edits for some Razor scenarios #4298

@allisonchou

Description

@allisonchou

After typing } in the scenario below (see location of $$), the following debug assertion is hit in FormattingDiagnosticValidationPass:

Debug.Fail("A formatting result was rejected because the formatted text produced different diagnostics compared to the original text.");

{@if (true)
{
    <div>
        @if (true)
        {
            <strong></strong>
        }
        else if (false)
        {
            }$$

        if (true)
        {
        }
    </div>
}}

Upon initial investigation, the C# formatter seems to be returning edits which when applied deletes some code. We ultimately end up with the correct formatting (the Razor formatter seems to fix the wonky indentation), but we should investigate why the C# formatter is returning to us invalid edits.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions