C
C#3d ago
AnnaSasDev

Auto Code Cleanup moves top comments in razor file

Hey there, Ive been stuck on an editor, Rider, issue for a while now, but cant find anything on how to solve it In my razor files (a blazor component, not an @page) I often have a comment at the top of the page, with underneath it @using statements, but when I "Reformat and cleanup" the code, by right clicking on the file, it moves the code about so the @using statements are at the top, and then being followed by the comments which werte at the top of the file beforehand. I cant find anything in the rider docs, or the .editorconfig that could help me so far... Anyone have a solution to this?
3 Replies
AnnaSasDev
AnnaSasDevOP3d ago
I know that using code behind cs files will solve this issue, but for small components requiring a code behind will make th code less readable in my opinion, so that isnt a good fix for me
glhays
glhays3d ago
First I am not a Rider user, but feel that this is similar to VS using headers so that they are always top most in a file. the best I can find for setting it up in Rider is to set up you comment block in the Editor >Code Style>C# Enter a Comment Block in the template box. May do some searching on setting up Headers in Rider see what options are available.
Lex Li
Lex Li3d ago
Bug reports/feature requests of Rider should go to https://youtrack.jetbrains.com/issues/rider You won't often meet JetBrains folks elsewhere. (Similarly if you hit VS issues, you should use the correct Microsoft channels).

Did you find this page helpful?