Merge remote-tracking branch 'origin/release/2.1' into dev

This commit is contained in:
N. Taylor Mullen 2018-03-26 12:40:03 -07:00
commit 7c0a486bcc
1 changed files with 9 additions and 7 deletions

View File

@ -3,7 +3,7 @@
using System;
using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Testing;
namespace Microsoft.AspNetCore.Razor.Language
{
@ -11,16 +11,18 @@ namespace Microsoft.AspNetCore.Razor.Language
{
public static string GetProjectDirectory(Type type)
{
var currentDirectory = new DirectoryInfo(AppContext.BaseDirectory);
var name = type.GetTypeInfo().Assembly.GetName().Name;
var solutionDir = TestPathUtilities.GetSolutionRootDirectory("Razor");
while (currentDirectory != null &&
!string.Equals(currentDirectory.Name, name, StringComparison.Ordinal))
var assemblyName = type.Assembly.GetName().Name;
var projectDirectory = Path.Combine(solutionDir, "test", assemblyName);
if (!Directory.Exists(projectDirectory))
{
currentDirectory = currentDirectory.Parent;
throw new InvalidOperationException(
$@"Could not locate project directory for type {type.FullName}.
Directory probe path: {projectDirectory}.");
}
return currentDirectory.FullName;
return projectDirectory;
}
}
}