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); }