Turning off auto import of using statements

Answered

Using Rider with Unity. 
Ran into this problem multiple times already. If I make a typo and press Enter, and if this typo is recognized by Rider as one of the classes/namespaces, Rider might auto-complete and add some using statements that will not allow me to build a project in Unity. For example, it might add:
using UnityEditor;
using NUnit;

Is there a way to turn off automatic import of missing namespaces on autocomplete and just keep them as suggestions?
Or - is there a way to control a list of namespaces that  Rider is allowed to auto - import into the scripts?
Thanks!

8
7 comments

For anyone who might face this issue:

Rider doesn't have UI for such setting yet (see RIDER-14342), but it honors "Show import items in basic completion" setting if configured with ReSharper. With this setting disabled, Rider won't suggest non-imported symbols in the completion. As a workaround, you can configure Rider settings file directly:

  1. Go to "Help -> Browse special files and folders" and double-click on "R# global settings".
  2. Close Rider
  3. Open GlobalSettingsStorage.DotSettings file in "R# global settings" folder
  4. Add this line to 'ResourceDictionary' node: <s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/ImportItemsInBasicCompletion/@EntryValue">False</s:Boolean>
  5. Save the file and open Rider. Now completion should not suggest non-imported symbols.
0

This would be really useful, and it's been annoying (and broken builds) - I still want Rider to autocomplete from non-imported symbols, but I don't want it to add the using statement.

3

Vote for this. It is really annoying 

0

The feature is already implemented. You can turn off "Show import items in basic completion" in "File| Settings | Editor | General | Code Completion". After it, Rider won't suggest non-imported symbols in the completion.

1

I'm not sure if that fixes the problem. As Vovo says in the original message "Is there a way to turn off automatic import of missing namespaces on autocomplete and just keep them as suggestions?" - if that setting is turned off, it won't list those symbols at all, which isn't the behaviour I'd like.

I'd prefer it if there was an option where it would list the symbols for autocomplete, but not insert the namespace automatically. If I turn off "Show import items in basic completion", I won't get the symbols in auto-complete, which isn't what I want either, since the suggestions are useful.

1

Exactly as Chris said. Vs or vscode will show all the non-imported symbols in auto-complete, and leave an error message if i pick one, which allows me to import missing namespace by simply a click on. This behavior does much better than what rider does. Especially when working on a really large projects, wrong typing or wrong picking symbol is a  very common situation. 

1

Since this was marked answered and dropped, I made another request that makes it explicit that we need to be able to disable auto import without disabling completion suggestions: https://rider-support.jetbrains.com/hc/en-us/community/posts/360003168700-Turning-off-auto-import-of-using-statements-without-disabling-import-suggestions-in-completion

2

Please sign in to leave a comment.