Skip to content

Include module names in add-import fixIds #29550

@amcasey

Description

@amcasey

Suppose the code contains an identifier abc that could be resolved by importing it from either module a or module b. Presently, getCodeFixes-full returns two code fixes - one each for a and b - with the same fixId. This causes two problems:

  1. VS de-dupes fixes with the same fixId so only the fix for a is shown.
  2. If fix-all is applied with the given fixId, the first fix with that fixId at each diagnostic span is used, which is somewhat arbitrary.

We can resolve both problems by including the module name in the fixId:

  1. The fixIds will differ and neither fix will be dropped by VS.
  2. fix-all will add an import to a single module and update all the diagnostic spans that can be resolved with an import from that module.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions