Code completion in Unity project is extremely frustrating

Answered

I've been having this issue regularly for the past 6 months or so, and I keep hoping it gets fixed with every new version but it keeps reoccurring. Every time I type out Vector3 I expect it to suggest the obvious type of "UnityEngine.Vector3" but Rider always suggests 'System.Numerics.Vector3' as the top pick. My files always have "using UnityEngine" so why on earth would it suggest a brand new type to import? Have I misconfigured my project somehow?

 

Also, maybe this is another configuration issue, but another common frustration is when I'm trying to create a new List<T> the "new" auto-complete suggestion can take 3-4 seconds to show up, so I end up having to type out the entire name of the type manually which kind of sucks. Definitely makes me reconsider why I'm paying for Rider.

 

Any suggestions on fixing either of those would be great. 

3
18 comments

I completely agree.  I posted about a similar problem here:

https://rider-support.jetbrains.com/hc/en-us/community/posts/360003397200-How-to-tell-Rider-which-assembly-to-get-a-symbol-from-

Rider keeps trying to autocomplete to the wrong assemblies.

0
Avatar
Permanently deleted user

Oh wow, so they definitely aren't reading these forums at all then. I'm pretty disappointed with JetBrains, this should be basic stuff but it's been a recurring nightmare lately. Might be time to switch back to Visual Studio to save my sanity.

0

Hello Jesse,

We do read these forums, please accept our sincere apologies for the delayed reply.

As a workaround, you can turn off "Show import items in basic completion" checkbox in "File | Settings | Editor | General | Code Completion". With this setting disabled, Rider won't suggest non-imported symbols in the completion.

We've adjusted completion in Rider 2019.1, and these bugs are most likely fixed there. Please let us know if you observe similar behavior on Rider 2019.1 EAP build or the stable release (planned for this month). 

0
Avatar
Permanently deleted user

Hi Julia,

Thanks for the reply. I did figure out that turning off 'Show import items" would fix it, but then how can I access code completion that _does_ show the import items? The keyboard shortcuts settings only shows a "Basic" and "SmartType" completion, neither of which show import items when that checkbox disabled. I've looked everywhere for some documentation on how to do this, but nothing seems to work - even the "Class Name Completion" (which is not even under the 'Completion' category in the settings) doesn't show imports.

I checked out the EAP build and it does seem to have those specific import issues fixed. However, other fundamental things are completely broken (adding a new file doesn't seem to be recognized by the project at all, until I restart Rider), so now I have two equally frustrating options to choose from.

I didn't even have this many issues using old versions of MonoDevelop that came bundled with Unity. Very disappointing.

0

Do I understand correctly, that in Rider 2019.1 the completion works well even with "Show import items" enabled? 

>adding a new file doesn't seem to be recognized by the project at all, until I restart Rider

Could you please provide steps to reproduce this? It looks major.

0
Avatar
Permanently deleted user

I have similar frustrations. Here is one example...

 

0

Hi Paul,

I've reproduced this issue and filed a ticket on Rider tracker: https://youtrack.jetbrains.com/issue/RIDER-49885. Please feel free to vote for it to subscribe for updates.

 

Sofia.

0
Avatar
Permanently deleted user

Thank you Sofia Byzova 🙂

Here is another example...

2

This problem still persists in 2021.3.3, and it's driving me bonkers! I honestly cannot understand why it would pre-select the Vector2 or Vector3 type that no import exists for in the file, when there is a Vector2 or Vector3 type for which one does exist in the file. 

Will implement the workaround, just wanted to note that it's still incredibly frustrating. 

[EDITED TO ADD]

Even with the workaround, and "uses UnityEngine" defined, Rider will auto-insert the fully-qualified type name? This is incredibly frustrating. Annoying enough to make me consider switching back to VS :(

1

Looking for somewhere to post this and this conversation seems mostly related. It would be so helpful to be able to mark a selection as the "best" selection or mark a suggestion as "less helpful". Even just be able to reset the algorithm that sorts would be great. The most frustrating situation to me is when a bad suggestion will get stuck above something that I use all of the time (like the Debug example above)

This is me right now

2

Lynlisten, please check Preferences | Editor | General | Code Completion | Machine Learning Assisted Completion. If it is enabled, you can try disabling it, then it will use ranking mechanism. If ranking mechanism still does not show the results you choose more often, then you can try clearing caches via File | Invalidate Caches. It will take some time to collect statistics. If it still does not help anyway, then please open an issue on our tracker and attach more information like: logs and specific example when it does not work as expected. Please let me know how it goes.

2

Since the last version, Turning off Machine Learning Assisted Completion has done nothing to stop this problem.  

Right now, if I type Vector3. as soon as I  hit the ., Rider quietly adds

using Vector3 = System.Numerics.Vector3;

and errors ensue.  It's far from the only autosuggestion that has been blowing up lately (Random, obviously).  Virtually every single Unity class that has an analogue in System (Random, Image come immediately to mind), Rider is autoselecting one from the System subset instead of the UnityEngine subset, even if the only using clause is UnityEngine.  

When the choice is obvious (for example, I have a class Fighter in namespace Fighting), and there are no ambiguous references in the assembly, then adding using Fighting automagically is handy, but that often doesn't happen at all, just setting Fighter to red when I reference it without the using.  That's ok, I can click on import types and fix it.  Perhaps an option in settings to not automatically add using $name$=$namespace$.$name$ when disambiguation is needed.  In the case of the Vector3 issue, this would simply solve it.  In the case of UnityEngine.Random vs System.Random, this would yield a cannot determine error and allow us to select the correct one (although if not using System, the first case should apply). 

1

Mnemoth42, you can specify namespaces that you do not want to be added in Preferences | Editor | General | Auto Import. As for the issue itself, could you please specify the exact Rider version, OS, and RiderEditor package version in Unity package manager?

0

Turning off "Machine Learning Assisted Completion" and then restarting Rider worked for me.  Vector3 from System.Numerics is still there but at least ranked below the Vector3 with the actual using statement in the class.

Just turning it off wasn't enough.  A restart of Rider was required.

At some point i have to wonder if the ML is training on people accidentally choosing the wrong one with auto-complete and then manually fixing it is outside the training set, lol.

0

For anyone facing this issue, here you go!

Add System.Numerics.* to the exclude filter

2

Good tip! Thank you rshea0, that should help! 

I cannot possibly adequately express how annoying Rider is in this regard. 

I was completely ready to rage-quite Rider today after like the hundredth time in the last three days (literally, not an exaggeration) that Rider auto-suggested and highlighted the System.Numerics.Vector2 type and I mistakenly accepted it (because in over thirty years of software development I've never encountered an editor this persistently wrong and it's just muscle memory).

Hopefully now I'll never see that particularly annoying situation again (at least for this type, lol).

 

To highlight the depth of frustration I experienced, Rider auto-suggested the wrong darned type literally every time I typed “Vector” in the code snippet below 😠

 

0

This is an incredibly annoying issue which we have been experiencing for a long time.

We have the problem with Vectors like everyone has been saying above.

We have a problem where when I type “Des” in a method inside a of a class derived from MonoBehaviour it suggests DES from System.Security.Cryptography instead of Destroy, which is crazy because DES matches what I have type LESS than Destroy AND it requires an extra import. Surely in this case Destroy, which matches what I have typed more AND is a method in the parent class, should match more than DES.

 

Or I have a variable called “existing” in a method and when I type “ex” it suggests the class ex from UnityEditor.Localization.Plugins.XLIFF.V12 instead of the local variable literally declared on the line above! Again surely my local variable should match more as it doesn't require an additional import statement.

 

Also when trying to override a method in a parent class, Rider doesn't suggest creating the override method unless I have explicitly typed “override” first:

 

Whilst turning off "Show import items in basic completion" checkbox in "File | Settings | Editor | General | Code Completion" as suggested does “fix” some of these issues, it defeats the object of the suggestions in cases where the thing you are typing hasn't yet been imported (i.e. every time you create a new class file and there are no imports, it's a pain every time you type List that it isn't suggested)

Manually ignoring the problem namespaces also “fixes” the issue but again it defeats the point of it in the cases where you want to see those suggestions.

I have tried all the combinations of the “Match case” “First letter only” and “All letters” settings however this doesn't improve the DES situation even though it it sounds like it should.

I have Preferences | Editor | General | Code Completion | Machine Learning Assisted Completion disabled.

Using JetBrains Rider 2024.1.4 Build #RD-241.18034.76

0

Please sign in to leave a comment.