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

Fix bug caused by System.Threading.Tasks v4.7.1 #892

Merged

Conversation

andyleejordan
Copy link
Contributor

Unfortunately System.Threading.Tasks v4.7.1 is broken. Its package manifest states that it depends on System.Threading.Tasks.Extensions >= v4.5.4 (assembly version v4.2.0.1); however, for some reason it actually requests v4.2.0.0. While neither OmniSharp nor PowerShell Editor Services, the downstream library where this bug appeared, ship that version of the library, it can sometimes be found in the Global Assembly Cache on Windows. When present (due to an installation by some other program), it gets loaded, and then other dependencies (correctly) request v4.2.0.1 which also gets loaded. When both are loaded, a System.MissingMethodException is thrown! Specifically the method ChannelReader.ReadAsync (from System.Threading.Tasks) on the type Tasks.ValueTask (provided by System.Threading.Tasks.Extensions) can no longer be resolved. I do not know enough about the intricacies of method/type resolution in the full .NET Framework as to explain precisely why the presence of v4.2.0.0 causes this resolution to fail, but it certainly does. Upgrading System.Threading.Tasks to v6.0.0 is confirmed to solve the problem, since the newer package correctly requests System.Threading.Tasks.Extensions v4.2.0.1.

I tested this and it sure seems to fix PowerShell/vscode-powershell#4175.

@@ -14,7 +14,6 @@
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
<PackageReference Include="GitVersion.Tool" ExcludeAssets="All" />
<PackageReference Include="ReportGenerator" ExcludeAssets="All" />
<PackageReference Include="JetBrains.ReSharper.CommandLineTools" ExcludeAssets="All" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because it was a duplicate line and the build tools complained about it. (See line 14.)

@github-actions github-actions bot added this to the v0.19.6 milestone Oct 5, 2022
@@ -10,7 +10,7 @@

<ItemGroup>
<ProjectReference Include="../../src/Server/Server.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging" VersionOverride="3.0.0" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample project was failing to restore because its dependencies updated to 6.0.0, but it was not.

…ence

This line was a duplicate and the build tools complained about it.
In order to allow it to restore since this dependency was updated
upstream, and that was causing it to fail to restore due to the detected
forced downgrade.
Unfortunately `System.Threading.Tasks` v4.7.1 is broken. Its package
manifest states that it depends on `System.Threading.Tasks.Extensions`
>= v4.5.4 (assembly version v4.2.0.1); however, for some reason it
actually requests v4.2.0.0. While neither OmniSharp nor PowerShell
Editor Services, the downstream library where this bug appeared, ship
that version of the library, it can sometimes be found in the Global
Assembly Cache on Windows. When present (due to an installation by some
other program), it gets loaded, and then other dependencies (correctly)
request v4.2.0.1 which also gets loaded. When both are loaded, a
`System.MissingMethodException` is thrown! Specifically the method
`ChannelReader.ReadAsync` (from `System.Threading.Tasks`) on the type
`Tasks.ValueTask` (provided by `System.Threading.Tasks.Extensions`) can
no longer be resolved. I do not know enough about the intricacies of
method/type resolution in the full .NET Framework as to explain
precisely why the presence of v4.2.0.0 causes this resolution to fail,
but it certainly does. Upgrading `System.Threading.Tasks` to v6.0.0 is
confirmed to solve the problem, since the newer package correctly
requests `System.Threading.Tasks.Extensions` v4.2.0.1.
@andyleejordan andyleejordan force-pushed the andschwa/fix-assembly-load-issue branch from 0d864f4 to 6c695e3 Compare October 5, 2022 17:51
@andyleejordan
Copy link
Contributor Author

@david-driscoll I split the changes into three commits in case you decide to release v0.19.6 with just a backported patch, since I'm not sure how ready it is for a full release.

@andyleejordan
Copy link
Contributor Author

I've also confirmed with @prpercival that the dev build I produced with the updated O# package fixed the issue on their machine too 😄

@david-driscoll david-driscoll merged commit 5b42009 into OmniSharp:master Oct 13, 2022
@github-actions github-actions bot added the mysterious We forgot to label this label Oct 13, 2022
@andyleejordan
Copy link
Contributor Author

@david-driscoll the bot added the "mysterious" label and that is so freaking apt!

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

Successfully merging this pull request may close these issues.

Extension crashes when targeting PowerShell 5.1 (PowerShellEditorServices DryIoc error)
2 participants