Skip to content

Roslyn's MEF-based "Generate overrides..." leaks into headless code actions and throws on apply #201

Description

@MelbourneDeveloper

What

Requesting code actions on a type declaration can surface Roslyn's own Generate overrides... provider alongside the sidecar's headless replacement (HeadlessOverrideCodeAction). Resolving the Roslyn one fails:

Service of type 'Microsoft.CodeAnalysis.PickMembers.IPickMembersService' is required
to accomplish the task but is not available from 'MSBuildWorkspace' workspace.

IPickMembersService is a MEF-composed IDE service that does not exist in a headless MSBuildWorkspace, which is precisely why HeadlessOverrideCodeAction exists. Both actions carry the identical title Generate overrides..., so which one a client gets depends on ordering — the user sees an action that sometimes works and sometimes errors.

Reproduce

Observed against src/editors/vscode/test-fixtures-style sources while writing HeadlessOverrideGenerationTests. Put the caret on the identifier of an abstract class that inherits only object's virtuals (so the headless provider contributes nothing), request code actions, then resolve the Generate overrides... entry.

Expected

MEF-dependent providers that cannot run headlessly should be filtered out of the code-action list, so the only Generate overrides... offered is the one that actually works. A duplicate title should never be ambiguous.

Notes

Not a regression from the current PR — the headless replacement and the leak arrived together. Filed separately rather than widening that PR's scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions