diff --git a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs index 6f9abe6170..dfe3c96be9 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/Compilation/RoslynCompilationService.cs @@ -20,8 +20,8 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation /// public class RoslynCompilationService : ICompilationService { - private readonly ConcurrentDictionary _metadataFileCache = - new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); + private readonly ConcurrentDictionary _metadataFileCache = + new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); private readonly ILibraryManager _libraryManager; private readonly IApplicationEnvironment _environment; @@ -172,15 +172,12 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation private MetadataReference CreateMetadataFileReference(string path) { - return _metadataFileCache.GetOrAdd(path, _ => + var metadata = _metadataFileCache.GetOrAdd(path, _ => { - // TODO: What about access to the file system? We need to be able to - // read files from anywhere on disk, not just under the web root - using (var stream = File.OpenRead(path)) - { - return new MetadataImageReference(stream); - } + return AssemblyMetadata.CreateFromImageStream(File.OpenRead(path)); }); + + return new MetadataImageReference(metadata); } private static CompilationMessage GetCompilationMessage(DiagnosticFormatter formatter, Diagnostic diagnostic)