Don't lock metadata references

This commit is contained in:
David Fowler 2014-10-27 16:14:32 -07:00
parent 4cddf880ec
commit 653d31b336
1 changed files with 6 additions and 1 deletions

View File

@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Reflection.PortableExecutable;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.AspNet.FileSystems; using Microsoft.AspNet.FileSystems;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
@ -174,7 +175,11 @@ namespace Microsoft.AspNet.Mvc.Razor.Compilation
{ {
var metadata = _metadataFileCache.GetOrAdd(path, _ => var metadata = _metadataFileCache.GetOrAdd(path, _ =>
{ {
return AssemblyMetadata.CreateFromStream(File.OpenRead(path)); using (var stream = File.OpenRead(path))
{
var moduleMetadata = ModuleMetadata.CreateFromStream(stream, PEStreamOptions.PrefetchMetadata);
return AssemblyMetadata.Create(moduleMetadata);
}
}); });
return metadata.GetReference(); return metadata.GetReference();