Comments (54)
Hey folks, thought I'd leave a message here and just let you all know that we're hard at work on making Razor formatting reliable, flexible, and more importantly correct π! Please bare with us though, it's an incredibly hard area to get right and we want to make sure we're able to deliver a quality experience for everyone to use. Love all the passion though, please keep leaving your suggestions, insight and ideas!
from razor.
@enricoreich Sadly this is planned at least 2 releases out. @danroth27 just pinging you because I noticed all the thumbs up/interest on this one π
from razor.
so there is still no progress for this? after 3 years?....I mean, common you are Microsoft right? even .Net 5 is released, vs code is still not supporting razor files? Is anybody here who develop asp.net projects? how do you live with this problem? I mean, the .cshtml formatting is totally a mess.
from razor.
from razor.
lol ya it's been a while. I'd be super curious as to all of your thoughts on Razor formatting in the latest Visual Studio 2022 builds. We've done loadsssss of work in the area!
/cc @davidwengier
Since first trying preview 6 (and now using preview 7:)
Kinda drives me crazy, lol
from razor.
It's pretty sad for developers working on dotnet ecosystem not getting most required features in Microsoft own editor π
You would suggest Visual Studio convincing that, It supports almost all the things out of the box!
Yes.. okay I'm using Visual Studio while working on large projects but it gives me trouble if I need to edit some razor file on the go, an I can't use my Flash VSCode for such tasks π
from razor.
Did you have any progress to share about this issue progress?
@ponchautf It's definitely one of the most asked for features and it's something we want to accomplish sooner rather than later. That being said we're currently prioritizing other high impact issues such as colorization over this. We're still looking at 2 or so releases out for formatting to land (a few months).
from razor.
Any progress on this? On latest version we have no more "There is no formatter" message but nothing is happening! All my views are a mess, this functionality is a must!
from razor.
Lots of bug fixes as part of https://github.com/dotnet/aspnetcore/issues/26527.
Remaining known issues:
- Unable to remap projected document edits if they fall outside of known list of source mappings
- Formatting C# blocks with nested HTML removes unexpected newlines
- Unexpected indentation for multiline expressions at the start of a Razor block
- Razor LSP top-level implicit statements don't get formatted
- @{ block format on type adds New Line on pressing ';'
from razor.
I don't think we should wait anymore for that.
3 year and Vs Code / Omnisharp is still not able to handle razor markups.
formatting is a mess, many many errors, unstable, unusable.
A definitively give up ans switched to JetBrains rider, expensive but not that much regarding the time wasted with Vs code.
Visual studio for Mac is free but it's also the worst IDE I used
Microsoft : please make Visual studio Mac as goo-d as Visual studio Windows (and don't try to rely/stick too much on Mac os UI : make a good IDE, not a good Mac OS IDE).
VS code i a great text editor but not more than that.
Just good enough for Javascript (and even with JS, there sometime stupid issue)
from razor.
The last version is unusable.
I got many many issue with it:
- formating not working (and when it works, not accurate at all)
- autocompletion inject irrelevant tags (I type
<div>
and it get replaced by<DataAnnotation>
) - divs inside foreach are underlined in red (why?)
- mouse over on properties keep displaying "Loading" and nothing else
- quick navigation using cmd+click work time to time, not always (get a thin blue strip at the top of my code indicating that VS code is searching
- tags autoclose don't works anymore
- and many more small issues..
I also requested razor formating but I prefer wait for a stable version.
Is it possible to rollback to the previous omnisharp version?, 1.23.3 it too buggy to work with it
from razor.
@matijagrcic I wouldn't add it to that list because the end-goal is once Razor is functioning 100% it would take over the current "Razor" identifier. For now to avoid breaking everyone on the planet we've made a separate content type identifier (aspnetcorerazor
)
from razor.
Sounds good. We can backlog this until the prerequisites like dotnet/aspnetcore#14286 are handled.
from razor.
Thanks for the info @nastro1995, but I'm going to move your comments to a new issue.
For anyone reading this, its a lot easier for us to track things if you just create new issues for each specific problem, than trying to keep track of huge threads, and the new issues appear in our triage lists etc. so they won't get lost.
Regarding @section
directive formatting, there have been a lot of updates since this issue was created (eg #6030 for formatting content, #6402 for formatting Html following a section block, and #6531 for formatting Razor following a section block.
In fact, I'm going to go so far as to say that this issue isn't helping anyone remaining open, and I'm going to close it. If anyone has formatting issues or requests, or indeed any other bug reports or feature requests, please feel free to log new issues for them. Thanks everyone for your participation thus far!
from razor.
Really looking forward to this, any date for it?
Also should aspnetcorerazor
be added to the list at https://code.visualstudio.com/docs/languages/identifiers ?
from razor.
Razor formatting in VSCode is now available with the latest C# extension (https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.3).
We're still in the process of ironing out rough edges. Please try it out and provide feedback!
from razor.
@frankhale, I believe what you are seeing is the same underlying issue as https://github.com/dotnet/aspnetcore/issues/26736. We're looking into fixing this.
from razor.
That was also my observation... π’
from razor.
@frankhale @MarkusRodler thanks for trying it out. Something regressed in latest OmniSharp version causing our settings sync to not work. I understand this can be frustrating and we are working with OmniSharp folks on a fix and will get it resolved ASAP. In the meantime, you can disable format on save globally,
from razor.
@ajaybhargavb sorry for the late response. I will open an issue today
from razor.
@nextfool I totally agree, It's a mess, it gives me a headache every day! Specially with Blazor
from razor.
bump
from razor.
so glad to see they are doing something on this...
from razor.
Looking forward to this! Currently getting There is no document formatter for 'aspnetcorerazor'-files installed.
. I assume this will address the issue, as I do have the C# extension installed.
from razor.
Yup!
from razor.
Thanks, makes sense, wasn't sure if that was the case.
from razor.
Is there any progress on this feature?
from razor.
Hi,
Did you have any progress to share about this issue progress?
from razor.
@ajaybhargavb given we're not going to return to formatting (we got @code
formatting done for those watching this comment) till post-build how do you feel about us putting this in the backlog and out of In Progress
?
from razor.
@zmp2000, we currently have support for formatting C# code inside the @code/@functions
block. HTML formatting is not implemented yet but is definitely one of our top priorities for the near future.
from razor.
@ajaybhargavb this year?
Currently this is the sole reason using vs code for core development is unusable. Remember that preview announcement was last year.
Will this new formatting power the VS also?
UPDATE
Used as experimental in VS since the release of Visual Studio 2019 16.7 Preview 4.
from razor.
Would this also include the ability to customize code style preferences like we currently can with C# in Visual Studio using the options window or .editorconfig file? If not, is there another issue tracking that?
from razor.
Would this also include the ability to customize code style preferences like we currently can with C# in Visual Studio using the options window or .editorconfig file? If not, is there another issue tracking that?
What type of code styles are you interested in? I'd imagine C#'s code styles are respected today are they not?
from razor.
@NTaylorMullen I can think of a few use cases I would use.
- I would like to be able to have open curly braces on the same line for razor files.
- In C# we enforce the use of
this.
but might not want to for razor files since there aren't really constructors in razor files (things are injected using@inject
instead of constructors). - I would also like a way to enforce the casing of things that are injected using
@inject
. - I personally like putting my
@code
blocks above the HTML markup, if this could be a preference so that new razor components were created that way would be nice too
I'm sure I could come up with others, but those are some I can think of off the top of my head :)
from razor.
Ah I see. So sadly this effort doesn't encompass that π’
from razor.
please, is there any progress on this?
from razor.
please, is there any progress on this?
I would die for having this.
from razor.
Still pretty much the same state but the language server is now available in Visual Studio https://devblogs.microsoft.com/aspnet/new-experimental-razor-editor-for-visual-studio/
from razor.
One more like from me for this feature. Maybe itβs quite annoying for the team but this is the only reason stopping me from using VS Code as a daily driver, as Iβm using Razor most of the time.
from razor.
I am seeing weird razor formatting issues where it's easily confused specifically about HTML style markup. Here is a screenshot of VSCode 1.50 with the C# extension. Notice that the Razor formatting is confused about the markup:
If I remove the @foreach block the formatting is no longer confused and displays properly.
from razor.
@ajaybhargavb I'm with the updated VS Code v1.50.0 and C# Extension v1.23.3 but the formatting is not working for me at all. I haven't changed any default settings of the extension:
from razor.
I have the same formatting bug as already presented above. It is ok for me that it doesn't work right now. But I have a big problem with the auto-formatting on save. I can't disable it. It's running riot.
from razor.
@MarkusRodler I tried disabling Razor formatting but it doesn't work. The settings under preferences doesn't seem to do anything.
from razor.
@krispetkov, @ponchautf thanks for trying it out. Can you please file a separate issue with a repro to help investigate more?
from razor.
(re: Blazor razor component formatting): On VS Code insiders I'm seeing a different behavior. Some razor components will format correctly and some (I have @if's and @foreach's) will no longer format at all. Even the @code block won't format even though format on save is turned on. The formatting chord CTRL+K, CTRL+D will not force it to format either.
I'm kind of stuck between a rock and a hard place here. Even the formatting of razor components in Visual Studio 2019 using the experimental [yes I know] is buggy and results in so many crashes [gold bar shows and language server will be completely busted resulting in needing to restart VS].
I often find myself switching between VSCode and Visual Studio until the point I can't take one or the other anymore because of the oddities that are happening.
from razor.
lol ya it's been a while. I'd be super curious as to all of your thoughts on Razor formatting in the latest Visual Studio 2022 builds. We've done loadsssss of work in the area!
/cc @davidwengier
from razor.
If now omnisharp and VS use the same lsp, why don't you update/provide new versions to vscode?
I'd prefer to test it with vs code and it would be nice to have something like latest
there..
At the moment razor.format.enable
is completely unusable. For example it adds a newline to each line in @code{}
(even for empty line) after the format is called.
from razor.
I've noteid a weird behaviour in my solution when dealing with razor components. When the autoformat runs (which I can't seem to stop) on the insertion of a ';' character, it moves the caret to the end of the opening '@code {' line.
This is a bit disruptive, particularly in a razor component with over 1000 lines of code.
Going into the settings and changing the editor back to the legacy razor editor fixes that, but the code doesn't look anywhere near as pretty. But I may have to do so until the next update lands and I can try this out again.
from razor.
I've also managed to repro when I've created a new blazor server app.
from razor.
I've noteid a weird behaviour in my solution when dealing with razor components. When the autoformat runs (which I can't seem to stop) on the insertion of a ';' character, it moves the caret to the end of the opening '@code {' line.
This is a bit disruptive, particularly in a razor component with over 1000 lines of code.
Oh definitely! This is probably one of the most disruptive bugs we currently have. I'm sorry you're running into it :(. If it helps we have a fix queued up for 17.0.3 (hopefully mid Dec) and in 17.1-Preview2.
That work was tracked here: https://developercommunity.visualstudio.com/t/In-a-blazor-page-razor-adding-semi-c/1574500
from razor.
bump
from razor.
Running latest VS Studio 2022 as of 2022/09/08 version 17.3.3.
Still getting strange cshtml formatting with 'ctrl + k' then 'ctrl + d' to format the current document.
when the html is first and the @Sections are placed below the first @section gets formatted correctly, where any that follow or html that follow bellow those @Sections get messed up indentation.
Before updating to 17.3.3 I had 17.1.* and formatting worked fine then
(tried inputting example code to show what i mean but the formatting gets messed up when i try paste in here
Have a epic day!
from razor.
(tried inputting example code to show what i mean but the formatting gets messed up when i try paste in here
How about adding screenshots instead?
from razor.
Will do, here they are, what is strange all tags have a closing pair, even in _Layout. and all needed closing braces are there to.
from razor.
Related Issues (20)
- FUSE generating C# compile errors when non-FUSE doesn't HOT 2
- Bug while compiling #regions on SDK 8.0.400. HOT 12
- Formatting issues with block bodied lamdas
- [Automated] PRs inserted in VS build main-35214.137
- Port CodeActions endpoints to cohosting
- Port Formatting endpoints to cohosting
- Port InlineCompletion endpoint to cohosting
- Port MapCode endpoint to cohosting
- Port SpellCheck endpoint to cohosting
- asp.net core autoformatting problem
- Blazor : razor editor does not suggest any intellisense options, until I enter a character and then delete it, then it works fine
- Razor Syntax Highlight & Intellisense Issues in VS2022 17.10.x when use symbolic link HOT 1
- [Automated] PRs inserted in VS build feature.debugger.main-35215.202
- Improve Blazor CascadingTypeParameter support - Current compiler cannot handle common scenarios. HOT 2
- Editor went and remained in a completely out of sync/broken state HOT 4
- Suggestion: @style directive similar to scoped CSS files
- Finish "Display" endpoints for cohosting
- Highlight and drag no longer working
- [Automated] PRs inserted in VS build main-35220.126
- Constant RZ10012 errors in vscode when using components from library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from razor.