-
Notifications
You must be signed in to change notification settings - Fork 90
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
Ambiguity between class #464
Comments
Hi. I think I saw this problem myself too. The issue appears to be triggered when omnisharp server is still loading project data but omnisharp-emacs starts to interact with it (by asking for autocomplete, syntax checks, etc.). The server probably doesn't know the file is part of the project when the project is not loaded yet and thus once the project is actually loaded there appears to be two duplicate files/class definitions in it's mind. I think we will have to suppress interaction with the server until it has projects loaded. And we probably need to check what other omnisharp clients are doing. |
@beeuhtricks You can consider emacs itself to be a non-multithreaded process–I think there is some kind of threading support build into emacs but we don't use it in this project. Omnisharp-emacs uses a subprocess model to manage communication with the server via STDOUT/STDIN using a kind of event-loop mechanism model–I may not know the details very intimately, since I inherited this project. Events received from the server are processed at this point: You can add a Another point is where all the messages are dispatched to the server: Here you will probably need to add an You can maintain the status of the server on the
This was a tiny brain dump which is hopefully useful for you as a starting point :) Please ask if there are any other questions. (And sorry for any grammar mistakes, English is not my first language) |
@beeuhtricks I would also suggest you take a look at how vscode plugin for omnisharp-roslyn handles this. They may have the events described in typescript classes and you can infer more about the expected communication model with the server from their code: |
@razzmatazz I'm going to be working until about 6PM EST today and I will take a crack at this afterwards. Thanks for giving me a leg up. |
@razzmatazz So, I think omnisharp-vscode uses async/await to deal with launching the server: I have found some libraries that provide promise-like APIs with async/await for Emacs Lisp. Would you be opposed to bringing those in or would it be better to adopt an approach with something like an event loop and polling? |
I will note that calling |
Looking at the code, I think this issue might be upstream. I have a hunch this happened during 1.32.2 -> 1.32.3 @ OmniSharp/omnisharp-roslyn#1252 because that release merged a PR that introduced support for files outside of projects. Is it possible that what's happening is OmniSharp is trying to load it as a file outside of a project and then loading it inside the project as well? |
@razzmatazz Confirmed that this is upstream. I tried the new beta of the OmniSharp Server (1.32.9-beta.20 to be precise) and it appears to be fixed: OmniSharp/omnisharp-roslyn#1252 (comment) Would anyone else like to confirm that they tried this and it works? |
I will note that this does require manually downloading and extracting the server from Azure Storage, because it is not yet released as a tag on GitHub. I'm wondering if we could extract the code to download a server version so the user could set where they want it to pull the server from. Currently the URL is hardcoded in omnisharp-server-installation.el This is the PR with the fix: OmniSharp/omnisharp-roslyn#1357 (comment) |
I think I still have this issue using omnisharp-roslyn v1.32.9, sometimes I launch emacsclient(which in turn starts emacsserver if there isn't already one) via Unity, I still get errors like 'the namespace already contains a definition for xxxx'. If I start emacsserver and then omnisharp server in unity project directory manually then this bug never occurs. |
@ifoolb I think we should wait for the bugfix to be released first as @beeuhtricks has noticed. and then we will know if there is anything to be done here in |
Is there any update on this? I am also experiencing the same issue. |
Update: I have tested it with the latest version of omnisharp-roslyn (v1.32.10) and am still experiencing the same problem (occasionally, it will report ambiguity where there is none). Calling 'omnisharp-reload-solution' sometimes works, but sometimes does nothing. |
@Chaoclypse sorry for not looking at this.. work and life problems, as usual.. and yes, it does the same thing for me with the new version I tried today. I think the problem goes away if you don't touch the buffer of any of .cs files in your projects. That way ominsharp server is not forced to observe the file twice (during the time you browse the file and during it's own project loading sequence). The proper solution still would probably be to wait until all the projects are loaded before issuing any requests to omnisharp-roslyn server from |
This problem (I think) has appeared once they have added support for files outside projects (a.k.a csx scripts) – thus the server does not know if the file belongs to any project before the project has actually completed loading–thus the confusion in it's behaviour. |
@razzmatazz Don't worry about it, and thanks for the prompt reply to my latest message! Is there any way to tell when my projects are fully loaded so that I know when I can make a request? Also, to clarify, a request in this case means inserting some text and getting an auto-complete, for example, right? |
Just launch the server while browsing root project directory with dired or within a shell with
Which means loading for the project is complete. I infer all of this is from observation as I am not involved in development of the related |
As to give the answer to your last question–yes. When you do autocomplete or point to a thing with a cursor - |
Apologies for not responding sooner. The problem with waiting for all the projects to load is that the server doesn’t announce these things, as far as I can tell, and beyond that, there is already a decent amount of async logic in the code for this particular problem. I think a long-term solution will necessitate working with the omnisharp-roslyn team as this is a regression they introduced. For the record I have also started experiencing this occasionally again and it seemed to be fixed at first.
…________________________________
From: Saulius Menkevičius <[email protected]>
Sent: Thursday, January 31, 2019 8:06 AM
To: OmniSharp/omnisharp-emacs
Cc: Beatrix Klebe; Mention
Subject: Re: [OmniSharp/omnisharp-emacs] Ambiguity between class (#464)
As to give the answer to your last question–yes. When you do autocomplete or point to a thing with a cursor - omnisharp-emacs sends the whole buffer to the server to parse and do it's thing. Thus making the server register the class/namespace BEFORE it has actually loaded from the project or before it actually has any references between code objects in your .cs files and files on the disk.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#464 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIpKPZvwUCpFw-KLqQy6W5BTgS18oR3dks5vIuo6gaJpZM4ZHoUF>.
|
@razzmatazz In the short term, it seems like we could do something like block with a while loop until we see that message. Pretty ugly, but ironically enough I’ve had to do the same thing in a project for work recently. I can start a PR for this when I’m back at my workstation if wanted.
…________________________________
From: Beatrix Klebe <[email protected]>
Sent: Thursday, January 31, 2019 10:29 AM
To: OmniSharp/omnisharp-emacs; OmniSharp/omnisharp-emacs
Cc: Beatrix Klebe; Mention
Subject: Re: [OmniSharp/omnisharp-emacs] Ambiguity between class (#464)
Apologies for not responding sooner. The problem with waiting for all the projects to load is that the server doesn’t announce these things, as far as I can tell, and beyond that, there is already a decent amount of async logic in the code for this particular problem. I think a long-term solution will necessitate working with the omnisharp-roslyn team as this is a regression they introduced. For the record I have also started experiencing this occasionally again and it seemed to be fixed at first.
________________________________
From: Saulius Menkevičius <[email protected]>
Sent: Thursday, January 31, 2019 8:06 AM
To: OmniSharp/omnisharp-emacs
Cc: Beatrix Klebe; Mention
Subject: Re: [OmniSharp/omnisharp-emacs] Ambiguity between class (#464)
As to give the answer to your last question–yes. When you do autocomplete or point to a thing with a cursor - omnisharp-emacs sends the whole buffer to the server to parse and do it's thing. Thus making the server register the class/namespace BEFORE it has actually loaded from the project or before it actually has any references between code objects in your .cs files and files on the disk.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#464 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIpKPZvwUCpFw-KLqQy6W5BTgS18oR3dks5vIuo6gaJpZM4ZHoUF>.
|
@razzmatazz Would just like to report that I did indeed try to wait for the message to appear in the appropriate buffer. However, the problem still occurs occasionally, even after the update message appeared. |
@Chaoclypse this is, indeed, distressing. I think more details should be passed upstream.
…________________________________
From: Chaoclypse <[email protected]>
Sent: Thursday, January 31, 2019 10:36 AM
To: OmniSharp/omnisharp-emacs
Cc: Beatrix Klebe; Mention
Subject: Re: [OmniSharp/omnisharp-emacs] Ambiguity between class (#464)
@razzmatazz<https://github.com/razzmatazz> Would just like to report that I did indeed try to wait for the message to appear in the appropriate buffer. However, the problem still occurs occasionally, even after the update message appeared.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#464 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIpKPfDyFRTs--t4l4u6Z7LKu_Q2WKkSks5vIw14gaJpZM4ZHoUF>.
|
@beeuhtricks I would be happy to assist in any way I can - however, do note that I am an emacs novice. I might need some instructions as to how to help. In the meantime, is there any hack or any way around this barring constantly restarting the solution/server? |
There’s a whole range of rather ugly hacks I can imagine, the first of which is to set a literal timeout before commencing communications with the server, maybe just a couple seconds after seeing that message or so. I’m no emacs lisp expert either, I would just be googling to figure this out. Clearly omnisharp-roslyn need to either fix their messaging so we can work around their regression or fix it entirely in the first place.
…________________________________
From: Chaoclypse <[email protected]>
Sent: Thursday, January 31, 2019 10:42 AM
To: OmniSharp/omnisharp-emacs
Cc: Beatrix Klebe; Mention
Subject: Re: [OmniSharp/omnisharp-emacs] Ambiguity between class (#464)
@beeuhtricks<https://github.com/beeuhtricks> I would be happy to assist in any way I can - however, do note that I am an emacs novice. I might need some instructions as to how to help.
In the meantime, is there any hack or any way around this barring constantly restarting the solution/server?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#464 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AIpKPZzB5lTGJ8Geev59WCJPKh9n29Cuks5vIw7ZgaJpZM4ZHoUF>.
|
@Chaoclypse I am trying this out with 1.32.10 after it started happening again on my old 1.32.9 beta. It seems to be fixed, I can't repro it. Are there more details about your setup you could provide? |
@beeuhtricks My set-up is pretty bare-bones. The only plug-in installed on emacs is omnisharp-emacs and its dependencies. Here are my relevant settings:
In addition, the shell script it's pointed to is just this:
Mono is version 5.16.0, OmniSharp is version 1.32.10. I hope that's enough details! Thanks! |
Update: I went back and read what @razzmatazz posted and I would like to note that I must have missed the "pointing with a cursor" part. If I keep my cursor still until the server start-up message has popped up, there is indeed no problem, at least after testing it about 10 times. If I move before the server start-up message, there is usually ambiguity. Sorry for the error on that part. @beeuhtricks When you say you can't repro it, you mean that there is no ambiguity, regardless of when you move the cursor/type in input, right? |
Sorry for replying so late. This is correct, the bug is completely gone for me. I am now using the 1.32.11 prerelease. Does that fix it for you? |
@razzmatazz As a thought, I've noticed that some contingent of omnisharp-roslyn are working on Language Server Protocol support. Maybe it would be best to start a new issue to discuss this, but in the long term that seems somewhat appealing as a solution to this problem of the clients and server diverging over time. Certainly not all features would be supported, but it might be more robust in the features it does have. |
@beeuhtricks I was actually attempting to make it work some time ago, but ran into a couple of bugs in omnisharp-roslyn. See https://github.com/razzmatazz/lsp-csharp The bugs were JSONRPC compliance issues in omnisharp-roslyn, maybe they are fixed now:
I have not prepared README.md in my lsp-csharp repo yet (as it didn't even actually work for me), but you can take a look at: |
by the way has any of you guys tried windows version of omnishap emacs? I just did, and my classes, functions etc were marked red by flycheck all the time. it often takes many tries restarting omnisharp server and flycheck manually to finally make a session work, while currently this almost doesn't happen to me on Linux. how can omnishap roslyn be more buggy on Windows??? |
I now start to doubt myself if we're talking about the same thing. I've only been using emacs to code C# for Unity. In my case the ambiguity issue and redefinition issue will rise when I directly create a source file in emacs and remove a source file in unity respectively. Also if I import new packages in Unity after omnishap server has been started, the server won't just detect these new classes by itself. these issues are usually gone after I manually restart the server, as such I didn't pay much attention to it before, but it's much less likely to make it work on Windows, which is a real pain. |
Will you guys update the omnisharp-server binary so that the ambiguity is gone? |
I have it on my mind and somewhat working on my machine. But there is a couple of PRs that are stuck on failing tests that I didn’t get to fix yet that need to be merged in first.
—Saulius Menkevičius
… Am 19.04.2019 um 15:31 schrieb Enderguy58 ***@***.***>:
Will you guys update the omnisharp-server binary so that the ambiguity is gone?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I have release an updated version of omnisharp-emacs which:
As far as I have tested this fixes this particular problem with amiguity. I tried modifying the files while the server is loading, also adding a new file no longer seems to issue "duplicate definition" error for me. Could someone confirm this fixes their problem too? |
I'm sorry to bring bad news but my pc seems to freeze at |
Is it your emacs that freezes or the whole PC?! |
emacs 25.2.2 haha. I'm on Linux Mint |
Not sure why it could be happening.. in the worst case just mkdir ~/.emacs.d/.cache/omnisharp/server/v1.32.18 and extract https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.32.18/omnisharp-linux-x64.tar.gz there.. |
Thank you! It did work but, as you said earlier, it no longer requires a .sln file. Thing is, I was working using .sln files with Unity Engine |
I think it's using csproj files, I'm not sure. Is there a way I could solve this by myself if it's not a bug? |
I have a question is: Ambiguity between 'Receiver._runningConsumers' and 'Receiver._runningConsumers'
First, i ensure this class no repeat. this error always print when i'm load project complete. I'm try to delete this class and files, after restart emacs and loading project, create file and class, error has gone. so i not sure this problem from here? omnisharp-emacs plugin or omnisharp-rolysn .
omnisharp-emacs version: v4.2
omnisharp-rolysn version: v1.32.8
os: ubuntu 18.04
The text was updated successfully, but these errors were encountered: