-
Notifications
You must be signed in to change notification settings - Fork 266
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
Adding Resolution Paths during appdomain creation (Compatibility Isuue) #404
Conversation
@@ -75,35 +75,123 @@ internal TestSourceHost(string sourceFileName, IRunSettings runSettings, IFramew | |||
/// </summary> | |||
public void SetupHost() | |||
{ | |||
if (this.AppDomainCreationDisabledInRunSettings()) | |||
List<string> resolutionPaths = this.GetResolutionPaths(this.sourceFileName, VSInstallationUtilities.IsCurrentProcessRunningInPortableMode()); |
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.
Please add test for ResolutionPaths being set.
|
||
this.targetFrameworkVersion = this.GetTargetFrameworkVersionString(this.sourceFileName); | ||
// Adding extensions folder to resolution paths |
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.
Nit: this is runner location(OM assembly location).
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.
Done.
List<string> resolutionPaths = this.GetResolutionPaths(this.sourceFileName, VSInstallationUtilities.IsCurrentProcessRunningInPortableMode()); | ||
|
||
// Check if user specified any runsettings | ||
MSTestAdapterSettings adapterSettings = MSTestSettingsProvider.Settings; |
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.
Move the declaration near to usage.
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.
Done
// Check if user specified any runsettings | ||
MSTestAdapterSettings adapterSettings = MSTestSettingsProvider.Settings; | ||
|
||
if (resolutionPaths != null && resolutionPaths.Count > 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.
This should not be happen. Even if it is empty or null, We should add below two paths.
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.
Done
} | ||
catch (Exception exception) | ||
{ | ||
if (EqtTrace.IsErrorEnabled) |
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.
Nit: Remove if check for error scenarios.
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.
Why so?
{ | ||
if (EqtTrace.IsErrorEnabled) | ||
{ | ||
EqtTrace.Error(exception); |
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.
Nit: Add more details while logging the exception. At line 190 too.
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.
Done
var configFile = this.GetConfigFileForTestSource(this.sourceFileName); | ||
AppDomainUtilities.SetConfigurationFile(appDomainSetup, configFile); | ||
|
||
this.domain = this.appDomain.CreateDomain("TestSourceHost: Enumering assembly", null, appDomainSetup); |
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.
Change the name of appdomain to sourcefilename.
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.
Done
|
||
// Case when Child-appdomain was created successfully, update appbase and set assembly resolver on it | ||
else if (this.domain != null) | ||
if (this.domain != null) |
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.
Change this to inverted if IsAppDomainCreationDisable
.
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.
Done.
} | ||
|
||
// Log error when child-appdomain was expected to be created but wasn't created. | ||
else | ||
else if (!this.AppDomainCreationDisabledInRunSettings()) |
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.
This is not required. Are DisableAppDomain
settings from runsettings only once.
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.
done.
try | ||
{ | ||
var additionalSearchDirectories = | ||
adapterSettings.GetDirectoryListWithRecursiveProperty(this.domain.SetupInformation.ApplicationBase); |
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.
this.domain.SetupInformation.ApplicationBase
value should be testsource directory.
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.
Reuse additionalSearchDirectories
.
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.
Done.
try | ||
{ | ||
this.parentDomainAssemblyResolver = new AssemblyResolver(resolutionPaths); | ||
this.parentDomainAssemblyResolver.AddSearchDirectoriesFromRunSetting(adapterSettings.GetDirectoryListWithRecursiveProperty(null)); |
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.
GetDirectoryListWithRecursiveProperty
should take test source directory.
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.
Done.
@@ -172,7 +172,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataSourceTestProject", "te | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DoNotParallelizeTestProject", "test\E2ETests\TestAssets\DoNotParallelizeTestProject\DoNotParallelizeTestProject.csproj", "{8080DE48-CFD9-4F33-908A-8B71108CA223}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompatTestProject", "test\E2ETests\TestAssets\CompatTestProject\CompatTestProject.csproj", "{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}" | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompatTestProject", "test\E2ETests\TestAssets\CompatTestProject\CompatTestProject.csproj", "{2D2C5B73-F1F1-47C8-BC5C-A172E9BB3D16}" |
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.
Consider having separate sln for test assets.
@@ -70,40 +68,108 @@ internal TestSourceHost(string sourceFileName, IRunSettings runSettings, IFramew | |||
this.SetContext(sourceFileName); | |||
} | |||
|
|||
public AppDomain AppDomain |
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.
Make it internal.
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.
Done.
/// <summary> | ||
/// Setup the isolation host. | ||
/// </summary> | ||
public void SetupHost() | ||
{ | ||
List<string> resolutionPaths = this.GetResolutionPaths(this.sourceFileName, VSInstallationUtilities.IsCurrentProcessRunningInPortableMode()); | ||
|
||
EqtTrace.Info("DesktopTestSourceHost.SetupHost(): Creating assembly resolver with resolution paths {0}.", string.Join(",", resolutionPaths.ToArray())); |
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.
Check if tracing enabled?
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.
Done.
|
||
if (adapterSettings != null) | ||
{ | ||
try |
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.
DRY.
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.
Done.
var mockRunSettings = new Mock<IRunSettings>(); | ||
mockRunSettings.Setup(rs => rs.SettingsXml).Returns(runSettingxml); | ||
|
||
StringReader stringReader = new StringReader(runSettingxml); |
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.
DRY.
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.
Done.
<IsPackable>false</IsPackable> | ||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | ||
<OutputPath>$(TestFxRoot)artifacts\TestAssets\ComponentTests</OutputPath> | ||
<SignAssembly>true</SignAssembly> |
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.
Remove this if not required?
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.
Required. SampleFrameworkExtensions also has it. PlatformServices.Desktop.Component.Tests throws strong name error if key.snk is not referenced in TestProjectForAssemblyResolution.
@dotnet-bot Test Windows / Debug Build please |
Scenario which was broken -
If suppose TestProject has a config file having assembly binding redirect of System.Runtime to 4.1. Our TestAdapter which has a dependency of System.Runtime of 4.0, uses the above config file and tries to load System.Runtime 4.1. Since assembly resolver was not set at the time of loading of adapter, it is unable to find 4.1 version of assembly and bombs.
Fix - Adding resolution paths at the time of creation of appdomains.
Validations-