format icon indicating copy to clipboard operation
format copied to clipboard

Support formatting .cshtml and .razor files

Open mort3za opened this issue 6 years ago • 7 comments

I just tried
dotnet-format --files Home/Home.cshtml on my razor template but seems it does not read it at all.
(But tried on other filetypes and works great).
Is razor templates supported?

mort3za avatar May 15 '19 08:05 mort3za

@mort3za Sorry but dotnet-format does not currently work with razor files. We would like to support razor scenarios in the future.

JoeRobich avatar May 24 '19 17:05 JoeRobich

Is this still a thing? Are there any alternative linters/formatters for razor or cshtml syntax?

DefinitelyADev avatar Oct 23 '20 18:10 DefinitelyADev

/cc @ajaybhargavb for curiosities sake. It'd be a suppper hard problem to do right if we're taking into account things like TagHelpers/Components 😄

NTaylorMullen avatar Oct 23 '20 21:10 NTaylorMullen

Is there even editorconfig support for razor files (outside of the basic spacing, encoding, and line endings)? Yesterday I was trying to set them up to use K&R style braces while my .cs files used Allman but the format feature in VS wasn't formatting the razor files with the new expected brace style. It seems like whatever you pick for your c# settings gets used for all c# code instead of letting you have settings based on the file extension.

xt0rted avatar Oct 24 '20 22:10 xt0rted

Still looking for a CLI solution to format .cs, .cshtml and .razor files.

jordan-cote avatar Feb 10 '21 14:02 jordan-cote

can't dotnet format just format the content from the @code { } block from razor files?

seriouz avatar Jul 23 '21 15:07 seriouz

Any updates on this?

somegenericdev avatar Feb 08 '24 15:02 somegenericdev