Skip to content

Failed syntax tree validation reported, but input and output code look OK #1388

@edyoung

Description

@edyoung

Csharpier version 0.30.1

Input:

using System.Text.Json;

namespace Microsoft.Azure.HybridCompute.Shared.DataModel.Entities.NetworkSecurityPerimeter;

public class NSPValidationData
{
    public NSPValidationData()
    {    
        var accessRulesResponsePayload = new Dictionary<string, List<int>? >
        {
            { "value", accessRulesResponseModel } // NSP data plane library expects this format
        };     
    }

    
}

Command line Output:

> dotnet csharpier test.cs
Error ./test.cs - Failed syntax tree validation.
  ----------------------------- Original: Around Line 10 -----------------------------
          var accessRulesResponsePayload = new Dictionary<string, List<int>? >
          {
              { "value", accessRulesResponseModel } // NSP data plane library expects this format
          };
      }


  }
  ----------------------------- Formatted: Around Line 0 -----------------------------
  using System.Text.Json;

  namespace Microsoft.Azure.HybridCompute.Shared.DataModel.Entities.NetworkSecurityPerimeter;

  public class NSPValidationData
  {
      public NSPValidationData()
      {
Formatted 1 files in 213ms.

file output

using System.Text.Json;

namespace Microsoft.Azure.HybridCompute.Shared.DataModel.Entities.NetworkSecurityPerimeter;

public class NSPValidationData
{
    public NSPValidationData()
    {
        var accessRulesResponsePayload = new Dictionary<string, List<int>?>
        {
            { "value", accessRulesResponseModel }, // NSP data plane library expects this format
        };
    }
}

Expected behavior:
There doesn't seem to be an issue with the syntax tree, so I don't expect to see an error reported.

If I remove the comment, and change the input to the file below, I don't see any error.

using System.Text.Json;

namespace Microsoft.Azure.HybridCompute.Shared.DataModel.Entities.NetworkSecurityPerimeter;

public class NSPValidationData
{
    public NSPValidationData()
    {    
        var accessRulesResponsePayload = new Dictionary<string, List<int>? >
        {
            { "value", accessRulesResponseModel } 
        };     
    }

    
}

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