parent
500bdc1fd4
commit
4e909515a7
|
|
@ -397,25 +397,24 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
throw new ArgumentNullException(nameof(result));
|
||||
}
|
||||
|
||||
assemblyPath = Path.Combine(result.Project.DirectoryPath, Path.Combine(assemblyPath));
|
||||
|
||||
var typeNames = GetDeclaredTypeNames(assemblyPath);
|
||||
Assert.DoesNotContain(fullTypeName, typeNames);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetDeclaredTypeNames(string assemblyPath)
|
||||
{
|
||||
IEnumerable<string> typeNames;
|
||||
using (var file = File.OpenRead(assemblyPath))
|
||||
{
|
||||
var peReader = new PEReader(file);
|
||||
var metadataReader = peReader.GetMetadataReader();
|
||||
typeNames = metadataReader.TypeDefinitions.Where(t => !t.IsNil).Select(t =>
|
||||
return metadataReader.TypeDefinitions.Where(t => !t.IsNil).Select(t =>
|
||||
{
|
||||
var type = metadataReader.GetTypeDefinition(t);
|
||||
return metadataReader.GetString(type.Namespace) + "." + metadataReader.GetString(type.Name);
|
||||
});
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
return typeNames;
|
||||
}
|
||||
|
||||
private abstract class MSBuildXunitException : Xunit.Sdk.XunitException
|
||||
|
|
|
|||
|
|
@ -36,8 +36,16 @@ namespace Microsoft.AspNetCore.Razor.Design.IntegrationTests
|
|||
|
||||
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "MvcWithComponents.dll"), "MvcWithComponents.TestComponent");
|
||||
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "MvcWithComponents.dll"), "MvcWithComponents.Views.Shared.NavMenu");
|
||||
|
||||
// This is a component file with a .cshtml extension. It should appear in the main assembly, but not in the views dll.
|
||||
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "MvcWithComponents.dll"), "MvcWithComponents.Components.Counter");
|
||||
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "MvcWithComponents.dll"), "MvcWithComponents.Views.Home.Index");
|
||||
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "MvcWithComponents.Views.dll"), "MvcWithComponents.Components.Counter");
|
||||
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "MvcWithComponents.Views.dll"), "AspNetCore.Components_Counter");
|
||||
|
||||
// Verify a regular View appears in the views dll, but not in the main assembly.
|
||||
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "MvcWithComponents.dll"), "AspNetCore.Views.Home.Index");
|
||||
Assert.AssemblyDoesNotContainType(result, Path.Combine(OutputPath, "MvcWithComponents.dll"), "AspNetCore.Views_Home_Index");
|
||||
Assert.AssemblyContainsType(result, Path.Combine(OutputPath, "MvcWithComponents.Views.dll"), "AspNetCore.Views_Home_Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<RazorComponent Include="@(Content->WithMetadataValue('Extension', '.cshtml'))" />
|
||||
<RazorComponent Include="**/*.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in New Issue