private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results) { System.Web.Compilation.BuildProvider provider = null; foreach (CompilerError error in results.Errors) { if (!error.IsWarning) { System.Web.Compilation.BuildProvider buildProviderFromLinePragma = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName); if (((buildProviderFromLinePragma != null) && (buildProviderFromLinePragma is BaseTemplateBuildProvider)) && (buildProviderFromLinePragma != provider)) { provider = buildProviderFromLinePragma; CompilerResults results2 = new CompilerResults(null); foreach (string str in results.Output) { results2.Output.Add(str); } results2.PathToAssembly = results.PathToAssembly; results2.NativeCompilerReturnValue = results.NativeCompilerReturnValue; results2.Errors.Add(error); HttpCompileException compileException = new HttpCompileException(results2, assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProviderFromLinePragma)); BuildResult result = new BuildResultCompileError(buildProviderFromLinePragma.VirtualPathObject, compileException); buildProviderFromLinePragma.SetBuildResultDependencies(result); BuildManager.CacheVPathBuildResult(buildProviderFromLinePragma.VirtualPathObject, result, this._utcStart); } } } }
private void CacheAssemblyResults(AssemblyBuilder assemblyBuilder, CompilerResults results) { foreach (System.Web.Compilation.BuildProvider provider in assemblyBuilder.BuildProviders) { BuildResult buildResult = provider.GetBuildResult(results); if ((buildResult != null) && !BuildManager.CacheVPathBuildResult(provider.VirtualPathObject, buildResult, this._utcStart)) { break; } } }
private void CacheAssemblyResults(AssemblyBuilder assemblyBuilder, CompilerResults results) { foreach (BuildProvider buildProvider in assemblyBuilder.BuildProviders) { BuildResult result = buildProvider.GetBuildResult(results); // If the provider didn't produce anything, ignore it if (result == null) { continue; } // If CacheVPathBuildResult returns false, something was found to be invalidated // and we need to abort the caching (VSWhidbey 578372) if (!BuildManager.CacheVPathBuildResult(buildProvider.VirtualPathObject, result, _utcStart)) { break; } #if DBG if (results != null) { if (DelayLoadType.Enabled) { Debug.Trace("BuildManager", buildProvider.VirtualPath + " Delay Load Assembly"); } else { Debug.Trace("BuildManager", buildProvider.VirtualPath + results.CompiledAssembly.EscapedCodeBase); } } else { Debug.Trace("BuildManager", buildProvider.VirtualPath + ": no assembly"); } #endif } }
// Cache the various compile errors found during batching private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results) { BuildProvider previous = null; // Go through all the compile errors foreach (CompilerError error in results.Errors) { // Skip warnings if (error.IsWarning) { continue; } // Try to map the error back to a BuildProvider. If we can't, skip the error. BuildProvider buildProvider = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName); if (buildProvider == null) { continue; } // Only cache the error for template controls. Otherwise, for file types like // asmx/ashx, it's too likely that two of them define the same class. if (!(buildProvider is BaseTemplateBuildProvider)) { continue; } // If the error is for the same page as the previous one, ignore it if (buildProvider == previous) { continue; } previous = buildProvider; // Create a new CompilerResults for this error CompilerResults newResults = new CompilerResults(null /*tempFiles*/); // Copy all the output to the new result. Note that this will include all the // error lines, not just the ones for this BuildProvider. But that's not a big deal, // and we can't easily filter the output here. foreach (string s in results.Output) { newResults.Output.Add(s); } // Copy various other fields to the new CompilerResults object newResults.PathToAssembly = results.PathToAssembly; newResults.NativeCompilerReturnValue = results.NativeCompilerReturnValue; // Add this error. It will be the only one in the CompilerResults object. newResults.Errors.Add(error); // Create a new HttpCompileException & BuildResultCompileError to wrap this error HttpCompileException e = new HttpCompileException(newResults, assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProvider)); BuildResult result = new BuildResultCompileError(buildProvider.VirtualPathObject, e); // Add the dependencies to the compile error build provider, so that // we will retry compilation when a dependency changes buildProvider.SetBuildResultDependencies(result); // Cache it BuildManager.CacheVPathBuildResult(buildProvider.VirtualPathObject, result, _utcStart); } }