-
Notifications
You must be signed in to change notification settings - Fork 257
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
Fix version of Newtonsoft.Json #1723
Conversation
… well, and a test to ensure the two versions are in sync
|
||
[TestMethod] | ||
public void NewtonsoftVersionMatch() { | ||
var dlsNewtonsoftVersion = GetLibraryVersion(@"../../../../DafnyLanguageServer/DafnyLanguageServer.csproj", "Newtonsoft.Json"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this relative path work? I thought you can't assume anything about the working directory when running tests. Can you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it work ! It assumes we are in DafnyLanguageServer.Test\bin\Debug\net6.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely better not to assume anything about the output directory, in which tests run (and I worked really hard not to in the xUnit lit test runner), but in a test that will fail loudly if the assumption is ever violated, I think it's fine.
Is this something we could test, instead of testing the dll versions directly? |
Testing will not prevent the version from being incompatible for either project, unless you have a way to force DafnyLanguageServer to dynamically load its version of NewtonSoft.json.dll without the need to "install" it next to it? |
Can I ask, how do you reproduce the bug that this PR wants to solve? Can we create a test that executes that reproduction? |
I understand your question now ! To reproduce the bug, here is how you would proceed on the command-line:
You'd get the following error:
I'm not sure how I am going to implement this test but I'll have a look. |
I'm worried about the complexity of implementing such a test vs. the benefit. In this case the problem seems to be (IIUC) that we have two projects that depend(ed) on two different versions of a DLL. Now, because we put all of our binaries in the same place instead of partitioning them into separation The fix to this is to use the same version in both places, and to make that fix robust we can have a check that asserts that the versions match. I don't think it's enough to try to catch load-time bugs: having a different DLL loaded depending on compilation order is a recipe for trouble even if things don't crash right away (ie, the test wouldn't be reliable). |
Do we need to build DafnyLanguageServer and DafnyDriver to the same directory? What happens if we remove |
That should fix it, but is it a change we want to make now? |
If there's no impact from doing that, then yes right? Not building two projects into the same folder will solve the |
There is an impact for doing the change of where the output of the build is going to be placed. I think it's an aberration that two Dafny projects in the same solution actually use two different versions of the same library, and if we can handle it by synchronizing the versions, that's a non-breaking change that is way better than changing the directory structure. |
Wouldn't the same problem happen in the output of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve this since it's definitely better than not having the change. Thanks for the fix @MikaelMayer
Indeed it's a much bigger change than this PR. We can make it later :-) |
Would your language server testing PR would be a good test against this bug, since it tests the language server in non-trivial ways? |
I hope so? I ran into this issue as well while working on the LSP tester :) |
This will fix #1722 by expliciting the version of Newtonsoft.json in both DafnyDriver and DafnyLanguageServer.
I added a test in DafnyLanguageServer to ensure the two versions are in sync, to prevent further synchronization problems.