This project is read-only.


Quick Fixes should check Workspace.CanApplyChange


I made a Workspace where CanApplyChange() always returned false (by accident).

Quick fixes worked fine, and called ChangedDocumentText, in spite of that.

The format command handler, on the other hand, correctly checked CanApplyChange(), and didn't do anything.

These should presumably be consistent.


manishv wrote Dec 12, 2014 at 5:00 PM

I have looked at the code around quick fixes and Workspace.TryApplyChanges and am unable to find a code path where the scenario you mention can occur.
ApplyChangesOperation.Apply, which is the primary method to apply quick fix changes back to the workspace invokes workspace.TryApplyChanges(changedSolution).
The base implementation of TryApplyChanges checks if any of the changes can even be attempted/supported by invoking Workspace.CheckAllowedSolutionChanges (which checks CanApplyChange for each change's ApplyChangeKind). Only if this succeeds, it goes ahead to invoke Workspace.ApplyProjectChanges, which is the only place where ChangedDocumentText is invoked.

Can you please give some more information:
1) Call stack when you see ChangedDocumentText being invoked by quick fixes.
2) Your implementation/subtype of Workspace where you override CanApplyChanges to always return false. Can you provide your implementation of TryApplyChanges? Are you invoking base.TryApplyChanges in there?


SSL wrote Dec 12, 2014 at 6:49 PM

Yes; it looks like this bug was fixed by, which was released after I reported this bug.

SSL wrote Dec 12, 2014 at 6:50 PM

If I could get more releases, this wouldn't happen as often :)