Prevent Rider from removing "using XXX = Name.Space.Class;" ?
I often use this for clarity in my code:
```using GridCoord = UnityEngine.Vector3Int;```
But often when refactoring, like moving a type to its own file, Rider will simply replace all occurances of GridCoord with Vector3Int, leaving me with ambiguous use of types in my code.
Is there any setting that prevent this behaviour?
Please sign in to leave a comment.
Note: for built-in types its even worse because Rider will remove statements like these when running Code Cleanup:
using ChunkKey = System.Int64;
To be more precise, in the latter example the using statement stays but any uses of "ChunkKey" will be replaced by "long".
Hello Steffen,
Thank you for the feedback.
I was able to reproduce this behavior and submitted a new issue RIDER-94546 Move To Another File refactoring does not preserve aliases. Please upvote it and click
Watch
to keep an eye on the progress.This is related to a known issue with code cleanup, see RSRP-3932 Optimize Usings shouldn't remove aliases. Feel free to upvote this one as well. To avoid this behavior, you can navigate to Preferences | Editor | Code Cleanup and disable Optimize imports | C# | Optimize 'using' directives in the cleanup profile.
Thank you!