fernandoescolar / vscode-solution-explorer

This is a Visual Studio Code extension that provides a (.sln) Visual Studio Solution explorer panel..
MIT License
352 stars 73 forks source link

Fix integration with Omnisharp solution selection when it's not currently active #224

Closed prettyv closed 2 years ago

prettyv commented 2 years ago

When enabling the option to follow the currently selected solution in Omnisharp and not being in a workspace where Omnisharp has already activated a ton of errors were being produced due to improperly accessing the extension.exports field when the extension has not yet activated. As the docs for the export field mention:

The public API exported by this extension (return value of `activate`).
It is an invalid action to access this field before this extension has been activated.

This PR removes the type cast to any when getting the Omnisharp extension and checks for the isActive flag before accessing the API. I also decided to add an interface corresponding directly to the concrete event as currently defined in Omnisharp for slightly more clarity.

At the same time I think that this extension should probably not even be activated in contexts where Omnisharp doesn't also already define its own activation events, but I haven't thought about that part enough at this point.