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

Remove binding redirect of Newtonsoft.Json from testhost config file #663

Merged
merged 13 commits into from
Apr 4, 2017

Conversation

Faizan2304
Copy link
Contributor

faahmad added 2 commits March 27, 2017 02:47
1) microsoft#391
2) microsoft#613

Fix: Remove binding redirect of Newtonsoft.json from testhost config file
@msftclas
Copy link

@Faizan2304,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

# Binding redirection for Newtonsoft.Json.dll has been removed from testhost config file to resolve bug: https://github.com/Microsoft/vstest/issues/391
# Microsoft.TestPlatform.CommunicationUtilities depends on Newtonsoft.Json of version 8.0.3 and Microsoft.TestPlatform.CrossPlatEngine depends on Microsoft.Extensions.Dependencymodel which
# depends on Newtonsoft.Json of version 9.0.1. So at the end testhost has Newtonsoft.Json.dll of version 9.0.1 in their publish package.
# Since testhost uses CommunicationUtilities (and dont use that part of code of CrossPlatEngine which uses Newtonsoft.Json of version 9.0.1) so it needs Newtonsoft.Json.dll of version 8.0.3
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to include why we made this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please also state that we have a very thin line on cross plat engine's dependency on newtonsoft.json 9.0.1(It actually should be just calling into 8.0.3 compatible APIs since that's what it finds at runtime.)

@@ -10,6 +10,8 @@
<TargetFrameworks>netcoreapp1.0;net46</TargetFrameworks>
<AssemblyName>Microsoft.TestPlatform.Client.UnitTests</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to figure out what this actually means.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Faizan2304 why is this required for TP.Client.UnitTests? Can we add a comment please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TP.Client.UnitTests has dependency on both version 8 and 9 of Newtonsoft.Json, hence higher version(9) get copied in output folder . We have removed the binding redirect of Newtonsoft.Json from testhost config file So the appdomain which runs the test doesn't have any binding redirect of Newtonsoft.json, as a result when the test run it loads the version 9 of Newtonsoft.Json. when the code which uses Newtonsoft.Json (8) get executed it fails with method not found exception.

@Faizan2304
Copy link
Contributor Author

@dotnet-bot test this please

# In the TestPlatform repo: Microsoft.TestPlatform.CommunicationUtilities depends on Newtonsoft.Json(8.0.3) and Microsoft.TestPlatform.CrossPlatEngine depends on Microsoft.Extensions.Dependencymodel which
# depends on Newtonsoft.Json(9.0.1). So testhost ends up having Newtonsoft.Json.dll of version 9.0.1 in their publish package.
# Since testhost uses CommunicationUtilities (and does not use that part of CrossPlatEngine which uses Newtonsoft.Json of version 9.0.1) so it needs Newtonsoft.Json.dll of version 8.0.3 along with it.
# Hence, copying Newtonsoft.Json.dll of version 8.0.3 to test $testhostFullPackageDir. This is however very much dependent on the CrossPlatEngine code running in testhost to not call into APIs specific to 9.0.1.
Copy link
Contributor

Choose a reason for hiding this comment

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

We're copying the JSON.net since CommunicationUtilities requires it. Suggest adding this root cause to the actual bug and refer it here for history.

After refactoring of test host providers, CrossPlatEngine no longer takes a dependency on JSON.net.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit

$newtonsoft = Join-Path $env:TP_PACKAGES_DIR "newtonsoft.json\8.0.3\lib\net45\Newtonsoft.Json.dll"
Copy-Item $newtonsoft $testhostFullPackageDir -Force

# Copy over the Full CLR built testhost package assemblies to the Core CLR and Full CRL package folder.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/CRL/CLR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in next commit

@@ -14,6 +14,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp1.0'">
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment why is this required. CrossPlatEngine no longer has a dependency on JSON.net.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after PR #659, we may not need this.

@@ -12,6 +12,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp1.0'">
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
Copy link
Contributor

Choose a reason for hiding this comment

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

May be this is not required since CrossPlatEngine is not dependent on JSON.net.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will remove after testing once Mayank fix will go in

@@ -11,6 +11,8 @@
<AssemblyName>Microsoft.TestPlatform.CommunicationUtilities.UnitTests</AssemblyName>
<EnableCodeAnalysis>true</EnableCodeAnalysis>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
Copy link
Contributor

Choose a reason for hiding this comment

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

Require comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for all changes below.

Copy link
Contributor

@codito codito left a comment

Choose a reason for hiding this comment

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

LGTM with few suggestions.

@Faizan2304
Copy link
Contributor Author

@dotnet-bot test this please

1 similar comment
@Faizan2304
Copy link
Contributor Author

@dotnet-bot test this please

faahmad added 5 commits March 31, 2017 07:00
@Faizan2304 Faizan2304 merged commit 6924402 into microsoft:master Apr 4, 2017
@Faizan2304 Faizan2304 deleted the NewtonSoft branch April 4, 2017 13:27
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

Successfully merging this pull request may close these issues.

4 participants