Major Bug: Alt-Enter fix variable name doesn't add FormerlySerialzedAs for Unity

Answered

So I just pretty much destroyed a huge swath of code and had to revert back to an earlier git version because of what I consider to be a pretty major bug/oversight in how Rider works when "fixing" a variable name.

I am porting some old Unity code into a new project that has different naming standards.  I set Rider up for the new naming standards and then started going through files, and using Alt+Enter on the old names ad choosing the suggested "proper" name.  This renames the variable properly as expceted but does NOT add a FormerlySerializedAs() decoration.  Same with if you Alt+Enter and choose to fix it in a larger scope such as all in file.

It appears that Rider only adds the proper decoration if I Refactor->Rename or CTRL + R,R which makes he process infinitely slower as not only do I have to type he new name manually rather than let Rider just give me the proper name under the new rules, but I have to do it for each and every field manually rather than all in file.

Lots of egg on my face after touting how amazing Rider is to my team :(

6 comments
Comment actions Permalink

Hi John! 

Let me try to help you. What is your version of Rider and Unity? Had your variable [SerializeField] attribute? Please, attach a screencast where you reproduce the issue, it'll help a lot. 

Thank you in advance! 

0
Comment actions Permalink

If anyone else is having this issue, you first have to rename a variable using Refactor -> Rename or Ctrl + R, R and in the prompt that appears, make sure the checkbox next to 'Add FormerlySerializedAs attribute' is checked. So long as it is checked the last time you did an individual field rename refactor, then it will default to this behaviour when renaming via Alt+Enter or in a batch rename in a larger scope.

0
Comment actions Permalink

skatebee, it should be fixed already as the result of RIDER-12298. If you still experience it, please add a screen recording showing the case. Thank you in advance! 

0
Comment actions Permalink

Hi Olga,

Here is a recording of the behaviour I described in using Rider 2021.2.3 (I also reproduced the same behaviour after updating to 2021.3.2)

To clarify though, I don't think it is a bug; it seems to be this way by design. The Rename prompt allows you to decide whether you want FormerlySerializedAs added when doing subsequent batch name fixing. It isn't super obvious though so I posted here in case anyone else encountered the same problem. Apologies if my description is a bit confusing.

0
Comment actions Permalink

The issue is that when you rename a SINGLE variable the rename dialog comes up and let's you set FormerlySerializedAs properly but if you rename MULTIPLE variables it does not.  It uses whatever your previous setting was.

So if you rename one thing and choose not to mark it, then you rename a whole bunch of things, it also defaults to not marking them.  That is the bug.  The bug IMHO is it should ask regardless not just default to your previous choice.

0
Comment actions Permalink

There is a request for settings option to make adding it or not customizable: RIDER-63450, which should be solution for this.

0

Please sign in to leave a comment.