Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@rmshaffer
Copy link
Contributor

@rmshaffer rmshaffer commented Aug 10, 2020

This PR is an attempt to allow Q# language server features to work even without a .csproj file. (For example, this may be common in simple Python scripting scenarios where the user has simply a .py file and a .qs file.)

  • When a .qs file is opened in the editor, if no local .csproj can be found, the language server automatically generates and saves a .csproj file in a temporary folder.

  • The temporary .csproj file is a Q# library project referencing the Microsoft.Quantum.Sdk version that matches the version of the language server.

    NOTE: For Python scripting scenarios, it is possible that this will not match the versions of the installed qsharp Python package or IQ# kernel. We can live with that edge case, since our guidance is always to use matching versions of all QDK components.

  • The temporary .csproj file specifies a QsharpCompile property that includes all .qs files in the folder of the currently-opened .qs file, but not subfolders.

    • This will most closely match the behavior of IQ# and Python interop when there is no .csproj file.
    • This will also avoid potentially bad issues if the user opened a .qs file from a folder at the root of a large tree, e.g., the C:\ folder.

@rmshaffer rmshaffer changed the title WIP: Auto-create temporary .csproj file if none exists Auto-create temporary .csproj file if none exists Aug 11, 2020
@rmshaffer rmshaffer marked this pull request as ready for review August 11, 2020 14:58
@rmshaffer
Copy link
Contributor Author

Thanks for the review, @ricardo-espinoza! I made a few additional changes in response to the discussion with @bettinaheim in this PR; probably enough that I'd be most comfortable if you could give the new changes a quick look before merging.

@filipw
Copy link
Contributor

filipw commented Aug 19, 2020

out of curiosity, why is there a need to even generate a temporary csproj? it seems at first glance like a bit of an overkill but perhaps I am missing some details. couldn't the language server just create in memory ProjectInformation based on the loose files?

e.g. in OmniSharp we support loose .cs files but we don't physically generate a csproj, we only create an in-memory representation of such "loose files" project in the current workspace

@rmshaffer
Copy link
Contributor Author

out of curiosity, why is there a need to even generate a temporary csproj? it seems at first glance like a bit of an overkill but perhaps I am missing some details. couldn't the language server just create in memory ProjectInformation based on the loose files?

e.g. in OmniSharp we support loose .cs files but we don't physically generate a csproj, we only create an in-memory representation of such "loose files" project in the current workspace

Thanks @filipw, very good question. Including @ricardo-espinoza here also. I agree that this approach is a bit of overkill. My understanding from the code and from discussion with @bettinaheim is that the way the language server is currently set up to get change notifications, it is completely dependent on watching for changes in the file system. So it would be a bit of a more involved change to add support for something outside the file system. Certainly doable though... this was just the less-invasive approach. I think it's something we could potentially build on top of this... if we made that change later, it would be a nice improvement and (hopefully) totally invisible to the user experience...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants