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

Working with *.csx and intellisense is messing up #1199

Closed
ReginaldBull opened this issue May 23, 2018 · 14 comments · Fixed by #1210
Closed

Working with *.csx and intellisense is messing up #1199

ReginaldBull opened this issue May 23, 2018 · 14 comments · Fixed by #1210

Comments

@ReginaldBull
Copy link

I'm working on an asp.net core solution. In that solution the user can add a c# script via monaco editor. For better usage I'm running Omnisharp as a service and send the /autocomplete to omnisharp.
Omnisharp is started this way: Omnisharp.exe -s Path
The scripts are stored on the file system as a xxx.csx file. When starting omnisharp when a csx file is present it works well. Added own assemblies as #r "XY.dll".
If omnisharp starts without the *.csx file the intellisense is not working and from /codecheck I'm also getting warnings that #r can only be used in scripts.

What would be a smart way to handle this?

@ReginaldBull ReginaldBull changed the title *.csx Working with *.csx and intellisense is messing up May 23, 2018
@filipw
Copy link
Member

filipw commented May 23, 2018

I am not sure I fully understand, so let me try and recap: you say that when OmniSharp is started with pre-existing csx files, everything is fine. But when you start OmniSharp when no csx files exist, and then you later add one, intellisense for the new one is not surfaced properly?
OmniSharp provides language services for csx files that physically exist on disk, so both of those scenarios should work. Do you have some example of a repro?

@filipw
Copy link
Member

filipw commented May 23, 2018

Oh I think I know what you mean. We have a file watcher for new csx files, but it only gets activated once at least 1 csx file exists on startup. Otherwise we won't discover new files.

If that's the thing that the you are experiencing, then I agree, it would have to be fixed. The workaround for now would be to keep an empty dummy.csx in the folder.

@ReginaldBull
Copy link
Author

Do you have some example of a repro?

I can try to create a small repo if needed but you have understand correctly.

If that's the thing that the you are experiencing, then I agree, it would have to be fixed.

That's exactly what I'm experience.

The workaround for now would be to keep an empty dummy.csx in the folder.

Will be there a fix in the future?

@filipw
Copy link
Member

filipw commented May 24, 2018

Thanks, I managed to reproduce it, so no problem.
I already have a fix on this branch https://github.com/filipw/omnisharp-roslyn/tree/bugfix/1199

If I provided you a local OmniSharp build for testing this, would you be interested in trying this out?

@ReginaldBull
Copy link
Author

Oh that was fast! Yes I would be interested.

@filipw
Copy link
Member

filipw commented May 24, 2018

no problem!
can you please try with the build attached to this comment? it should be able to discover newly added csx files, even if OmniSharp was started without any csx files originally available in the target folder. It's a Windows-only build, if you need a Unix one let me know.
omnisharp-win-x64.zip

@ReginaldBull
Copy link
Author

Thank you, I will check in the afternoon.

@ReginaldBull
Copy link
Author

Is it possible for you to provide the OmniSharp.Http.Driver?

@filipw
Copy link
Member

filipw commented May 24, 2018

sure
omnisharp.http-win-x64.zip

@ReginaldBull
Copy link
Author

ReginaldBull commented May 24, 2018

Hello
I have tested it now with your provided binary. First image shows the ouput when I start omnisharp when there is a *.csx file is present in the folder. The second image shows what happens when I start omnisharp without an *.csx file in the folder.

startingwithscriptfile
startingwithoutscriptfile

@filipw
Copy link
Member

filipw commented May 24, 2018

Thanks - I think then you will really need to provide more details about what you are doing and how you are wiring things up.
From the provided build, see the attached GIF below - this is the behavior you should see when starting against a completely empty folder.

I think in your case it's not really related to the file watching issue anymore, but has to do something with your current set up.
The things that come to my mind:

  • so in your case, what is this editor?
  • where is the reference coming from (I don't see any #r references?)?
  • could you walk through the steps of what is happening - when do you start OmniSharp, how long afterwards do you create new files?
  • is this a local drive or shared drive?
  • which extensions do the files have (OmniSharp only watches for *.csx)?
  • maybe you could put together some repro or point me to some repo code where I could see this?

@ReginaldBull
Copy link
Author

  • I'm using the monaco editor in an angular project with asp.net core.
  • The references are included on server side when the /autocomplete /codecheck is performed. This creates the files (*.csx) on the filesystem. After the file is created I'm sending a request on omnisharp to the uri and port omnisharp is listening. Omnisharp is currently running on the same machine as my app and has access to the files and the solution.
  • Currently I'm starting omnisharp before my server starts. The start is done in a powershell with
    Omnisharp.exe -s D:\Project\xxx (source of my solution). After omnisharp has started, the asp server starts and after that the files are created.
  • It is a local drive.
  • The extension is a *.csx.
  • I will create a repo, may take one or two days.

Attached you see a file that is produced by the app.
producedfile

@filipw
Copy link
Member

filipw commented May 25, 2018

Thanks a lot. I think I now understand what is happening. Sorry, there was a bit of a confusion on the type of editor that you are using and that impacts things a lot.
So - your issue indeed helped uncover a bug that CSX services were not used for new CSX if there were no CSX files at startup.
This is addressed in the build attached in this convo and will soon be added to OmniSharp.

However, in your case the issue is slightly more complex. When I was referring to "file watching" here, I wasn't referring to physical watching of file system, but instead a file watching service that OmniSharp has, and exposes as endpoint. It is the responsibility of the editor to watch for file changes and inform OmniSharp about them over the /filesChanged endpoint. The OmniSharp extensions for editors do just that, and for example if you use VS Code, you will see the requests to this endpoint flying when you add or delete files. And that is precisely the reason why it works with newly created files on the GIF that I attached, and I am guessing why it didn't work for you.

So in your case, the process would be something like this:

  1. start OmniSharp, no CSX have to exist at this point (as explained earlier, this bug is still there on master but not in the attached build)
  2. create, say a foo.csx
  3. notify OmniSharp that a file has been created by calling /filesChanged endpoint with the following payload
[
  {
	"ChangeType": "Create",
	"FileName": "C:\\path\\to\\foo.csx"
  }
]
  1. this triggers the file watchers internally in OmniSharp and language services for the new file are set up
  2. you can now call /projects endpoint to verify that the new CSX file has been bootstrapped or simply start using the different language service endpoints

Also, a final thing, when you are unsure what is going on, you can always run OmniSharp with the --loglevel debug argument to get better and more detailed output.
I hope this helps to get you going - ket me know if this answers your question.

@ReginaldBull
Copy link
Author

Thanks a lot. That filesChanged was missing. Calling that fixed my problem. Thank you!

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

Successfully merging a pull request may close this issue.

2 participants