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

[BUG] Razor Formatting no longer works? #218

Closed
seangwright opened this issue Jul 1, 2023 · 5 comments · Fixed by dotnet/vscode-csharp#6236
Closed

[BUG] Razor Formatting no longer works? #218

seangwright opened this issue Jul 1, 2023 · 5 comments · Fixed by dotnet/vscode-csharp#6236
Labels
Milestone

Comments

@seangwright
Copy link

seangwright commented Jul 1, 2023

Describe the Issue

Should Razor formatting be working? It definitely worked before I switched to the new DevKit.

Here's a video reproducing the issue

vscode-razor-formatting-not-working.webm

Here are my relevant VS Code workspace settings:

"editor.formatOnSave": true,
"emmet.includeLanguages": {
    "aspnetcorerazor": "html"
  },
  "[csharp]": {
    "editor.defaultFormatter": "ms-dotnettools.csharp"
  },
  "[aspnetcorerazor]": {
    "editor.defaultFormatter": "ms-dotnettools.csharp"
  }

I hope I'm logging this issue in the correct repository, but as a related note, I now have a really difficult time understanding which parts of the tooling is controlled by each repository

Maybe it would be a good opportunity for a ASPNET Core Community standup episode for someone to explain all of these for the community. 🤔

Steps To Reproduce

  1. Create a Razor file
  2. Author some C# and HTML that should be formattable
  3. Format the document
  4. See nothing happens

Expected Behavior

The HTML, Razor and C# is all formatted correctly

Environment Information

  • OS - Windows 11 Pro
  • ms-dotnettools.csharp - 2.0.248
  • ms-dotnettools.csdevkit - 0.2.99
  • VS Code - 1.79.2
  • .NET SDK installed - 8.0.0-preview.5.23280.8
  • global.json
    	{
    	  "sdk": {
    	    "version": "6.0.403",
    	    "rollForward": "latestMajor",
    	    "allowPrerelease": false
    	  }
    	}
  • .NET SDK in use 7.0.305
@seangwright seangwright added the bug Something isn't working label Jul 1, 2023
@leandro-regis
Copy link

I'm facing the exact same problem, but in my case I notice if I cut the line @model and try the formatting command, it works.
It also works if I comment the @model line and run the formatting command, then after formatting I uncomment the line.
So now when I have a .cshtml file and I want to format I cut the line and re-past it, or I comment the @model line and after formatting I uncomment.

Environment Information

  • OS - Windows 11 Pro
  • ms-dotnettools.csharp - v2.0.328
  • ms-dotnettools.csdevkit - v0.3.21
  • VS Code - 1.81.0
  • ..NET SDK in use - 7.0.304

@allisonchou
Copy link
Member

@webreidi This issue is fixed pending release via dotnet/vscode-csharp#6236, however I don't have permissions to close this issue. Could you do it on my behalf? Thanks!

@seangwright
Copy link
Author

seangwright commented Aug 28, 2023

@allisonchou thanks for the work tracking down this issue and resolving it 🙏! Which extension gets the fix and which version is it fixed in? Is this something I can test in my code today?

@allisonchou
Copy link
Member

@seangwright The fix should be in today's C# extension release (2.0.436). Could you try the new version and let us know if you still see the problem? Thanks!

@seangwright
Copy link
Author

Everything looks good now! I can format Razor views and even my _ViewImports.cshtml which would completely break after a format previously.

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants