|
8 | 8 | using System.Reflection;
|
9 | 9 | using System.Threading.Tasks;
|
10 | 10 | using Microsoft.AspNet.FileProviders;
|
| 11 | +using Microsoft.AspNet.Mvc.Internal; |
11 | 12 | using Microsoft.AspNet.Mvc.Razor.Compilation;
|
12 | 13 | using Microsoft.AspNet.Mvc.Razor.Directives;
|
13 | 14 | using Microsoft.AspNet.Mvc.Razor.Internal;
|
@@ -92,7 +93,7 @@ protected virtual RazorFileInfoCollection CreateFileInfoCollection()
|
92 | 93 | var file = filesToProcess[index];
|
93 | 94 |
|
94 | 95 | PrecompilationCacheEntry cacheEntry;
|
95 |
| - if(!PreCompilationCache.TryGetValue(file.RelativePath, out cacheEntry)) |
| 96 | + if (!PreCompilationCache.TryGetValue(file.RelativePath, out cacheEntry)) |
96 | 97 | {
|
97 | 98 | cacheEntry = GetCacheEntry(file);
|
98 | 99 | PreCompilationCache.Set(
|
@@ -163,22 +164,17 @@ protected virtual RazorFileInfoCollection GeneratePrecompiledAssembly(
|
163 | 164 | }
|
164 | 165 | else
|
165 | 166 | {
|
166 |
| - assemblyStream.Position = 0; |
167 |
| - var assemblyBytes = assemblyStream.ToArray(); |
168 | 167 | var assemblyResource = new ResourceDescription(assemblyResourceName,
|
169 |
| - () => new MemoryStream(assemblyBytes), |
| 168 | + () => GetNonDisposableStream(assemblyStream), |
170 | 169 | isPublic: true);
|
171 | 170 | CompileContext.Resources.Add(assemblyResource);
|
172 | 171 |
|
173 | 172 | string symbolsResourceName = null;
|
174 | 173 | if (pdbStream != null)
|
175 | 174 | {
|
176 | 175 | symbolsResourceName = resourcePrefix + ".pdb";
|
177 |
| - pdbStream.Position = 0; |
178 |
| - var pdbBytes = pdbStream.ToArray(); |
179 |
| - |
180 | 176 | var pdbResource = new ResourceDescription(symbolsResourceName,
|
181 |
| - () => new MemoryStream(pdbBytes), |
| 177 | + () => GetNonDisposableStream(pdbStream), |
182 | 178 | isPublic: true);
|
183 | 179 |
|
184 | 180 | CompileContext.Resources.Add(pdbResource);
|
@@ -279,6 +275,12 @@ private static void AddRange<TVal>(IList<TVal> target, IEnumerable<TVal> source)
|
279 | 275 | }
|
280 | 276 | }
|
281 | 277 |
|
| 278 | + private static Stream GetNonDisposableStream(Stream stream) |
| 279 | + { |
| 280 | + stream.Position = 0; |
| 281 | + return new NonDisposableStream(stream); |
| 282 | + } |
| 283 | + |
282 | 284 | private class PrecompileRazorFileInfoCollection : RazorFileInfoCollection
|
283 | 285 | {
|
284 | 286 | public PrecompileRazorFileInfoCollection(string assemblyResourceName,
|
|
0 commit comments