Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit bb5eb96

Browse files
committed
Load the precompilation type from the loaded assembly
1 parent 9ea37a1 commit bb5eb96

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/Microsoft.AspNetCore.Mvc.Razor/Compilation/CompiledViewManfiest.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ public static class CompiledViewManfiest
1515

1616
public static Type GetManifestType(AssemblyPart assemblyPart, string typeName)
1717
{
18-
EnsureFeatureAssembly(assemblyPart);
19-
20-
var precompiledAssemblyName = new AssemblyName(assemblyPart.Assembly.FullName);
21-
precompiledAssemblyName.Name = precompiledAssemblyName.Name + PrecompiledViewsAssemblySuffix;
22-
23-
return Type.GetType($"{typeName},{precompiledAssemblyName}");
18+
var assembly = GetFeatureAssembly(assemblyPart);
19+
return assembly?.GetType(typeName);
2420
}
2521

26-
private static void EnsureFeatureAssembly(AssemblyPart assemblyPart)
22+
private static Assembly GetFeatureAssembly(AssemblyPart assemblyPart)
2723
{
2824
if (assemblyPart.Assembly.IsDynamic || string.IsNullOrEmpty(assemblyPart.Assembly.Location))
2925
{
30-
return;
26+
return null;
3127
}
3228

3329
var precompiledAssemblyFileName = assemblyPart.Assembly.GetName().Name
@@ -41,13 +37,15 @@ private static void EnsureFeatureAssembly(AssemblyPart assemblyPart)
4137
{
4238
try
4339
{
44-
Assembly.LoadFile(precompiledAssemblyFilePath);
40+
return Assembly.LoadFile(precompiledAssemblyFilePath);
4541
}
4642
catch (FileLoadException)
4743
{
4844
// Don't throw if assembly cannot be loaded. This can happen if the file is not a managed assembly.
4945
}
5046
}
47+
48+
return null;
5149
}
5250
}
5351
}

0 commit comments

Comments
 (0)