Fixup RuntimeDependenciesResolver test (#19208)

Fixes https://github.com/dotnet/aspnetcore/issues/12059
This commit is contained in:
Pranav K 2020-02-21 08:35:20 -08:00 committed by GitHub
parent 9ded8e17d4
commit 4715de45eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 57 deletions

View File

@ -56,16 +56,4 @@
MicrosoftNETSdkRazorPackageVersion=$(MicrosoftNETSdkRazorPackageVersion)" /> MicrosoftNETSdkRazorPackageVersion=$(MicrosoftNETSdkRazorPackageVersion)" />
</Target> </Target>
<!-- A bit of msbuild magic to support reference resolver tests -->
<Target Name="CreateReferenceHintPathsList" AfterTargets="Build">
<ItemGroup>
<_BclDirectory Include="$(ComponentsWebAssemblyBaseClassLibraryPath)" />
<_BclDirectory Include="$(ComponentsWebAssemblyBaseClassLibraryFacadesPath)" />
<_BclDirectory Include="$(ComponentsWebAssemblyFrameworkPath)" />
</ItemGroup>
<WriteLinesToFile Lines="@(ReferencePath)" File="$(TargetDir)referenceHints.txt" WriteOnlyWhenDifferent="true" Overwrite="true" />
<WriteLinesToFile Lines="@(_BclDirectory)" File="$(TargetDir)bclLocations.txt" WriteOnlyWhenDifferent="true" Overwrite="true" />
</Target>
</Project> </Project>

View File

@ -5,39 +5,23 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using Microsoft.AspNetCore.Testing;
using Xunit; using Xunit;
namespace Microsoft.AspNetCore.Components.WebAssembly.Build namespace Microsoft.AspNetCore.Components.WebAssembly.Build
{ {
public class RuntimeDependenciesResolverTest public class RuntimeDependenciesResolverTest
{ {
[ConditionalFact(Skip = " https://github.com/aspnet/AspNetCore/issues/12059")] [Fact]
[SkipOnHelix("https://github.com/aspnet/AspNetCore/issues/10426")]
public void FindsReferenceAssemblyGraph_ForStandaloneApp() public void FindsReferenceAssemblyGraph_ForStandaloneApp()
{ {
// Arrange // Arrange
var standaloneAppAssembly = typeof(StandaloneApp.Program).Assembly; var standaloneAppAssembly = typeof(StandaloneApp.Program).Assembly;
var mainAssemblyLocation = standaloneAppAssembly.Location; var mainAssemblyLocation = standaloneAppAssembly.Location;
var mainAssemblyDirectory = Path.GetDirectoryName(mainAssemblyLocation);
// This list of hints is populated by MSBuild so it will be on the output var hintPaths = ReadContent(standaloneAppAssembly, "StandaloneApp.referenceHints.txt");
// folder. var bclLocations = ReadContent(standaloneAppAssembly, "StandaloneApp.bclLocations.txt");
var hintPaths = File.ReadAllLines(Path.Combine(
mainAssemblyDirectory, "referenceHints.txt"));
var bclLocations = File.ReadAllLines(Path.Combine(
mainAssemblyDirectory, "bclLocations.txt"));
var references = new[]
{
"Microsoft.AspNetCore.Blazor.dll",
"Microsoft.AspNetCore.Components.Web.dll",
"Microsoft.AspNetCore.Components.dll",
"Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"Microsoft.Extensions.DependencyInjection.dll",
"Microsoft.JSInterop.dll",
"Mono.WebAssembly.Interop.dll",
}.Select(a => hintPaths.Single(p => Path.GetFileName(p) == a))
.ToArray();
var expectedContents = new[] var expectedContents = new[]
{ {
@ -57,53 +41,55 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
fewer assemblies from the server, and during publishing, illink would remove all the fewer assemblies from the server, and during publishing, illink would remove all the
uncalled implementation code from mscorlib.dll anyway. uncalled implementation code from mscorlib.dll anyway.
*/ */
"Microsoft.AspNetCore.Blazor.dll", "Microsoft.AspNetCore.Blazor.HttpClient.dll",
"Microsoft.AspNetCore.Blazor.pdb", "Microsoft.AspNetCore.Blazor.HttpClient.pdb",
"Microsoft.AspNetCore.Components.Web.dll",
"Microsoft.AspNetCore.Components.Web.pdb",
"Microsoft.AspNetCore.Components.dll", "Microsoft.AspNetCore.Components.dll",
"Microsoft.AspNetCore.Components.pdb", "Microsoft.AspNetCore.Components.Forms.dll",
"Microsoft.AspNetCore.Components.Web.dll",
"Microsoft.AspNetCore.Components.WebAssembly.dll",
"Microsoft.AspNetCore.Components.WebAssembly.pdb",
"Microsoft.Bcl.AsyncInterfaces.dll",
"Microsoft.Extensions.Configuration.Abstractions.dll",
"Microsoft.Extensions.Configuration.dll",
"Microsoft.Extensions.DependencyInjection.Abstractions.dll", "Microsoft.Extensions.DependencyInjection.Abstractions.dll",
"Microsoft.Extensions.DependencyInjection.dll", "Microsoft.Extensions.DependencyInjection.dll",
"Microsoft.Extensions.Logging.Abstractions.dll",
"Microsoft.Extensions.Primitives.dll",
"Microsoft.JSInterop.dll", "Microsoft.JSInterop.dll",
"Mono.Security.dll", "Mono.Security.dll",
"Mono.WebAssembly.Interop.dll", "Mono.WebAssembly.Interop.dll",
"Mono.WebAssembly.Interop.pdb",
"mscorlib.dll", "mscorlib.dll",
"netstandard.dll", "netstandard.dll",
"StandaloneApp.dll", "StandaloneApp.dll",
"StandaloneApp.pdb", "StandaloneApp.pdb",
"System.dll", "System.dll",
"System.Buffers.dll", "System.Buffers.dll",
"System.Collections.Concurrent.dll",
"System.Collections.dll",
"System.ComponentModel.Composition.dll",
"System.ComponentModel.dll",
"System.ComponentModel.Annotations.dll", "System.ComponentModel.Annotations.dll",
"System.ComponentModel.DataAnnotations.dll", "System.ComponentModel.DataAnnotations.dll",
"System.ComponentModel.Composition.dll",
"System.Core.dll", "System.Core.dll",
"System.Data.dll", "System.Data.dll",
"System.Diagnostics.Debug.dll", "System.Data.DataSetExtensions.dll",
"System.Diagnostics.Tracing.dll",
"System.Drawing.Common.dll", "System.Drawing.Common.dll",
"System.IO.Compression.dll", "System.IO.Compression.dll",
"System.IO.Compression.FileSystem.dll", "System.IO.Compression.FileSystem.dll",
"System.Linq.dll", "System.Memory.dll",
"System.Linq.Expressions.dll",
"System.Net.Http.dll", "System.Net.Http.dll",
"System.Numerics.dll", "System.Numerics.dll",
"System.Reflection.Emit.ILGeneration.dll", "System.Numerics.Vectors.dll",
"System.Reflection.Emit.Lightweight.dll", "System.Runtime.CompilerServices.Unsafe.dll",
"System.Reflection.Primitives.dll",
"System.Resources.ResourceManager.dll",
"System.Runtime.dll",
"System.Runtime.Extensions.dll",
"System.Runtime.Serialization.dll", "System.Runtime.Serialization.dll",
"System.ServiceModel.Internals.dll", "System.ServiceModel.Internals.dll",
"System.Threading.dll", "System.Text.Encodings.Web.dll",
"System.Text.Json.dll",
"System.Threading.Tasks.Extensions.dll",
"System.Transactions.dll", "System.Transactions.dll",
"System.Web.Services.dll",
"System.Xml.dll", "System.Xml.dll",
"System.Xml.Linq.dll", "System.Xml.Linq.dll",
"WebAssembly.Bindings.dll",
"WebAssembly.Net.Http.dll",
"WebAssembly.Net.WebSockets.dll",
}.OrderBy(i => i, StringComparer.Ordinal) }.OrderBy(i => i, StringComparer.Ordinal)
.ToArray(); .ToArray();
@ -111,9 +97,9 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
var paths = ResolveBlazorRuntimeDependencies var paths = ResolveBlazorRuntimeDependencies
.ResolveRuntimeDependenciesCore( .ResolveRuntimeDependenciesCore(
mainAssemblyLocation, mainAssemblyLocation,
references, hintPaths,
bclLocations); bclLocations);
var contents = paths var contents = paths
.Select(p => Path.GetFileName(p)) .Select(p => Path.GetFileName(p))
@ -139,6 +125,14 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
Assert.Equal(expectedContents, contents); Assert.Equal(expectedContents, contents);
} }
private string[] ReadContent(Assembly standaloneAppAssembly, string fileName)
{
using var resource = standaloneAppAssembly.GetManifestResourceStream(fileName);
using var streamReader = new StreamReader(resource);
return streamReader.ReadToEnd().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
private class ContentMisMatchException : Xunit.Sdk.XunitException private class ContentMisMatchException : Xunit.Sdk.XunitException
{ {
public IEnumerable<string> ContentNotFound { get; set; } public IEnumerable<string> ContentNotFound { get; set; }

View File

@ -10,4 +10,22 @@
<Reference Include="Microsoft.AspNetCore.Components.WebAssembly" /> <Reference Include="Microsoft.AspNetCore.Components.WebAssembly" />
<Reference Include="Microsoft.AspNetCore.Blazor.HttpClient" /> <Reference Include="Microsoft.AspNetCore.Blazor.HttpClient" />
</ItemGroup> </ItemGroup>
<!-- A bit of msbuild magic to support reference resolver tests -->
<Target Name="CreateReferenceHintPathsList" AfterTargets="ResolveAssemblyReferences">
<ItemGroup>
<_BclFile Include="$(ComponentsWebAssemblyBaseClassLibraryPath)*" />
<_BclFile Include="$(ComponentsWebAssemblyBaseClassLibraryFacadesPath)*" />
<_BclFile Include="$(ComponentsWebAssemblyFrameworkPath)*" />
</ItemGroup>
<WriteLinesToFile Lines="@(ReferencePath);@(ReferenceDependencyPaths)" File="$(IntermediateOutputPath)referenceHints.txt" WriteOnlyWhenDifferent="true" Overwrite="true" />
<WriteLinesToFile Lines="@(_BclFile)" File="$(IntermediateOutputPath)bclLocations.txt" WriteOnlyWhenDifferent="true" Overwrite="true" />
<ItemGroup>
<EmbeddedResource Include="$(IntermediateOutputPath)bclLocations.txt" Link="bclLocations.txt" Type="Non-Resx" />
<EmbeddedResource Include="$(IntermediateOutputPath)referenceHints.txt" Link="referenceHints.txt" Type="Non-Resx" />
</ItemGroup>
</Target>
</Project> </Project>