Renamed CodeBuilder related classes to CodeGenerator

- Now that what used to be CodeGenerators are now ChunkGenerators we can rename the CodeBuilder into its correct structure: a CodeGenerator.
- Moved the TagHelperAttributeValueCodeRenderer from the TagHelpers namespace into the CodeGeneration namespace.
- Went through several classes and remove and sorted usings.
- Updated test files to abide by the new naming convention of Builders => CodeGenerators.

#140
This commit is contained in:
N. Taylor Mullen 2015-05-27 16:21:39 -07:00
parent 5df9b52afe
commit 6df8bc23f1
46 changed files with 131 additions and 142 deletions

View File

@ -41,9 +41,9 @@ namespace Microsoft.AspNet.Razor
return new RazorChunkGenerator(className, rootNamespaceName, sourceFileName, host); return new RazorChunkGenerator(className, rootNamespaceName, sourceFileName, host);
} }
public override CodeBuilder CreateCodeBuilder(CodeBuilderContext context) public override CodeGenerator CreateCodeGenerator(CodeGeneratorContext context)
{ {
return new CSharpCodeBuilder(context); return new CSharpCodeGenerator(context);
} }
} }
} }

View File

@ -10,13 +10,13 @@ using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.CodeGeneration namespace Microsoft.AspNet.Razor.CodeGeneration
{ {
public class CSharpCodeBuilder : CodeBuilder public class CSharpCodeGenerator : CodeGenerator
{ {
// See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx // See http://msdn.microsoft.com/en-us/library/system.codedom.codechecksumpragma.checksumalgorithmid.aspx
private const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}"; private const string Sha1AlgorithmId = "{ff1816ec-aa5e-4d10-87f7-6f4963833460}";
private const int DisableAsyncWarning = 1998; private const int DisableAsyncWarning = 1998;
public CSharpCodeBuilder(CodeBuilderContext context) public CSharpCodeGenerator(CodeGeneratorContext context)
: base(context) : base(context)
{ {
} }
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
return new CSharpCodeWriter(); return new CSharpCodeWriter();
} }
public override CodeBuilderResult Build() public override CodeGeneratorResult Generate()
{ {
var writer = CreateCodeWriter(); var writer = CreateCodeWriter();
@ -81,11 +81,11 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
} }
} }
return new CodeBuilderResult(writer.GenerateCode(), writer.LineMappingManager.Mappings); return new CodeGeneratorResult(writer.GenerateCode(), writer.LineMappingManager.Mappings);
} }
protected virtual CSharpCodeVisitor CreateCSharpCodeVisitor([NotNull] CSharpCodeWriter writer, protected virtual CSharpCodeVisitor CreateCSharpCodeVisitor([NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context) [NotNull] CodeGeneratorContext context)
{ {
return new CSharpCodeVisitor(writer, context); return new CSharpCodeVisitor(writer, context);
} }

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
internal static readonly string RunnerVariableName = "__tagHelperRunner"; internal static readonly string RunnerVariableName = "__tagHelperRunner";
private readonly CSharpCodeWriter _writer; private readonly CSharpCodeWriter _writer;
private readonly CodeBuilderContext _context; private readonly CodeGeneratorContext _context;
private readonly IChunkVisitor _bodyVisitor; private readonly IChunkVisitor _bodyVisitor;
private readonly IChunkVisitor _literalBodyVisitor; private readonly IChunkVisitor _literalBodyVisitor;
private readonly GeneratedTagHelperContext _tagHelperContext; private readonly GeneratedTagHelperContext _tagHelperContext;
@ -34,12 +34,12 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
/// </summary> /// </summary>
/// <param name="bodyVisitor">The <see cref="IChunkVisitor"/> used to render chunks found in the body.</param> /// <param name="bodyVisitor">The <see cref="IChunkVisitor"/> used to render chunks found in the body.</param>
/// <param name="writer">The <see cref="CSharpCodeWriter"/> used to write code.</param> /// <param name="writer">The <see cref="CSharpCodeWriter"/> used to write code.</param>
/// <param name="context">A <see cref="CodeBuilderContext"/> instance that contains information about /// <param name="context">A <see cref="CodeGeneratorContext"/> instance that contains information about
/// the current code generation process.</param> /// the current code generation process.</param>
public CSharpTagHelperCodeRenderer( public CSharpTagHelperCodeRenderer(
[NotNull] IChunkVisitor bodyVisitor, [NotNull] IChunkVisitor bodyVisitor,
[NotNull] CSharpCodeWriter writer, [NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context) [NotNull] CodeGeneratorContext context)
{ {
_bodyVisitor = bodyVisitor; _bodyVisitor = bodyVisitor;
_writer = writer; _writer = writer;
@ -653,7 +653,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
public CSharpLiteralCodeVisitor( public CSharpLiteralCodeVisitor(
CSharpTagHelperCodeRenderer tagHelperRenderer, CSharpTagHelperCodeRenderer tagHelperRenderer,
CSharpCodeWriter writer, CSharpCodeWriter writer,
CodeBuilderContext context) CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
// Ensure that no matter how this class is used, we don't create numerous CSharpTagHelperCodeRenderer // Ensure that no matter how this class is used, we don't create numerous CSharpTagHelperCodeRenderer

View File

@ -3,20 +3,20 @@
namespace Microsoft.AspNet.Razor.CodeGeneration namespace Microsoft.AspNet.Razor.CodeGeneration
{ {
public abstract class CodeBuilder public abstract class CodeGenerator
{ {
private readonly CodeBuilderContext _context; private readonly CodeGeneratorContext _context;
public CodeBuilder(CodeBuilderContext context) public CodeGenerator(CodeGeneratorContext context)
{ {
_context = context; _context = context;
} }
protected CodeBuilderContext Context protected CodeGeneratorContext Context
{ {
get { return _context; } get { return _context; }
} }
public abstract CodeBuilderResult Build(); public abstract CodeGeneratorResult Generate();
} }
} }

View File

@ -8,17 +8,17 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
/// <summary> /// <summary>
/// Context object with information used to generate a Razor page. /// Context object with information used to generate a Razor page.
/// </summary> /// </summary>
public class CodeBuilderContext : ChunkGeneratorContext public class CodeGeneratorContext : ChunkGeneratorContext
{ {
/// <summary> /// <summary>
/// Instantiates a new instance of the <see cref="CodeBuilderContext"/> object. /// Instantiates a new instance of the <see cref="CodeGeneratorContext"/> object.
/// </summary> /// </summary>
/// <param name="generatorContext">A <see cref="ChunkGeneratorContext"/> to copy information from.</param> /// <param name="generatorContext">A <see cref="ChunkGeneratorContext"/> to copy information from.</param>
/// <param name="errorSink"> /// <param name="errorSink">
/// The <see cref="ErrorSink"/> used to collect <see cref="RazorError"/>s encountered /// The <see cref="ErrorSink"/> used to collect <see cref="RazorError"/>s encountered
/// when parsing the current Razor document. /// when parsing the current Razor document.
/// </param> /// </param>
public CodeBuilderContext(ChunkGeneratorContext generatorContext, ErrorSink errorSink) public CodeGeneratorContext(ChunkGeneratorContext generatorContext, ErrorSink errorSink)
: base(generatorContext) : base(generatorContext)
{ {
ErrorSink = errorSink; ErrorSink = errorSink;
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
} }
// Internal for testing. // Internal for testing.
internal CodeBuilderContext(RazorEngineHost host, internal CodeGeneratorContext(RazorEngineHost host,
string className, string className,
string rootNamespace, string rootNamespace,
string sourceFile, string sourceFile,

View File

@ -5,9 +5,9 @@ using System.Collections.Generic;
namespace Microsoft.AspNet.Razor.CodeGeneration namespace Microsoft.AspNet.Razor.CodeGeneration
{ {
public class CodeBuilderResult public class CodeGeneratorResult
{ {
public CodeBuilderResult(string code, IList<LineMapping> designTimeLineMappings) public CodeGeneratorResult(string code, IList<LineMapping> designTimeLineMappings)
{ {
Code = code; Code = code;
DesignTimeLineMappings = designTimeLineMappings; DesignTimeLineMappings = designTimeLineMappings;

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
/// Indicates that expressions should be written to the output stream /// Indicates that expressions should be written to the output stream
/// </summary> /// </summary>
/// <example> /// <example>
/// If @foo is rendered with WriteToOutput, the code builder would output the following code: /// If @foo is rendered with WriteToOutput, the code generator would output the following code:
/// ///
/// Write(foo); /// Write(foo);
/// </example> /// </example>
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration
/// the code exists will be used to render it /// the code exists will be used to render it
/// </summary> /// </summary>
/// <example> /// <example>
/// If @foo is rendered with InjectCode, the code builder would output the following code: /// If @foo is rendered with InjectCode, the code generator would output the following code:
/// ///
/// foo /// foo
/// </example> /// </example>

View File

@ -2,11 +2,10 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.AspNet.Razor.CodeGeneration;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Razor.TagHelpers namespace Microsoft.AspNet.Razor.CodeGeneration
{ {
/// <summary> /// <summary>
/// Renders code for tag helper property initialization. /// Renders code for tag helper property initialization.
@ -21,7 +20,7 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// The <see cref="TagHelperAttributeDescriptor"/> to generate code for. /// The <see cref="TagHelperAttributeDescriptor"/> to generate code for.
/// </param> /// </param>
/// <param name="writer">The <see cref="CSharpCodeWriter"/> that's used to write code.</param> /// <param name="writer">The <see cref="CSharpCodeWriter"/> that's used to write code.</param>
/// <param name="context">A <see cref="ChunkGeneratorContext"/> instance that contains information about /// <param name="context">A <see cref="Chunks.Generators.ChunkGeneratorContext"/> instance that contains information about
/// the current code generation process.</param> /// the current code generation process.</param>
/// <param name="renderAttributeValue"> /// <param name="renderAttributeValue">
/// <see cref="Action"/> that renders the raw value of the HTML attribute. /// <see cref="Action"/> that renders the raw value of the HTML attribute.
@ -31,11 +30,12 @@ namespace Microsoft.AspNet.Razor.TagHelpers
/// C# expressions e.g. <c>"PropertyName"</c>. <c>true</c> if the attribute value contain at least one in-line /// C# expressions e.g. <c>"PropertyName"</c>. <c>true</c> if the attribute value contain at least one in-line
/// Razor construct e.g. <c>"@(@readonly)"</c>. /// Razor construct e.g. <c>"@(@readonly)"</c>.
/// </param> /// </param>
public virtual void RenderAttributeValue([NotNull] TagHelperAttributeDescriptor attributeDescriptor, public virtual void RenderAttributeValue(
[NotNull] CSharpCodeWriter writer, [NotNull] TagHelperAttributeDescriptor attributeDescriptor,
[NotNull] CodeBuilderContext context, [NotNull] CSharpCodeWriter writer,
[NotNull] Action<CSharpCodeWriter> renderAttributeValue, [NotNull] CodeGeneratorContext context,
bool complexValue) [NotNull] Action<CSharpCodeWriter> renderAttributeValue,
bool complexValue)
{ {
renderAttributeValue(writer); renderAttributeValue(writer);
} }

View File

@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
{ {
public class CSharpBaseTypeVisitor : CodeVisitor<CSharpCodeWriter> public class CSharpBaseTypeVisitor : CodeVisitor<CSharpCodeWriter>
{ {
public CSharpBaseTypeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context) public CSharpBaseTypeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
} }

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
private CSharpPaddingBuilder _paddingBuilder; private CSharpPaddingBuilder _paddingBuilder;
private CSharpTagHelperCodeRenderer _tagHelperCodeRenderer; private CSharpTagHelperCodeRenderer _tagHelperCodeRenderer;
public CSharpCodeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context) public CSharpCodeVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
_paddingBuilder = new CSharpPaddingBuilder(context.Host); _paddingBuilder = new CSharpPaddingBuilder(context.Host);
@ -519,7 +519,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
return RenderPreWriteStart(Writer, Context); return RenderPreWriteStart(Writer, Context);
} }
public static CSharpCodeWriter RenderPreWriteStart(CSharpCodeWriter writer, CodeBuilderContext context) public static CSharpCodeWriter RenderPreWriteStart(CSharpCodeWriter writer, CodeGeneratorContext context)
{ {
if (!string.IsNullOrEmpty(context.TargetWriterName)) if (!string.IsNullOrEmpty(context.TargetWriterName))
{ {

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
public CSharpDesignTimeHelpersVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor, public CSharpDesignTimeHelpersVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor,
[NotNull] CSharpCodeWriter writer, [NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context) [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
/// </summary> /// </summary>
/// <param name="writer">The <see cref="CSharpCodeWriter"/> used to write code.</param> /// <param name="writer">The <see cref="CSharpCodeWriter"/> used to write code.</param>
/// <param name="context"> /// <param name="context">
/// A <see cref="CodeBuilderContext"/> instance that contains information about the current code generation /// A <see cref="CodeGeneratorContext"/> instance that contains information about the current code generation
/// process. /// process.
/// </param> /// </param>
/// <param name="attributeTypeName"> /// <param name="attributeTypeName">
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
/// </param> /// </param>
public CSharpTagHelperAttributeValueVisitor( public CSharpTagHelperAttributeValueVisitor(
[NotNull] CSharpCodeWriter writer, [NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context, [NotNull] CodeGeneratorContext context,
string attributeTypeName) string attributeTypeName)
: base(writer, context) : base(writer, context)
{ {

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
private bool _foundTagHelpers; private bool _foundTagHelpers;
public CSharpTagHelperFieldDeclarationVisitor([NotNull] CSharpCodeWriter writer, public CSharpTagHelperFieldDeclarationVisitor([NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context) [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
_declaredTagHelpers = new HashSet<string>(StringComparer.Ordinal); _declaredTagHelpers = new HashSet<string>(StringComparer.Ordinal);

View File

@ -18,9 +18,9 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
/// Creates a new instance of <see cref="CSharpTagHelperRunnerInitializationVisitor"/>. /// Creates a new instance of <see cref="CSharpTagHelperRunnerInitializationVisitor"/>.
/// </summary> /// </summary>
/// <param name="writer">The <see cref="CSharpCodeWriter"/> used to generate code.</param> /// <param name="writer">The <see cref="CSharpCodeWriter"/> used to generate code.</param>
/// <param name="context">The <see cref="CodeBuilderContext"/>.</param> /// <param name="context">The <see cref="CodeGeneratorContext"/>.</param>
public CSharpTagHelperRunnerInitializationVisitor([NotNull] CSharpCodeWriter writer, public CSharpTagHelperRunnerInitializationVisitor([NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context) [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
_tagHelperContext = Context.Host.GeneratedClassContext.GeneratedTagHelperContext; _tagHelperContext = Context.Host.GeneratedClassContext.GeneratedTagHelperContext;

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
public CSharpTypeMemberVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor, public CSharpTypeMemberVisitor([NotNull] CSharpCodeVisitor csharpCodeVisitor,
[NotNull] CSharpCodeWriter writer, [NotNull] CSharpCodeWriter writer,
[NotNull] CodeBuilderContext context) [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
_csharpCodeVisitor = csharpCodeVisitor; _csharpCodeVisitor = csharpCodeVisitor;

View File

@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
private bool _foundTagHelpers; private bool _foundTagHelpers;
public CSharpUsingVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeBuilderContext context) public CSharpUsingVisitor([NotNull] CSharpCodeWriter writer, [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
ImportedUsings = new List<string>(); ImportedUsings = new List<string>();

View File

@ -10,14 +10,14 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
public abstract class ChunkVisitor<TWriter> : IChunkVisitor public abstract class ChunkVisitor<TWriter> : IChunkVisitor
where TWriter : CodeWriter where TWriter : CodeWriter
{ {
public ChunkVisitor([NotNull] TWriter writer, [NotNull] CodeBuilderContext context) public ChunkVisitor([NotNull] TWriter writer, [NotNull] CodeGeneratorContext context)
{ {
Writer = writer; Writer = writer;
Context = context; Context = context;
} }
protected TWriter Writer { get; private set; } protected TWriter Writer { get; private set; }
protected CodeBuilderContext Context { get; private set; } protected CodeGeneratorContext Context { get; private set; }
public void Accept([NotNull] IList<Chunk> chunks) public void Accept([NotNull] IList<Chunk> chunks)
{ {

View File

@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Razor.CodeGeneration.Visitors
public class CodeVisitor<TWriter> : ChunkVisitor<TWriter> public class CodeVisitor<TWriter> : ChunkVisitor<TWriter>
where TWriter : CodeWriter where TWriter : CodeWriter
{ {
public CodeVisitor([NotNull] TWriter writer, [NotNull] CodeBuilderContext context) public CodeVisitor([NotNull] TWriter writer, [NotNull] CodeGeneratorContext context)
: base(writer, context) : base(writer, context)
{ {
} }

View File

@ -19,15 +19,15 @@ namespace Microsoft.AspNet.Razor
/// Instantiates a new <see cref="GeneratorResults"/> instance. /// Instantiates a new <see cref="GeneratorResults"/> instance.
/// </summary> /// </summary>
/// <param name="parserResults">The results of parsing a document.</param> /// <param name="parserResults">The results of parsing a document.</param>
/// <param name="codeBuilderResult">The results of generating code for the document.</param> /// <param name="codeGeneratorResult">The results of generating code for the document.</param>
/// <param name="chunkTree">A <see cref="ChunkTree"/> for the document.</param> /// <param name="chunkTree">A <see cref="ChunkTree"/> for the document.</param>
public GeneratorResults([NotNull] ParserResults parserResults, public GeneratorResults([NotNull] ParserResults parserResults,
[NotNull] CodeBuilderResult codeBuilderResult, [NotNull] CodeGeneratorResult codeGeneratorResult,
[NotNull] ChunkTree chunkTree) [NotNull] ChunkTree chunkTree)
: this(parserResults.Document, : this(parserResults.Document,
parserResults.TagHelperDescriptors, parserResults.TagHelperDescriptors,
parserResults.ErrorSink, parserResults.ErrorSink,
codeBuilderResult, codeGeneratorResult,
chunkTree) chunkTree)
{ {
} }
@ -43,17 +43,17 @@ namespace Microsoft.AspNet.Razor
/// The <see cref="ErrorSink"/> used to collect <see cref="RazorError"/>s encountered when parsing the /// The <see cref="ErrorSink"/> used to collect <see cref="RazorError"/>s encountered when parsing the
/// current Razor document. /// current Razor document.
/// </param> /// </param>
/// <param name="codeBuilderResult">The results of generating code for the document.</param> /// <param name="codeGeneratorResult">The results of generating code for the document.</param>
/// <param name="chunkTree">A <see cref="ChunkTree"/> for the document.</param> /// <param name="chunkTree">A <see cref="ChunkTree"/> for the document.</param>
public GeneratorResults([NotNull] Block document, public GeneratorResults([NotNull] Block document,
[NotNull] IEnumerable<TagHelperDescriptor> tagHelperDescriptors, [NotNull] IEnumerable<TagHelperDescriptor> tagHelperDescriptors,
[NotNull] ErrorSink errorSink, [NotNull] ErrorSink errorSink,
[NotNull] CodeBuilderResult codeBuilderResult, [NotNull] CodeGeneratorResult codeGeneratorResult,
[NotNull] ChunkTree chunkTree) [NotNull] ChunkTree chunkTree)
: base(document, tagHelperDescriptors, errorSink) : base(document, tagHelperDescriptors, errorSink)
{ {
GeneratedCode = codeBuilderResult.Code; GeneratedCode = codeGeneratorResult.Code;
DesignTimeLineMappings = codeBuilderResult.DesignTimeLineMappings; DesignTimeLineMappings = codeGeneratorResult.DesignTimeLineMappings;
ChunkTree = chunkTree; ChunkTree = chunkTree;
} }

View File

@ -54,6 +54,6 @@ namespace Microsoft.AspNet.Razor
/// </summary> /// </summary>
public abstract RazorChunkGenerator CreateChunkGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host); public abstract RazorChunkGenerator CreateChunkGenerator(string className, string rootNamespaceName, string sourceFileName, RazorEngineHost host);
public abstract CodeBuilder CreateCodeBuilder(CodeBuilderContext chunkGeneratorContext); public abstract CodeGenerator CreateCodeGenerator(CodeGeneratorContext chunkGeneratorContext);
} }
} }

View File

@ -204,13 +204,13 @@ namespace Microsoft.AspNet.Razor
} }
/// <summary> /// <summary>
/// Gets an instance of the code builder and is provided an opportunity to decorate or replace it /// Gets an instance of the code generator and is provided an opportunity to decorate or replace it
/// </summary> /// </summary>
/// <param name="incomingBuilder">The code builder</param> /// <param name="incomingBuilder">The code generator</param>
/// <returns>Either the same code builder, after modifications, or a different code builder.</returns> /// <returns>Either the same code generator, after modifications, or a different code generator.</returns>
public virtual CodeBuilder DecorateCodeBuilder( public virtual CodeGenerator DecorateCodeGenerator(
[NotNull] CodeBuilder incomingBuilder, [NotNull] CodeGenerator incomingBuilder,
CodeBuilderContext context) CodeGeneratorContext context)
{ {
return incomingBuilder; return incomingBuilder;
} }

View File

@ -313,17 +313,17 @@ namespace Microsoft.AspNet.Razor
var results = parser.Parse(input); var results = parser.Parse(input);
// Generate code // Generate code
var generator = CreateChunkGenerator(className, rootNamespace, sourceFileName); var chunkGenerator = CreateChunkGenerator(className, rootNamespace, sourceFileName);
generator.DesignTimeMode = Host.DesignTimeMode; chunkGenerator.DesignTimeMode = Host.DesignTimeMode;
generator.Visit(results); chunkGenerator.Visit(results);
var codeBuilderContext = new CodeBuilderContext(generator.Context, results.ErrorSink); var codeGeneratorContext = new CodeGeneratorContext(chunkGenerator.Context, results.ErrorSink);
codeBuilderContext.Checksum = checksum; codeGeneratorContext.Checksum = checksum;
var builder = CreateCodeBuilder(codeBuilderContext); var codeGenerator = CreateCodeGenerator(codeGeneratorContext);
var builderResult = builder.Build(); var codeGeneratorResult = codeGenerator.Generate();
// Collect results and return // Collect results and return
return new GeneratorResults(results, builderResult, codeBuilderContext.ChunkTreeBuilder.ChunkTree); return new GeneratorResults(results, codeGeneratorResult, codeGeneratorContext.ChunkTreeBuilder.ChunkTree);
} }
protected internal virtual RazorChunkGenerator CreateChunkGenerator( protected internal virtual RazorChunkGenerator CreateChunkGenerator(
@ -351,9 +351,9 @@ namespace Microsoft.AspNet.Razor
return Host.DecorateRazorParser(parser, sourceFileName); return Host.DecorateRazorParser(parser, sourceFileName);
} }
protected internal virtual CodeBuilder CreateCodeBuilder(CodeBuilderContext context) protected internal virtual CodeGenerator CreateCodeGenerator(CodeGeneratorContext context)
{ {
return Host.DecorateCodeBuilder(Host.CodeLanguage.CreateCodeBuilder(context), context); return Host.DecorateCodeGenerator(Host.CodeLanguage.CreateCodeGenerator(context), context);
} }
private static string ComputeChecksum(Stream inputStream) private static string ComputeChecksum(Stream inputStream)

View File

@ -3,7 +3,6 @@
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.CodeGeneration; using Microsoft.AspNet.Razor.CodeGeneration;
using Microsoft.AspNet.Razor.CodeGeneration;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Xunit; using Xunit;
@ -45,12 +44,12 @@ namespace Microsoft.AspNet.Razor.Test
} }
[Fact] [Fact]
public void CreateCodeBuilder_ReturnsNewCSharpCodeBuilder() public void CreateCodeGenerator_ReturnsNewCSharpCodeGenerator()
{ {
// Arrange // Arrange
var language = new CSharpRazorCodeLanguage(); var language = new CSharpRazorCodeLanguage();
var host = new RazorEngineHost(language); var host = new RazorEngineHost(language);
var codeBuilderContext = new CodeBuilderContext( var codeGeneratorContext = new CodeGeneratorContext(
host, host,
"myclass", "myclass",
"myns", "myns",
@ -59,10 +58,10 @@ namespace Microsoft.AspNet.Razor.Test
errorSink: new ErrorSink()); errorSink: new ErrorSink());
// Act // Act
var generator = language.CreateCodeBuilder(codeBuilderContext); var generator = language.CreateCodeGenerator(codeGeneratorContext);
// Assert // Assert
Assert.IsType<CSharpCodeBuilder>(generator); Assert.IsType<CSharpCodeGenerator>(generator);
} }
} }
} }

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.Chunks
private static Mock<ChunkVisitor<CodeWriter>> CreateVisitor() private static Mock<ChunkVisitor<CodeWriter>> CreateVisitor()
{ {
var codeBuilderContext = new CodeBuilderContext( var codeGeneratorContext = new CodeGeneratorContext(
new RazorEngineHost(new CSharpRazorCodeLanguage()), new RazorEngineHost(new CSharpRazorCodeLanguage()),
"myclass", "myclass",
"myns", "myns",
@ -37,7 +37,7 @@ namespace Microsoft.AspNet.Razor.Chunks
shouldGenerateLinePragmas: false, shouldGenerateLinePragmas: false,
errorSink: new ErrorSink()); errorSink: new ErrorSink());
var writer = Mock.Of<CodeWriter>(); var writer = Mock.Of<CodeWriter>();
return new Mock<ChunkVisitor<CodeWriter>>(writer, codeBuilderContext); return new Mock<ChunkVisitor<CodeWriter>>(writer, codeGeneratorContext);
} }
private class MyTestChunk : Chunk private class MyTestChunk : Chunk

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
#if !DNXCORE50 #if !DNXCORE50
using Microsoft.AspNet.Razor.CodeGeneration;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test; using Microsoft.AspNet.Razor.Test;
using Microsoft.AspNet.Razor.Test.Generator; using Microsoft.AspNet.Razor.Test.Generator;
@ -10,9 +9,9 @@ using Microsoft.AspNet.Razor.Test.Utils;
using Moq; using Moq;
using Xunit; using Xunit;
namespace Microsoft.AspNet.Razor.Chunks namespace Microsoft.AspNet.Razor.CodeGeneration
{ {
public class CSharpCodeBuilderTests public class CSharpCodeGeneratorTest
{ {
[Fact] [Fact]
public void ChunkTreeWithUsings() public void ChunkTreeWithUsings()
@ -20,25 +19,25 @@ namespace Microsoft.AspNet.Razor.Chunks
var syntaxTreeNode = new Mock<Span>(new SpanBuilder()); var syntaxTreeNode = new Mock<Span>(new SpanBuilder());
var language = new CSharpRazorCodeLanguage(); var language = new CSharpRazorCodeLanguage();
var host = new CodeGenTestHost(language); var host = new CodeGenTestHost(language);
var codeBuilderContext = new CodeBuilderContext( var codeGeneratorContext = new CodeGeneratorContext(
host, host,
"TestClass", "TestClass",
"TestNamespace", "TestNamespace",
"Foo.cs", "Foo.cs",
shouldGenerateLinePragmas: false, shouldGenerateLinePragmas: false,
errorSink: new ErrorSink()); errorSink: new ErrorSink());
codeBuilderContext.ChunkTreeBuilder.AddUsingChunk("FakeNamespace1", syntaxTreeNode.Object); codeGeneratorContext.ChunkTreeBuilder.AddUsingChunk("FakeNamespace1", syntaxTreeNode.Object);
codeBuilderContext.ChunkTreeBuilder.AddUsingChunk("FakeNamespace2.SubNamespace", syntaxTreeNode.Object); codeGeneratorContext.ChunkTreeBuilder.AddUsingChunk("FakeNamespace2.SubNamespace", syntaxTreeNode.Object);
var codeBuilder = new CodeGenTestCodeBuilder(codeBuilderContext); var codeGenerator = new CodeGenTestCodeGenerator(codeGeneratorContext);
// Act // Act
var result = codeBuilder.Build(); var result = codeGenerator.Generate();
BaselineWriter.WriteBaseline( BaselineWriter.WriteBaseline(
@"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\Output\CSharpCodeBuilder.cs", @"test\Microsoft.AspNet.Razor.Test\TestFiles\CodeGenerator\Output\CSharpCodeGenerator.cs",
result.Code); result.Code);
var expectedOutput = TestFile.Create("TestFiles/CodeGenerator/Output/CSharpCodeBuilder.cs").ReadAllText(); var expectedOutput = TestFile.Create("TestFiles/CodeGenerator/Output/CSharpCodeGenerator.cs").ReadAllText();
// Assert // Assert
Assert.Equal(expectedOutput, result.Code); Assert.Equal(expectedOutput, result.Code);

View File

@ -177,19 +177,19 @@ namespace Microsoft.AspNet.Razor.Test.Generator
private static TrackingUniqueIdsTagHelperCodeRenderer CreateCodeRenderer() private static TrackingUniqueIdsTagHelperCodeRenderer CreateCodeRenderer()
{ {
var writer = new CSharpCodeWriter(); var writer = new CSharpCodeWriter();
var codeBuilderContext = CreateContext(); var codeGeneratorContext = CreateContext();
var visitor = new CSharpCodeVisitor(writer, codeBuilderContext); var visitor = new CSharpCodeVisitor(writer, codeGeneratorContext);
var codeRenderer = new TrackingUniqueIdsTagHelperCodeRenderer( var codeRenderer = new TrackingUniqueIdsTagHelperCodeRenderer(
visitor, visitor,
writer, writer,
codeBuilderContext); codeGeneratorContext);
visitor.TagHelperRenderer = codeRenderer; visitor.TagHelperRenderer = codeRenderer;
return codeRenderer; return codeRenderer;
} }
private static CodeBuilderContext CreateContext() private static CodeGeneratorContext CreateContext()
{ {
return new CodeBuilderContext( return new CodeGeneratorContext(
new ChunkGeneratorContext( new ChunkGeneratorContext(
new RazorEngineHost(new CSharpRazorCodeLanguage()), new RazorEngineHost(new CSharpRazorCodeLanguage()),
"MyClass", "MyClass",
@ -204,7 +204,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
public TrackingUniqueIdsTagHelperCodeRenderer( public TrackingUniqueIdsTagHelperCodeRenderer(
IChunkVisitor bodyVisitor, IChunkVisitor bodyVisitor,
CSharpCodeWriter writer, CSharpCodeWriter writer,
CodeBuilderContext context) CodeGeneratorContext context)
: base(bodyVisitor, writer, context) : base(bodyVisitor, writer, context)
{ {

View File

@ -1,14 +1,13 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.CodeGeneration; using Microsoft.AspNet.Razor.CodeGeneration;
namespace Microsoft.AspNet.Razor.Test.Generator namespace Microsoft.AspNet.Razor.Test.Generator
{ {
public class CodeGenTestCodeBuilder : CSharpCodeBuilder public class CodeGenTestCodeGenerator : CSharpCodeGenerator
{ {
public CodeGenTestCodeBuilder(CodeBuilderContext context) public CodeGenTestCodeGenerator(CodeGeneratorContext context)
: base(context) : base(context)
{ {
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.CodeGeneration; using Microsoft.AspNet.Razor.CodeGeneration;
namespace Microsoft.AspNet.Razor.Test.Generator namespace Microsoft.AspNet.Razor.Test.Generator
@ -13,15 +12,15 @@ namespace Microsoft.AspNet.Razor.Test.Generator
{ {
} }
public override CodeBuilder DecorateCodeBuilder(CodeBuilder incomingBuilder, CodeBuilderContext context) public override CodeGenerator DecorateCodeGenerator(CodeGenerator incomingBuilder, CodeGeneratorContext context)
{ {
if (incomingBuilder is CodeGenTestCodeBuilder) if (incomingBuilder is CodeGenTestCodeGenerator)
{ {
return incomingBuilder; return incomingBuilder;
} }
else else
{ {
return new CodeGenTestCodeBuilder(context); return new CodeGenTestCodeGenerator(context);
} }
} }
} }

View File

@ -6,9 +6,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.CodeGeneration; using Microsoft.AspNet.Razor.CodeGeneration;
using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Utils; using Microsoft.AspNet.Razor.Test.Utils;
using Microsoft.AspNet.Testing; using Microsoft.AspNet.Testing;
using Xunit; using Xunit;

View File

@ -42,38 +42,38 @@ namespace Microsoft.AspNet.Razor.Test.Generator
// Act & Assert // Act & Assert
RunTagHelperTest(testName: "BasicTagHelpers", RunTagHelperTest(testName: "BasicTagHelpers",
baseLineName: "BasicTagHelpers.CustomAttributeCodeBuilder", baseLineName: "BasicTagHelpers.CustomAttributeCodeGenerator",
tagHelperDescriptors: tagHelperDescriptors, tagHelperDescriptors: tagHelperDescriptors,
hostConfig: (host) => hostConfig: (host) =>
{ {
return new CodeBuilderReplacingHost(host); return new CodeGeneratorReplacingHost(host);
}); });
} }
private class CodeBuilderReplacingHost : CodeGenTestHost private class CodeGeneratorReplacingHost : CodeGenTestHost
{ {
public CodeBuilderReplacingHost(RazorEngineHost originalHost) public CodeGeneratorReplacingHost(RazorEngineHost originalHost)
: base(new CSharpRazorCodeLanguage()) : base(new CSharpRazorCodeLanguage())
{ {
GeneratedClassContext = originalHost.GeneratedClassContext; GeneratedClassContext = originalHost.GeneratedClassContext;
} }
public override CodeBuilder DecorateCodeBuilder(CodeBuilder incomingBuilder, CodeBuilderContext context) public override CodeGenerator DecorateCodeGenerator(CodeGenerator incomingBuilder, CodeGeneratorContext context)
{ {
return new AttributeChunkGeneratorReplacingCodeBuilder(context); return new AttributeChunkGeneratorReplacingCodeGenerator(context);
} }
} }
private class AttributeChunkGeneratorReplacingCodeBuilder : TestCSharpCodeBuilder private class AttributeChunkGeneratorReplacingCodeGenerator : TestCSharpCodeGenerator
{ {
public AttributeChunkGeneratorReplacingCodeBuilder(CodeBuilderContext context) public AttributeChunkGeneratorReplacingCodeGenerator(CodeGeneratorContext context)
: base(context) : base(context)
{ {
} }
protected override CSharpCodeVisitor CreateCSharpCodeVisitor( protected override CSharpCodeVisitor CreateCSharpCodeVisitor(
CSharpCodeWriter writer, CSharpCodeWriter writer,
CodeBuilderContext context) CodeGeneratorContext context)
{ {
var bodyVisitor = base.CreateCSharpCodeVisitor(writer, context); var bodyVisitor = base.CreateCSharpCodeVisitor(writer, context);
@ -88,7 +88,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
public override void RenderAttributeValue( public override void RenderAttributeValue(
TagHelperAttributeDescriptor attributeInfo, TagHelperAttributeDescriptor attributeInfo,
CSharpCodeWriter writer, CSharpCodeWriter writer,
CodeBuilderContext context, CodeGeneratorContext context,
Action<CSharpCodeWriter> renderAttributeValue, Action<CSharpCodeWriter> renderAttributeValue,
bool complexValue) bool complexValue)
{ {

View File

@ -77,9 +77,9 @@ namespace Microsoft.AspNet.Razor.Test.Generator
_tagHelperDescriptors = tagHelperDescriptors; _tagHelperDescriptors = tagHelperDescriptors;
} }
protected internal override CodeBuilder CreateCodeBuilder(CodeBuilderContext context) protected internal override CodeGenerator CreateCodeGenerator(CodeGeneratorContext context)
{ {
return Host.DecorateCodeBuilder(new TestCSharpCodeBuilder(context), context); return Host.DecorateCodeGenerator(new TestCSharpCodeGenerator(context), context);
} }
protected internal override RazorParser CreateParser(string fileName) protected internal override RazorParser CreateParser(string fileName)
@ -92,15 +92,15 @@ namespace Microsoft.AspNet.Razor.Test.Generator
} }
} }
protected class TestCSharpCodeBuilder : CodeGenTestCodeBuilder protected class TestCSharpCodeGenerator : CodeGenTestCodeGenerator
{ {
public TestCSharpCodeBuilder(CodeBuilderContext context) public TestCSharpCodeGenerator(CodeGeneratorContext context)
: base(context) : base(context)
{ {
} }
protected override CSharpCodeVisitor CreateCSharpCodeVisitor(CSharpCodeWriter writer, CodeBuilderContext context) protected override CSharpCodeVisitor CreateCSharpCodeVisitor(CSharpCodeWriter writer, CodeGeneratorContext context)
{ {
var visitor = base.CreateCSharpCodeVisitor(writer, context); var visitor = base.CreateCSharpCodeVisitor(writer, context);
visitor.TagHelperRenderer = new NoUniqueIdsTagHelperCodeRenderer(visitor, writer, context); visitor.TagHelperRenderer = new NoUniqueIdsTagHelperCodeRenderer(visitor, writer, context);
@ -111,7 +111,7 @@ namespace Microsoft.AspNet.Razor.Test.Generator
{ {
public NoUniqueIdsTagHelperCodeRenderer(IChunkVisitor bodyVisitor, public NoUniqueIdsTagHelperCodeRenderer(IChunkVisitor bodyVisitor,
CSharpCodeWriter writer, CSharpCodeWriter writer,
CodeBuilderContext context) CodeGeneratorContext context)
: base(bodyVisitor, writer, context) : base(bodyVisitor, writer, context)
{ {

View File

@ -4,8 +4,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;

View File

@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Linq; using System.Linq;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -1,9 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Chunks.Generators; using Microsoft.AspNet.Razor.Chunks.Generators;
using Microsoft.AspNet.Razor.Editor;
using Microsoft.AspNet.Razor.Parser; using Microsoft.AspNet.Razor.Parser;
using Microsoft.AspNet.Razor.Parser.SyntaxTree; using Microsoft.AspNet.Razor.Parser.SyntaxTree;
using Microsoft.AspNet.Razor.Test.Framework; using Microsoft.AspNet.Razor.Test.Framework;

View File

@ -103,11 +103,11 @@ namespace Microsoft.AspNet.Razor.Test
} }
[Fact] [Fact]
public void CreateCodeBuilder_PassesChunkGeneratorThroughDecorateMethodOnHost() public void CreateCodeGenerator_PassesChunkGeneratorThroughDecorateMethodOnHost()
{ {
// Arrange // Arrange
var mockHost = new Mock<RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true }; var mockHost = new Mock<RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true };
var codeBuilderContext = new CodeBuilderContext( var codeGeneratorContext = new CodeGeneratorContext(
mockHost.Object, mockHost.Object,
"different-class", "different-class",
"different-ns", "different-ns",
@ -115,14 +115,14 @@ namespace Microsoft.AspNet.Razor.Test
shouldGenerateLinePragmas: true, shouldGenerateLinePragmas: true,
errorSink: new ErrorSink()); errorSink: new ErrorSink());
var expected = new CSharpCodeBuilder(codeBuilderContext); var expected = new CSharpCodeGenerator(codeGeneratorContext);
mockHost.Setup(h => h.DecorateCodeBuilder(It.IsAny<CSharpCodeBuilder>(), codeBuilderContext)) mockHost.Setup(h => h.DecorateCodeGenerator(It.IsAny<CSharpCodeGenerator>(), codeGeneratorContext))
.Returns(expected); .Returns(expected);
var engine = new RazorTemplateEngine(mockHost.Object); var engine = new RazorTemplateEngine(mockHost.Object);
// Act // Act
var actual = engine.CreateCodeBuilder(codeBuilderContext); var actual = engine.CreateCodeGenerator(codeGeneratorContext);
// Assert // Assert
Assert.Equal(expected, actual); Assert.Equal(expected, actual);

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Razor.TagHelpers
resolver.Setup(mock => mock.Resolve(It.IsAny<TagHelperDescriptorResolutionContext>())) resolver.Setup(mock => mock.Resolve(It.IsAny<TagHelperDescriptorResolutionContext>()))
.Returns(Enumerable.Empty<TagHelperDescriptor>()); .Returns(Enumerable.Empty<TagHelperDescriptor>());
var tagHelperDirectiveSpanVisitor = new TagHelperDirectiveSpanVisitor( var tagHelperDirectiveSpanVisitor = new TagHelperDirectiveSpanVisitor(
resolver.Object, resolver.Object,
new ErrorSink()); new ErrorSink());
var document = new MarkupBlock( var document = new MarkupBlock(
Factory.Code("\"one\"").AsAddTagHelper("one"), Factory.Code("\"one\"").AsAddTagHelper("one"),
@ -139,8 +139,8 @@ namespace Microsoft.AspNet.Razor.TagHelpers
// Assert // Assert
var directiveDescriptor = Assert.Single(resolver.DirectiveDescriptors); var directiveDescriptor = Assert.Single(resolver.DirectiveDescriptors);
Assert.Equal( Assert.Equal(
expectedDirectiveDescriptor, expectedDirectiveDescriptor,
directiveDescriptor, directiveDescriptor,
TagHelperDirectiveDescriptorComparer.Default); TagHelperDirectiveDescriptorComparer.Default);
} }
@ -255,14 +255,14 @@ namespace Microsoft.AspNet.Razor.TagHelpers
private class CustomTagHelperDirectiveSpanVisitor : TagHelperDirectiveSpanVisitor private class CustomTagHelperDirectiveSpanVisitor : TagHelperDirectiveSpanVisitor
{ {
private Func<IEnumerable<TagHelperDirectiveDescriptor>, private Func<IEnumerable<TagHelperDirectiveDescriptor>,
ErrorSink, ErrorSink,
TagHelperDescriptorResolutionContext> _replacer; TagHelperDescriptorResolutionContext> _replacer;
public CustomTagHelperDirectiveSpanVisitor( public CustomTagHelperDirectiveSpanVisitor(
ITagHelperDescriptorResolver descriptorResolver, ITagHelperDescriptorResolver descriptorResolver,
Func<IEnumerable<TagHelperDirectiveDescriptor>, Func<IEnumerable<TagHelperDirectiveDescriptor>,
ErrorSink, ErrorSink,
TagHelperDescriptorResolutionContext> replacer) TagHelperDescriptorResolutionContext> replacer)
: base(descriptorResolver, new ErrorSink()) : base(descriptorResolver, new ErrorSink())
{ {

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer; using Microsoft.AspNet.Razor.Tokenizer;
using Microsoft.AspNet.Razor.Tokenizer.Symbols; using Microsoft.AspNet.Razor.Tokenizer.Symbols;

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNet.Razor.Text; using Microsoft.AspNet.Razor.Text;
using Microsoft.AspNet.Razor.Tokenizer; using Microsoft.AspNet.Razor.Tokenizer;
using Microsoft.AspNet.Razor.Tokenizer.Symbols; using Microsoft.AspNet.Razor.Tokenizer.Symbols;