internal AssemblyBuilder(CompilationSection compConfig, ICollection referencedAssemblies, CompilerType compilerType, string outputAssemblyName) { this._compConfig = compConfig; this._outputAssemblyName = outputAssemblyName; this._initialReferencedAssemblies = AssemblySet.Create(referencedAssemblies); this._compilerType = compilerType.Clone(); if (BuildManager.PrecompilingWithDebugInfo) { this._compilerType.CompilerParameters.IncludeDebugInformation = true; } else if (BuildManager.PrecompilingForDeployment) { this._compilerType.CompilerParameters.IncludeDebugInformation = false; } else if (DeploymentSection.RetailInternal) { this._compilerType.CompilerParameters.IncludeDebugInformation = false; } else if (this._compConfig.AssemblyPostProcessorTypeInternal != null) { this._compilerType.CompilerParameters.IncludeDebugInformation = true; } this._tempFiles.KeepFiles = this._compilerType.CompilerParameters.IncludeDebugInformation; this._codeProvider = CompilationUtil.CreateCodeDomProviderNonPublic(this._compilerType.CodeDomProviderType); this._maxBatchSize = this._compConfig.MaxBatchSize; this._maxBatchGeneratedFileSize = this._compConfig.MaxBatchGeneratedFileSize * 0x400; }
protected internal override CodeCompileUnit GetCodeCompileUnit(out IDictionary linePragmasTable) { Debug.Assert(_parser != null); // Return the provider type and compiler params Type codeDomProviderType = _parser.CompilerType.CodeDomProviderType; // Create a code generator for the language CodeDomProvider codeDomProvider = CompilationUtil.CreateCodeDomProviderNonPublic( codeDomProviderType); // Create a designer mode codedom tree for the page BaseCodeDomTreeGenerator treeGenerator = CreateCodeDomTreeGenerator(_parser); treeGenerator.SetDesignerMode(); CodeCompileUnit ccu = treeGenerator.GetCodeDomTree(codeDomProvider, new StringResourceBuilder(), VirtualPathObject); linePragmasTable = treeGenerator.LinePragmasTable; // This code is used to see the full generated code in the debugger. Just uncomment and look at // generatedCode in the debugger. Don't check in with this code uncommented! #if TESTCODE Stream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream, System.Text.Encoding.Unicode); codeDomProvider.GenerateCodeFromCompileUnit(ccu, writer, null /*CodeGeneratorOptions*/); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); TextReader reader = new StreamReader(stream); string generatedCode = reader.ReadToEnd(); #endif return(ccu); }
protected internal override CodeCompileUnit GetCodeCompileUnit(out IDictionary linePragmasTable) { CodeDomProvider codeDomProvider = CompilationUtil.CreateCodeDomProviderNonPublic(this._parser.CompilerType.CodeDomProviderType); BaseCodeDomTreeGenerator generator = this.CreateCodeDomTreeGenerator(this._parser); generator.SetDesignerMode(); CodeCompileUnit unit = generator.GetCodeDomTree(codeDomProvider, new StringResourceBuilder(), base.VirtualPathObject); linePragmasTable = generator.LinePragmasTable; return(unit); }