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

.razor files don't use C# formatting settings #10250

Open
vsfeedback opened this issue Apr 11, 2024 · 0 comments
Open

.razor files don't use C# formatting settings #10250

vsfeedback opened this issue Apr 11, 2024 · 0 comments
Labels
author: migration bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author feature-formatting

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:It’s more difficult to complete my work]
Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.9.6
No formatting extensions installed.

When I type a closing brace } in a C# .razor file, the opening brace { is moved to a new line.
These are my options:
Text editor > Code Cleanup > Run Code Cleanup profile on save: ☐
Text editor > C# > General > Automatic brace completion: ☐
Text editor > C# > Code Style > Formatting > General > all ☐
Text editor > C# > Code Style > Formatting > New lines > New line options for braces: all ☐

Example before:

	private void OnPriceClick() {
		OrderBy(x => x.Price);
	}
  

Action: remove closing brace and add it back in the same spot.

Example after:

	private void OnPriceClick()
	{
		OrderBy(x => x.Price);
	}
  

Edit: I realised that the C# code is inside a .razor file and not a .cs file. This matters a lot as razor files have their own settings. Formatting works fine in .cs files.
I can mitigate the issue by disabling Text editor > Razor (ASP.NET Core) > Advanced > Format On Type
This reduces the severity.


Original Comments

Feedback Bot on 4/11/2024, 01:12 AM:

(private comment, text removed)


Original Solutions

(no solutions)

@dotnet-policy-service dotnet-policy-service bot added untriaged author: migration bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author labels Apr 11, 2024
@phil-allen-msft phil-allen-msft added this to the 17.11 Planning milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author: migration bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author feature-formatting
Projects
None yet
Development

No branches or pull requests

2 participants