Skip to content

Conversation

@amanthatdoescares
Copy link

@amanthatdoescares amanthatdoescares commented Dec 20, 2025

Problem

The RemoveUnusedImports feature only considered imports at the top level of files, missing imports inside #if conditional compilation blocks. This led to:

  • False negatives: Unused imports inside #if blocks weren't detected
  • Incomplete cleanup: Projects with platform-specific or feature-flagged imports wouldn't get fully cleaned up

Solution

Implement recursive syntax tree traversal to find ALL imports throughout the entire file structure, including those inside conditional compilation blocks.
Fixes: #2335

Now properly handles all imports including those inside #if blocks while keeping platform-specific imports safe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove unused imports should be able to remove unused import declarations in active #if clauses

1 participant