Skip to content

Commit

Permalink
Undo the assembly merge from #383
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Oct 1, 2023
1 parent 1c51d51 commit 2dd6989
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 90 deletions.
24 changes: 0 additions & 24 deletions src/xunit.runner.visualstudio/VsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,30 +638,6 @@ void handler()
logger.LogWarning(message);
}

// Look for runners that might be embedded in ourselves (because of ILRepack). This is what the code
// in RunnerReporterUtility.GetAvailableRunnerReporters does after it finds a target assembly.
foreach (var type in adapterAssembly.GetTypes())
{
if (type is null || type.IsAbstract || !type.GetInterfaces().Any(t => t == typeof(IRunnerReporter)))
continue;

try
{
var ctor = type.GetConstructor(new Type[0]);
if (ctor is null)
{
logger?.LogWarning($"Type '{type.FullName ?? type.Name}' in the adapter assembly appears to be a runner reporter, but does not have an empty constructor.");
continue;
}

result.Add((IRunnerReporter)ctor.Invoke(new object[0]));
}
catch (Exception ex)
{
logger?.LogWarning($"Exception thrown while inspecting type '{type.FullName ?? type.Name}' in the adapter assembly:{Environment.NewLine}{ex}");
}
}

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)xunit.runner.reporters.net452.dll">
<Link>xunit.runner.reporters.net452.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)xunit.runner.utility.net452.dll">
<Link>xunit.runner.utility.net452.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<ProjectCapability Include="TestContainer" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)xunit.runner.reporters.netcoreapp10.dll">
<Link>xunit.runner.reporters.netcoreapp10.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<None Include="$(MSBuildThisFileDirectory)xunit.runner.utility.netcoreapp10.dll">
<Link>xunit.runner.utility.netcoreapp10.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</None>
<ProjectCapability Include="TestContainer" />
</ItemGroup>
</Project>
42 changes: 2 additions & 40 deletions src/xunit.runner.visualstudio/xunit.runner.visualstudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="$(MicrosoftTestPlatformObjectModelVersion)" PrivateAssets="All" />
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="$(TunnelVisionLabsReferenceAssemblyAnnotatorVersion)" PrivateAssets="All" />
<PackageReference Include="xunit.analyzers" Version="$(XunitAnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="xunit.runner.reporters" Version="$(XunitVersion)" PrivateAssets="All" />
<PackageReference Include="xunit.runner.reporters" Version="$(XunitVersion)" />
</ItemGroup>

<!-- Support deterministic builds (via https://github.com/clairernovotny/DeterministicBuilds) -->
Expand Down Expand Up @@ -56,47 +56,9 @@
Configuration=$(Configuration);
GitCommitId=$(GitCommitId);
PackageVersion=$(PackageVersion);
XunitVersion=$(XunitVersion);
</NuspecProperties>
</PropertyGroup>
</Target>

<!-- ILRepack support -->
<Target Name="ILRepack" AfterTargets="Build" Condition=" '$(TargetFramework)' != '' ">
<PropertyGroup>
<OutputAssembly>$([System.IO.Path]::Combine($(TargetDir), "merged", "$(TargetFileName)"))</OutputAssembly>
</PropertyGroup>

<Message Text="$(TargetName) -&gt; $(OutputAssembly)" Importance="High" />
<CallTarget Targets="ILRepackConditional" />
</Target>

<Target Name="ILRepackConditional" Inputs="$(TargetPath)" Outputs="$(TargetDir)merged\$(TargetFileName)">
<ItemGroup>
<ILRepackExclusions Include="$(OutputPath)*.abstractions.dll;$(OutputPath)Microsoft.*.dll;$(OutputPath)netstand*.dll;$(OutputPath)NuGet.*.dll;$(OutputPath)System.*.dll" />
</ItemGroup>
<ItemGroup>
<Assemblies Include="$(TargetDir)*.dll;$(TargetPath)" Exclude="@(ILRepackExclusions)" />
</ItemGroup>

<MakeDir Directories="$(TargetDir)premerge;$(TargetDir)merged" />
<!-- We copy assemblies into a 'premerge' folder and merge from there, because of this issue: https://github.com/gluck/il-repack/issues/283 -->
<Copy SourceFiles="@(Assemblies)" DestinationFolder="$(TargetDir)premerge" />

<PropertyGroup>
<ILRepackExe>$([System.IO.Path]::Combine($(NuGetPackageRoot), "ilrepack.msbuild.task", $(ILRepackVersion), "tools", "ilrepack.exe"))</ILRepackExe>
<ILRepackExe Condition=" '$(OS)' != 'Windows_NT' ">mono $(ILRepackExe)</ILRepackExe>
<MainAssembly>$([System.IO.Path]::Combine($(TargetDir), "premerge", "$(TargetFileName)"))</MainAssembly>
<OutputAssembly>$([System.IO.Path]::Combine($(TargetDir), "merged", "$(TargetFileName)"))</OutputAssembly>
</PropertyGroup>

<ItemGroup>
<OutputsToCopy Include="$(TargetDir)*.config;@(ILRepackExclusions)" />
<ILRepackDependencies Include="$(TargetDir)premerge\*.dll" Exclude="$(MainAssembly)" />
</ItemGroup>

<Copy SourceFiles="@(OutputsToCopy)" DestinationFolder="$(TargetDir)merged" />
<Exec StandardOutputImportance="low" Command="$(ILRepackExe) -internalize -ndebug -lib:$(TargetDir) -out:$(OutputAssembly) $(MainAssembly) @(ILRepackDependencies, ' ')" />
<RemoveDir Directories="$(TargetDir)premerge" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
<file target="_content\" src="..\..\logo-128-transparent.png" />
<file target="_content\" src="..\..\README.md" />

<file target="build\net462\" src="bin\$Configuration$\net462\merged\xunit.*.dll" />
<file target="build\net462\" src="bin\$Configuration$\net462\xunit.*.dll" />
<file target="build\net462\xunit.runner.visualstudio.props" src="build\xunit.runner.visualstudio.desktop.props" />

<file target="build\net6.0\" src="bin\$Configuration$\net6.0\merged\xunit.*.dll" />
<file target="build\net6.0\" src="bin\$Configuration$\net6.0\xunit.*.dll" />
<file target="build\net6.0\xunit.runner.visualstudio.props" src="build\xunit.runner.visualstudio.dotnetcore.props" />

<file target="lib\net462\" src="build\_._" />
Expand Down
4 changes: 4 additions & 0 deletions test/test.harness/test.harness.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<TargetFrameworks>net462;net472;net6.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\xunit.runner.visualstudio\xunit.runner.visualstudio.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
Expand Down
29 changes: 5 additions & 24 deletions test/test.testcasefilter/test.testcasefilter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<ProjectReference Include="..\..\src\xunit.runner.visualstudio\xunit.runner.visualstudio.csproj" />
</ItemGroup>

<!--
To verify that the tests can run with the ILRepack'd binaries (per the bug in https://github.com/xunit/visualstudio.xunit/issues/384),
run the following commands:
$ dotnet build
$ dotnet build test\test.testcasefilter /t:Test
In the success case, the output should contain JSON messages, like this:
[xUnit.net 00:00:00.00] {"message":"testCollectionStarting","flowId":"b41f5cce12d44b4aa70bc54778922c35","assembly":"test.testcasefilter, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null","collectionName":"Test collection for test.testcasefilter.Tests","collectionId":"c88827b8-7f3a-43d4-baea-1905ce8b521f"}
In the failure case, the output will include a warning about an unknown "json" reporter switch:
[xUnit.net 00:00:00.00] Could not find requested reporter 'json'
-->

<Target Name="Test">
<ItemGroup>
<RunnerBinaries Include="..\..\src\xunit.runner.visualstudio\bin\Debug\net462\merged\xunit*.dll" />
</ItemGroup>
<Copy SourceFiles="@(RunnerBinaries)" DestinationFolder="bin\Debug\net462" />
<Exec Command="dotnet vstest bin\Debug\net462\test.testcasefilter.dll /logger:console;verbosity=normal -- xUnit.ReporterSwitch=json" />
</Target>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
</ItemGroup>

</Project>

0 comments on commit 2dd6989

Please sign in to comment.