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

Adding Microsoft.VisualStudio.ArchitectureTools.PEReader.dll to Extensions #2041

Merged
merged 4 commits into from
Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ function Create-VsixPackage
$legacyDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.Internal.TestPlatform.Extensions\$testPlatformExternalsVersion\contentFiles\any\any"
Copy-Item -Recurse $legacyDir\* $packageDir -Force

# Copy Microsoft.VisualStudio.ArchitectureTools.PEReader to Extensions
Copy-Item $legacyDir\Microsoft.VisualStudio.ArchitectureTools.PEReader.dll $extensionsPackageDir -Force

# Copy QtAgent Related depedencies
$legacyDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.VisualStudio.QualityTools\$testPlatformExternalsVersion\contentFiles\any\any"
Copy-Item -Recurse $legacyDir\* $packageDir -Force
Expand Down
2 changes: 1 addition & 1 deletion src/package/nuspec/Microsoft.TestPlatform.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<file src="net451\$Runtime$\Microsoft.TestPlatform.Utilities.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.TestPlatform.Utilities.dll" />
<file src="net451\$Runtime$\Microsoft.TestPlatform.VsTestConsole.TranslationLayer.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.TestPlatform.VsTestConsole.TranslationLayer.dll" />
<file src="net451\$Runtime$\Microsoft.TestPlatform.VsTestConsole.TranslationLayer.xml" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.TestPlatform.VsTestConsole.TranslationLayer.xml" />
<file src="net451\$Runtime$\Microsoft.VisualStudio.ArchitectureTools.PEReader.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.ArchitectureTools.PEReader.dll" />
<file src="net451\$Runtime$\Microsoft.VisualStudio.ArchitectureTools.PEReader.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Extensions\Microsoft.VisualStudio.ArchitectureTools.PEReader.dll" />
<file src="net451\$Runtime$\Microsoft.VisualStudio.Coverage.Analysis.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.Coverage.Analysis.dll" />
<file src="net451\$Runtime$\Microsoft.VisualStudio.Coverage.Interop.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.Coverage.Interop.dll" />
<file src="net451\$Runtime$\Microsoft.VisualStudio.Diagnostics.Utilities.dll" target="tools\net451\Common7\IDE\Extensions\TestPlatform\Microsoft.VisualStudio.Diagnostics.Utilities.dll" />
Expand Down
13 changes: 13 additions & 0 deletions test/Microsoft.TestPlatform.AcceptanceTests/DataCollectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ public void ExecuteTestsWithDataCollectionUsingCollectArgument(RunnerInfo runner
this.VaildateDataCollectorOutput();
}

[TestMethod]
[NetFullTargetFrameworkDataSource]
[NetCoreTargetFrameworkDataSource]
public void DataCollectorAssemblyLoadingShouldNotThrowError(RunnerInfo runnerInfo)
{
AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);

var arguments = PrepareArguments(GetAssetFullPath("TraceCollectorLoader.dll", "netcoreapp2.0"), string.Empty, string.Empty, this.FrameworkArgValue);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding only netcoreapp2.0 since AppDomain is only available after netcoreapp2.0.
Documentation

Copy link
Contributor

Choose a reason for hiding this comment

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

How does this run for net451 then ?

Copy link
Contributor

Choose a reason for hiding this comment

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

And where is the datacollector getting enabled, I need to understand this better.

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 load the datacollectors only in the case of netcore as this change was made only in DotnetTestHostManager here. So net451 run without error.
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies(); in the test loads datacollectors including the trace datacollector.
When we attempt to get the types of the trace datacollector, in var typeInfo = assembly.GetTypes(); it breaks with the error.


this.InvokeVsTest(arguments);
this.ValidateSummaryStatus(1, 0, 0);
}

private static void CreateDataCollectionRunSettingsFile(string destinationRunsettingsPath, Dictionary<string, string> dataCollectionAttributes)
{
var doc = new XmlDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ protected string GetAssetFullPath(string assetName)
return this.testEnvironment.GetTestAsset(assetName);
}

protected string GetAssetFullPath(string assetName, string targetFramework)
{
return this.testEnvironment.GetTestAsset(assetName, targetFramework);
}

protected string GetTestAdapterPath(UnitTestFramework testFramework = UnitTestFramework.MSTest)
{
string adapterRelativePath = string.Empty;
Expand Down
6 changes: 6 additions & 0 deletions test/TestAssets/TestAssets.sln/TestAssets.sln
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LegacySettingsUnitTestProje
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewtonSoftDependency", "..\NewtonSoftDependency\NewtonSoftDependency.csproj", "{79EDA259-5EA0-45F0-990A-F078427E198A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TraceCollectorLoader", "..\TraceCollectorLoader\TraceCollectorLoader.csproj", "{85A7A75D-3FFE-4F9E-B71A-E4CF83D8E8E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -135,6 +137,10 @@ Global
{79EDA259-5EA0-45F0-990A-F078427E198A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79EDA259-5EA0-45F0-990A-F078427E198A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79EDA259-5EA0-45F0-990A-F078427E198A}.Release|Any CPU.Build.0 = Release|Any CPU
{85A7A75D-3FFE-4F9E-B71A-E4CF83D8E8E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85A7A75D-3FFE-4F9E-B71A-E4CF83D8E8E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85A7A75D-3FFE-4F9E-B71A-E4CF83D8E8E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85A7A75D-3FFE-4F9E-B71A-E4CF83D8E8E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
15 changes: 15 additions & 0 deletions test/TestAssets/TraceCollectorLoader/TraceCollectorLoader.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net451</TargetFrameworks>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.1" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions test/TestAssets/TraceCollectorLoader/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Linq;

namespace TraceCollectorLoader
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of the project is slightly misleading. Rename it to what is actually doing, something related to GetAssemblies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
// https://github.com/microsoft/vstest/issues/2008
// GetAssemblies adds datacollectors to test host appdomain which was failing in the above issue

var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();

foreach(var assembly in allAssemblies)
{
var typeInfo = assembly.GetTypes();
}
}
}
}