Ejemplo n.º 1
0
        /// <summary>
        /// Runs all this.variations and executes the specified continuation at the end.
        /// </summary>
        /// <param name="continuation">The continuation to execute at the end of execution.</param>
        public override void RunVariations(IAsyncContinuation continuation)
        {
            // Build CodeDOM tree
            var codeUnit = this.BuildCompiledCodeUnit();

            // Generate code
            ExtendedCodeGenerator generator = this.language.CreateCodeGenerator();
            var options = new SafeCodeGeneratorOptions()
            {
                BracingStyle = "C",
                IndentString = "    ",
            };

            this.generatedCode = generator.GenerateCodeFromCompileUnit(codeUnit, options);
            this.Log.WriteLine(LogLevel.Trace, this.generatedCode);

            this.CompileAndRunVariations(continuation, this.generatedCode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and
        /// outputs it to the specified a string.
        /// </summary>
        /// <param name="codeUnit">A <see cref="CodeCompileUnit"/> to generate code for.</param>
        /// <returns>The generated code.</returns>
        protected virtual string GenerateCodeFromCompileUnit(CodeCompileUnit codeUnit)
        {
            ExtendedCodeGenerator generator = this.language.CreateCodeGenerator();
            StringBuilder         sb        = new StringBuilder();

            using (var stringWriter = new StringWriter(sb, CultureInfo.InvariantCulture))
            {
                var options = new SafeCodeGeneratorOptions()
                {
                    BracingStyle = "C",
                    IndentString = "    ",
                };

                generator.GenerateCodeFromCompileUnit(codeUnit, stringWriter, options);
            }

            return(sb.ToString());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and
 /// outputs it to the specified text writer using the specified options.
 /// </summary>
 /// <param name="compileUnit">A <see cref="CodeCompileUnit"/> to generate code for.</param>
 /// <param name="writer">The <see cref="TextWriter"/> to output code to.</param>
 /// <param name="options">A <see cref="SafeCodeGeneratorOptions"/> that indicates the options to use for generating code.</param>
 public override void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, TextWriter writer, SafeCodeGeneratorOptions options)
 {
     writer.WriteLine("Option Infer");
     base.GenerateCodeFromCompileUnit(compileUnit, writer, options);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Runs all this.variations and executes the specified continuation at the end.
        /// </summary>
        /// <param name="continuation">The continuation to execute at the end of execution.</param>
        public override void RunVariations(IAsyncContinuation continuation)
        {
            // Build CodeDOM tree
            var codeUnit = this.BuildCompiledCodeUnit();

            // Generate code
            ExtendedCodeGenerator generator = this.language.CreateCodeGenerator();
            var options = new SafeCodeGeneratorOptions()
            {
                BracingStyle = "C",
                IndentString = "    ",
            };

            this.generatedCode = generator.GenerateCodeFromCompileUnit(codeUnit, options);
            this.Log.WriteLine(LogLevel.Trace, this.generatedCode);

            this.CompileAndRunVariations(continuation, this.generatedCode);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Generates code for the specified Code Document Object Model (CodeDOM) compilation unit and
 /// outputs it to the specified text writer using the specified options.
 /// </summary>
 /// <param name="compileUnit">A <see cref="CodeCompileUnit"/> to generate code for.</param>
 /// <param name="writer">The <see cref="TextWriter"/> to output code to.</param>
 /// <param name="options">A <see cref="SafeCodeGeneratorOptions"/> that indicates the options to use for generating code.</param>
 public override void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, TextWriter writer, SafeCodeGeneratorOptions options)
 {
     writer.WriteLine("Option Infer");
     base.GenerateCodeFromCompileUnit(compileUnit, writer, options);
 }
Ejemplo n.º 6
0
 public virtual void GenerateCodeFromType(CodeTypeDeclaration type, TextWriter writer, SafeCodeGeneratorOptions options)
 {
    using (StringWriter wrappedWriter = new StringWriter(CultureInfo.InvariantCulture))
    {
         this.WrappedCodeGenerator.GenerateCodeFromType(this.Rewriter.Rewrite(type), wrappedWriter, options);
         writer.Write(this.RewriteExtensionMethod(wrappedWriter.ToString()));
    }
 }
Ejemplo n.º 7
0
 public virtual void GenerateCodeFromStatement(CodeStatement statement, TextWriter writer, SafeCodeGeneratorOptions options)
 {
     using (var wrappedWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.WrappedCodeGenerator.GenerateCodeFromStatement(this.Rewriter.Rewrite(statement), wrappedWriter, options);
         writer.Write(this.RewriteExtensionMethod(wrappedWriter.ToString()));
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Generates code for the specified Code Document Object Model (CodeDOM) type declaration and
 /// outputs it to a string using the specified options.
 /// </summary>
 /// <param name="type">A <see cref="CodeTypeDeclaration"/> that indicates the type to generate code for.</param>
 /// <param name="options">A <see cref="SafeCodeGeneratorOptions"/> that indicates the options to use for generating code.</param>
 /// <returns>The generated code.</returns>
 public string GenerateCodeFromType(CodeTypeDeclaration type, SafeCodeGeneratorOptions options)
 {
     using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.GenerateCodeFromType(type, writer, options);
         return this.RewriteExtensionMethod(writer.ToString());
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Generates code for the specified Code Document Object Model (CodeDOM) statement and
 /// outputs it to a string using the specified options.
 /// </summary>
 /// <param name="statement">A <see cref="CodeStatement"/> containing the CodeDOM elements to translate.</param>
 /// <param name="options">A <see cref="SafeCodeGeneratorOptions"/> that indicates the options to use for generating code.</param>
 /// <returns>The generated code.</returns>
 public string GenerateCodeFromStatement(CodeStatement statement, SafeCodeGeneratorOptions options)
 {
     using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.GenerateCodeFromStatement(statement, writer, options);
         return this.RewriteExtensionMethod(writer.ToString());
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Generates code for the specified Code Document Object Model (CodeDOM) namespace and
 /// outputs it to a string using the specified options.
 /// </summary>
 /// <param name="ns">A <see cref="CodeNamespace"/> that indicates the namespace to generate code for.</param>
 /// <param name="options">A <see cref="SafeCodeGeneratorOptions"/> that indicates the options to use for generating code.</param>
 /// <returns>The generated code.</returns>
 public string GenerateCodeFromNamespace(CodeNamespace ns, SafeCodeGeneratorOptions options)
 {
     using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.GenerateCodeFromNamespace(ns, writer, options);
         return this.RewriteExtensionMethod(writer.ToString());
     }
 }
Ejemplo n.º 11
0
 public virtual void GenerateCodeFromExpression(CodeExpression expression, TextWriter writer, SafeCodeGeneratorOptions options)
 {
     using (StringWriter wrappedWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.WrappedCodeGenerator.GenerateCodeFromExpression(this.Rewriter.Rewrite(expression), wrappedWriter, options);
         writer.Write(this.RewriteExtensionMethod(wrappedWriter.ToString()));
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Generates code for the specified Code Document Object Model (CodeDOM) expression and outputs it to a string
 /// using the specified options.
 /// </summary>
 /// <param name="expression">A <see cref="CodeExpression"/> that indicates the expression to generate code for.</param>
 /// <param name="options">A <see cref="SafeCodeGeneratorOptions"/> that indicates the options to use for generating code.</param>
 /// <returns>The generated code.</returns>
 public string GenerateCodeFromExpression(CodeExpression expression, SafeCodeGeneratorOptions options)
 {
     using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.GenerateCodeFromExpression(expression, writer, options);
         return this.RewriteExtensionMethod(writer.ToString());
     }
 }
Ejemplo n.º 13
0
 public virtual void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, TextWriter writer, SafeCodeGeneratorOptions options)
 {
     using (var wrappingWriter = new StringWriter(CultureInfo.InvariantCulture))
     {
         this.WrappedCodeGenerator.GenerateCodeFromCompileUnit(this.Rewriter.Rewrite(compileUnit), wrappingWriter, options);
         string rewrittenResults = this.RewriteExtensionMethod(wrappingWriter.ToString());
         writer.Write(rewrittenResults);
     }
 }