Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong indentation when using primary constructor #2165

Open
aserrabi opened this issue Apr 2, 2024 · 0 comments
Open

Wrong indentation when using primary constructor #2165

aserrabi opened this issue Apr 2, 2024 · 0 comments

Comments

@aserrabi
Copy link

aserrabi commented Apr 2, 2024

using Microsoft.AspNetCore.Mvc;

namespace Web.Controllers;

[Route("test")]
public class TestController : ControllerBase
{
  private readonly ILogger<TestController> logger;

  public TestController(ILogger<TestController> logger)
  {
    this.logger = logger;
  }

  [HttpPost("test/{id}")]
  public ActionResult Test(string id)
  {
    this.logger.LogInformation("Hello {Id}", id);
    return this.Ok("Format me");
  }
}
  • When I run dotnet dotnet-format the file is formatted as follows:
image
  • After some time digging into the problem I realized that changing the primary constructor to a regular constructor fixes the issue. And dotnet-format will not format wrongly the file.
image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant