Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize changed project structure. #723

Closed
DasOhmoff opened this issue Aug 9, 2021 · 8 comments
Closed

Recognize changed project structure. #723

DasOhmoff opened this issue Aug 9, 2021 · 8 comments

Comments

@DasOhmoff
Copy link

Hello, thank you for your help.

When I work within vim on a cs file, everything works great and fine. But when I then switch to Visual Studio f.e. and change some things, such as adding a file to the project f.e., then vim stops working correctly. It shows errors that are not there and also cannot find the types in the new files. After restarting the servers everything works fine again.

Is there a way omnisharp recognize the changed project structure or files, and to update accordingly?

@nickspoons
Copy link
Member

Not really. There are no file watchers in OmniSharp-vim, and I don't think it would make sense for there to be. To me it would kind of make sense to have some file watchers on the server side, OmniSharp-roslyn, but I suspect if they were interested in automatically detecting changes they would have done it already.

When I make multi-file changes, I just restart the server. For individual file changes, you can tell OmniSharp-roslyn about the changes by just opening the modified file in your Vim session. The new state of the file will be sent to OmniSharp-roslyn.

@DasOhmoff
Copy link
Author

I see. Well I guess there is nothing that can be done here. If any one finds some kind of solution for this, please post it here.

@DasOhmoff
Copy link
Author

DasOhmoff commented Aug 16, 2021

Hello. I stumbled upon the endpoint /reanalyze in OmniSharp-roslyns directory src/OmniSharp.Abstractions/OmniSharpEndpoints.cs. Also upon the function WhenProjectIsRestoredThenReanalyzeProject() in tests/OmniSharp.MSBuild.Tests/ProjectWithAnalyzersTests.cs. And WhenReAnalyzeIsExecutedForAll_ThenReanalyzeAllFiles() in tests/OmniSharp.Roslyn.CSharp.Tests/ReAnalysisFacts.cs.

I remembered this issue and thought that maybe these can be used in some way to solve the problem. It would be nice to trigger this endpoint via omnisharp-vim, so that one does not have to restart the whole server again, as this takes quite a while.

@nickspoons
Copy link
Member

Hi @DasOhmoff,

That endpoint was added in this PR. Reading the description, it appears to be about running roslyn analyzers. I don't think this endpoint triggers reading modified files from disk.

@DasOhmoff
Copy link
Author

DasOhmoff commented Aug 18, 2021

Ah I see. But could we not at least trigger this endpoint manually when needed via omnisharp-vim? Then one would not have to restart the whole server again.

@nickspoons
Copy link
Member

Well yeah we can trigger the endpoint but what for? You still need to restart the server to have the external changes you've made read in.

@DasOhmoff
Copy link
Author

Does it not reanalize the whole project when we trigger the endpoint? In that case would the the server not read in the external changes itself, and afterwards notify vim about it? Maybe I misunderstood.

@nickspoons
Copy link
Member

I don't think so. Looking at the PR I think it just tells all analysers to restart. To start analysing the code that is in memory. If it reloads all files from disk, what would be the difference between this endpoint, and restarting the server?

Give it a try if you want, I just can't imagine that this endpoint will solve the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants