PR changes

\n\nCommit migrated from ef1a7507c9
This commit is contained in:
Pranav K 2019-01-07 15:43:28 -08:00
parent 500bdc1fd4
commit 4e909515a7
3 changed files with 14 additions and 7 deletions

View File

@ -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

View File

@ -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");
}
}
}

View File

@ -28,7 +28,7 @@
</ItemGroup>
<ItemGroup>
<RazorComponent Include="@(Content->WithMetadataValue('Extension', '.cshtml'))" />
<RazorComponent Include="**/*.cshtml" />
</ItemGroup>
<ItemGroup>