Load the precompilation type from the loaded assembly
This commit is contained in:
parent
9ea37a1bbb
commit
bb5eb96625
|
|
@ -15,19 +15,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
|
|
||||||
public static Type GetManifestType(AssemblyPart assemblyPart, string typeName)
|
public static Type GetManifestType(AssemblyPart assemblyPart, string typeName)
|
||||||
{
|
{
|
||||||
EnsureFeatureAssembly(assemblyPart);
|
var assembly = GetFeatureAssembly(assemblyPart);
|
||||||
|
return assembly?.GetType(typeName);
|
||||||
var precompiledAssemblyName = new AssemblyName(assemblyPart.Assembly.FullName);
|
|
||||||
precompiledAssemblyName.Name = precompiledAssemblyName.Name + PrecompiledViewsAssemblySuffix;
|
|
||||||
|
|
||||||
return Type.GetType($"{typeName},{precompiledAssemblyName}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EnsureFeatureAssembly(AssemblyPart assemblyPart)
|
private static Assembly GetFeatureAssembly(AssemblyPart assemblyPart)
|
||||||
{
|
{
|
||||||
if (assemblyPart.Assembly.IsDynamic || string.IsNullOrEmpty(assemblyPart.Assembly.Location))
|
if (assemblyPart.Assembly.IsDynamic || string.IsNullOrEmpty(assemblyPart.Assembly.Location))
|
||||||
{
|
{
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var precompiledAssemblyFileName = assemblyPart.Assembly.GetName().Name
|
var precompiledAssemblyFileName = assemblyPart.Assembly.GetName().Name
|
||||||
|
|
@ -41,13 +37,15 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Compilation
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Assembly.LoadFile(precompiledAssemblyFilePath);
|
return Assembly.LoadFile(precompiledAssemblyFilePath);
|
||||||
}
|
}
|
||||||
catch (FileLoadException)
|
catch (FileLoadException)
|
||||||
{
|
{
|
||||||
// Don't throw if assembly cannot be loaded. This can happen if the file is not a managed assembly.
|
// Don't throw if assembly cannot be loaded. This can happen if the file is not a managed assembly.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue