qsharp-compiler icon indicating copy to clipboard operation
qsharp-compiler copied to clipboard

Q# Code Actions in Visual Studio Code are not included as "Quick Fixes"

Open guenp opened this issue 2 years ago • 1 comments

Describe the bug

Code actions do not work. When hovering over a code warning, the pop up says "no fixes available".

Screenshot 2021-11-23 100314

The following error is displayed in the logs:

[2021-11-23 09:09:58.889] [exthost] [warning] quantum.quantum-devkit-vscode - Code actions of kind 'quickfix 'requested but returned code action does not have a 'kind'. Code action will be dropped. Please set 'CodeAction.kind'.

To Reproduce

Create a new file with the following contents and hover over "using":

namespace Qrng {
    open Microsoft.Quantum.Intrinsic;
    open Microsoft.Quantum.Canon;

    operation Name(target : Qubit) : Unit
    is Adj + Ctl {
        using q = Qubit() {
            foo bar baz;
        }
    }

}

Expected behavior

I expect to see a light bulb with a code action drop down.

System information

  • Visual Studio Code extension v0.21.2111.177148
  • Windows 11

Additional context

This issue was also seen on the previous version v0.20.2110

guenp avatar Nov 23 '21 18:11 guenp

After some investigation and debugging our different setups, we concluded that the issue is not that code actions are not available (they are, as light bulb suggestions when clicking on them or when using ctrl+.), however, there are two problems:

  • The Language Server requires the user to have installed .NET Core SDK 3.1 for it to work properly. This dependency is not intentional, and is being tracked by bug #1235
  • Code Actions are not marked to have a CodeAction.Kind of type QuickFix, and for that reason they are not included in the suggestions in the hover UI.

We're repurposing this issue to address the latter.

ricardo-espinoza avatar Dec 02 '21 23:12 ricardo-espinoza