How can I make Rider take preprocessor directives into consideration when using "optimize imports" ?

Hello,
When using the optimize imports feature, if the preprocessor directive conditions aren't met, Rider doesn't take the code in the preprocessor directive section into consideration. For example, greyed out preprocessor directive code imports something and it's required but the optimize imports feature doesn't care about this section and deletes the using directive required by this disabled section. Because it sees the code as if this section isn't present.
I want to automate the deletion of unnecessary using directives, but if it deletes the import required by the code in that preprocessor directive section, it breaks the code when this section gets enabled. In Unity, we often use these preprocessor directives to include/inject platform-specific code into a method. Is there a setting I can change to achieve what I want?

 

0
1 comment

Hello, 

Thanks for contacting Rider support. Unfortunately, this is a known limitation which we have reported in our issue tracker: RSRP-467998 Inactive preprocessor branches aren't taken into account when refactoring. Please upvote it to indicate your interest and subscribe to further status updates.

Let me know if there is anything else I could help you with. Have a great day!

Regards,

Tom

0

Please sign in to leave a comment.