[Issue #1318] Renamed RuntimeTarget to CodeTarget
This commit is contained in:
parent
da1296244b
commit
8cf7d248e7
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
|||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
||||
{
|
||||
public interface IInjectDirectiveTargetExtension : IRuntimeTargetExtension
|
||||
public interface IInjectDirectiveTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
void WriteInjectProperty(CSharpRenderingContext context, InjectDirectiveIRNode node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
|||
AcceptExtensionNode<InjectDirectiveIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ using System;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
public abstract class RuntimeTarget
|
||||
public abstract class CodeTarget
|
||||
{
|
||||
public static RuntimeTarget CreateDefault(RazorCodeDocument codeDocument, RazorParserOptions options)
|
||||
public static CodeTarget CreateDefault(RazorCodeDocument codeDocument, RazorParserOptions options)
|
||||
{
|
||||
if (codeDocument == null)
|
||||
{
|
||||
|
|
@ -22,10 +22,10 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
return CreateDefault(codeDocument, options, configure: null);
|
||||
}
|
||||
|
||||
public static RuntimeTarget CreateDefault(
|
||||
public static CodeTarget CreateDefault(
|
||||
RazorCodeDocument codeDocument,
|
||||
RazorParserOptions options,
|
||||
Action<IRuntimeTargetBuilder> configure)
|
||||
Action<ICodeTargetBuilder> configure)
|
||||
{
|
||||
if (codeDocument == null)
|
||||
{
|
||||
|
|
@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var builder = new DefaultRuntimeTargetBuilder(codeDocument, options);
|
||||
var builder = new DefaultCodeTargetBuilder(codeDocument, options);
|
||||
|
||||
if (builder.Options.DesignTimeMode)
|
||||
{
|
||||
|
|
@ -56,10 +56,10 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
return builder.Build();
|
||||
}
|
||||
|
||||
public static RuntimeTarget CreateEmpty(
|
||||
public static CodeTarget CreateEmpty(
|
||||
RazorCodeDocument codeDocument,
|
||||
RazorParserOptions options,
|
||||
Action<IRuntimeTargetBuilder> configure)
|
||||
Action<ICodeTargetBuilder> configure)
|
||||
{
|
||||
if (codeDocument == null)
|
||||
{
|
||||
|
|
@ -71,25 +71,25 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
throw new ArgumentNullException(nameof(options));
|
||||
}
|
||||
|
||||
var builder = new DefaultRuntimeTargetBuilder(codeDocument, options);
|
||||
var builder = new DefaultCodeTargetBuilder(codeDocument, options);
|
||||
configure?.Invoke(builder);
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
internal static void AddDesignTimeDefaults(IRuntimeTargetBuilder builder)
|
||||
internal static void AddDesignTimeDefaults(ICodeTargetBuilder builder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
internal static void AddRuntimeDefaults(IRuntimeTargetBuilder builder)
|
||||
internal static void AddRuntimeDefaults(ICodeTargetBuilder builder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public abstract DocumentWriter CreateWriter(CSharpRenderingContext context);
|
||||
|
||||
public abstract TExtension GetExtension<TExtension>() where TExtension : class, IRuntimeTargetExtension;
|
||||
public abstract TExtension GetExtension<TExtension>() where TExtension : class, ICodeTargetExtension;
|
||||
|
||||
public abstract bool HasExtension<TExtension>() where TExtension : class, IRuntimeTargetExtension;
|
||||
public abstract bool HasExtension<TExtension>() where TExtension : class, ICodeTargetExtension;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,17 +7,17 @@ using System.Linq;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
internal class DefaultRuntimeTarget : RuntimeTarget
|
||||
internal class DefaultCodeTarget : CodeTarget
|
||||
{
|
||||
private readonly RazorParserOptions _options;
|
||||
|
||||
public DefaultRuntimeTarget(RazorParserOptions options, IEnumerable<IRuntimeTargetExtension> extensions)
|
||||
public DefaultCodeTarget(RazorParserOptions options, IEnumerable<ICodeTargetExtension> extensions)
|
||||
{
|
||||
_options = options;
|
||||
Extensions = extensions.ToArray();
|
||||
}
|
||||
|
||||
public IRuntimeTargetExtension[] Extensions { get; }
|
||||
public ICodeTargetExtension[] Extensions { get; }
|
||||
|
||||
public override DocumentWriter CreateWriter(CSharpRenderingContext context)
|
||||
{
|
||||
|
|
@ -6,25 +6,25 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
internal class DefaultRuntimeTargetBuilder : IRuntimeTargetBuilder
|
||||
internal class DefaultCodeTargetBuilder : ICodeTargetBuilder
|
||||
{
|
||||
public DefaultRuntimeTargetBuilder(RazorCodeDocument codeDocument, RazorParserOptions options)
|
||||
public DefaultCodeTargetBuilder(RazorCodeDocument codeDocument, RazorParserOptions options)
|
||||
{
|
||||
CodeDocument = codeDocument;
|
||||
Options = options;
|
||||
|
||||
TargetExtensions = new List<IRuntimeTargetExtension>();
|
||||
TargetExtensions = new List<ICodeTargetExtension>();
|
||||
}
|
||||
|
||||
public RazorCodeDocument CodeDocument { get; }
|
||||
|
||||
public RazorParserOptions Options { get; }
|
||||
|
||||
public ICollection<IRuntimeTargetExtension> TargetExtensions { get; }
|
||||
public ICollection<ICodeTargetExtension> TargetExtensions { get; }
|
||||
|
||||
public RuntimeTarget Build()
|
||||
public CodeTarget Build()
|
||||
{
|
||||
return new DefaultRuntimeTarget(Options, TargetExtensions);
|
||||
return new DefaultCodeTarget(Options, TargetExtensions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,9 +9,9 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
internal class DefaultDocumentWriter : DocumentWriter
|
||||
{
|
||||
private readonly CSharpRenderingContext _context;
|
||||
private readonly RuntimeTarget _target;
|
||||
private readonly CodeTarget _target;
|
||||
|
||||
public DefaultDocumentWriter(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public DefaultDocumentWriter(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
|
|
@ -48,9 +48,9 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
private class Visitor : RazorIRNodeVisitor
|
||||
{
|
||||
private readonly CSharpRenderingContext _context;
|
||||
private readonly RuntimeTarget _target;
|
||||
private readonly CodeTarget _target;
|
||||
|
||||
public Visitor(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public Visitor(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
_target = target;
|
||||
_context = context;
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
public interface IRuntimeTargetBuilder
|
||||
public interface ICodeTargetBuilder
|
||||
{
|
||||
RazorCodeDocument CodeDocument { get; }
|
||||
|
||||
RazorParserOptions Options { get; }
|
||||
|
||||
ICollection<IRuntimeTargetExtension> TargetExtensions { get; }
|
||||
ICollection<ICodeTargetExtension> TargetExtensions { get; }
|
||||
|
||||
RuntimeTarget Build();
|
||||
CodeTarget Build();
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
public interface IRuntimeTargetExtension
|
||||
public interface ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
internal interface IDesignTimeDirectiveTargetExtension : IRuntimeTargetExtension
|
||||
internal interface IDesignTimeDirectiveTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
void WriteDesignTimeDirective(CSharpRenderingContext context, DesignTimeDirectiveIRNode node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
internal interface IPreallocatedAttributeTargetExtension : IRuntimeTargetExtension
|
||||
internal interface IPreallocatedAttributeTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
void WriteDeclarePreallocatedTagHelperHtmlAttribute(CSharpRenderingContext context, DeclarePreallocatedTagHelperHtmlAttributeIRNode node);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
internal interface ITemplateTargetExtension : IRuntimeTargetExtension
|
||||
internal interface ITemplateTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
void WriteTemplate(CSharpRenderingContext context, TemplateIRNode node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
var message = Resources.FormatDocumentMissingTarget(
|
||||
irDocument.DocumentKind,
|
||||
nameof(RuntimeTarget),
|
||||
nameof(CodeTarget),
|
||||
nameof(DocumentIRNode.Target));
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
public RazorEngine Engine { get; set; }
|
||||
|
||||
public ICollection<IRuntimeTargetExtension> TargetExtensions { get; } = new List<IRuntimeTargetExtension>();
|
||||
public ICollection<ICodeTargetExtension> TargetExtensions { get; } = new List<ICodeTargetExtension>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
public abstract class DocumentClassifierPassBase : RazorIRPassBase, IRazorDocumentClassifierPass
|
||||
{
|
||||
private static readonly IRuntimeTargetExtension[] EmptyExtensionArray = new IRuntimeTargetExtension[0];
|
||||
private static readonly ICodeTargetExtension[] EmptyExtensionArray = new ICodeTargetExtension[0];
|
||||
|
||||
protected abstract string DocumentKind { get; }
|
||||
|
||||
protected IRuntimeTargetExtension[] TargetExtensions { get; private set; }
|
||||
protected ICodeTargetExtension[] TargetExtensions { get; private set; }
|
||||
|
||||
protected override void OnIntialized()
|
||||
{
|
||||
|
|
@ -82,9 +82,9 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
protected abstract bool IsMatch(RazorCodeDocument codeDocument, DocumentIRNode irDocument);
|
||||
|
||||
private RuntimeTarget CreateTarget(RazorCodeDocument codeDocument, RazorParserOptions options)
|
||||
private CodeTarget CreateTarget(RazorCodeDocument codeDocument, RazorParserOptions options)
|
||||
{
|
||||
return RuntimeTarget.CreateDefault(codeDocument, options, (builder) =>
|
||||
return CodeTarget.CreateDefault(codeDocument, options, (builder) =>
|
||||
{
|
||||
for (var i = 0; i < TargetExtensions.Length; i++)
|
||||
{
|
||||
|
|
@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
});
|
||||
}
|
||||
|
||||
protected virtual void ConfigureTarget(IRuntimeTargetBuilder builder)
|
||||
protected virtual void ConfigureTarget(ICodeTargetBuilder builder)
|
||||
{
|
||||
// Intentionally empty.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
{
|
||||
public interface IRazorTargetExtensionFeature : IRazorEngineFeature
|
||||
{
|
||||
ICollection<IRuntimeTargetExtension> TargetExtensions { get; }
|
||||
ICollection<ICodeTargetExtension> TargetExtensions { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<AddPreallocatedTagHelperHtmlAttributeIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
|
||||
extension.WriteAddPreallocatedTagHelperHtmlAttribute(context, this);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<DeclarePreallocatedTagHelperAttributeIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
|
||||
extension.WriteDeclarePreallocatedTagHelperAttribute(context, this);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<DeclarePreallocatedTagHelperHtmlAttributeIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
|
||||
extension.WriteDeclarePreallocatedTagHelperHtmlAttribute(context, this);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<DesignTimeDirectiveIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
var extension = target.GetExtension<IDesignTimeDirectiveTargetExtension>();
|
||||
extension.WriteDesignTimeDirective(context, this);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
|
||||
public override SourceSpan? Source { get; set; }
|
||||
|
||||
public RuntimeTarget Target { get; set; }
|
||||
public CodeTarget Target { get; set; }
|
||||
|
||||
public override void Accept(RazorIRNodeVisitor visitor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
}
|
||||
}
|
||||
|
||||
public abstract void WriteNode(RuntimeTarget target, CSharpRenderingContext context);
|
||||
public abstract void WriteNode(CodeTarget target, CSharpRenderingContext context);
|
||||
|
||||
protected static void AcceptExtensionNode<TNode>(TNode node, RazorIRNodeVisitor visitor)
|
||||
where TNode : ExtensionIRNode
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<SetPreallocatedTagHelperPropertyIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
var extension = target.GetExtension<IPreallocatedAttributeTargetExtension>();
|
||||
extension.WriteSetPreallocatedTagHelperProperty(context, this);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<TemplateIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
var extension = target.GetExtension<ITemplateTargetExtension>();
|
||||
extension.WriteTemplate(context, this);
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified <see cref="IRuntimeTargetExtension"/>.
|
||||
/// Adds the specified <see cref="ICodeTargetExtension"/>.
|
||||
/// </summary>
|
||||
/// <param name="builder">The <see cref="IRazorEngineBuilder"/>.</param>
|
||||
/// <param name="extension">The <see cref="IRuntimeTargetExtension"/> to add.</param>
|
||||
/// <param name="extension">The <see cref="ICodeTargetExtension"/> to add.</param>
|
||||
/// <returns>The <see cref="IRazorEngineBuilder"/>.</returns>
|
||||
public static IRazorEngineBuilder AddTargetExtension(this IRazorEngineBuilder builder, IRuntimeTargetExtension extension)
|
||||
public static IRazorEngineBuilder AddTargetExtension(this IRazorEngineBuilder builder, ICodeTargetExtension extension)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,20 +6,20 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
public class RuntimeTargetTest
|
||||
public class CodeTargetTest
|
||||
{
|
||||
[Fact]
|
||||
public void CreateDefault_CreatesDefaultRuntimeTarget()
|
||||
public void CreateDefault_CreatesDefaultCodeTarget()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
// Act
|
||||
var target = RuntimeTarget.CreateDefault(codeDocument, options);
|
||||
var target = CodeTarget.CreateDefault(codeDocument, options);
|
||||
|
||||
// Assert
|
||||
Assert.IsType<DefaultRuntimeTarget>(target);
|
||||
Assert.IsType<DefaultCodeTarget>(target);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -27,13 +27,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
{
|
||||
// Arrange
|
||||
var wasCalled = false;
|
||||
Action<IRuntimeTargetBuilder> @delegate = (b) => { wasCalled = true; };
|
||||
Action<ICodeTargetBuilder> @delegate = (b) => { wasCalled = true; };
|
||||
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
// Act
|
||||
RuntimeTarget.CreateDefault(codeDocument, options, @delegate);
|
||||
CodeTarget.CreateDefault(codeDocument, options, @delegate);
|
||||
|
||||
// Assert
|
||||
Assert.True(wasCalled);
|
||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
// Act
|
||||
RuntimeTarget.CreateDefault(codeDocument, options, configure: null);
|
||||
CodeTarget.CreateDefault(codeDocument, options, configure: null);
|
||||
|
||||
// Assert (does not throw)
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
// Act
|
||||
RuntimeTarget.CreateDefault(codeDocument, options, configure: null);
|
||||
CodeTarget.CreateDefault(codeDocument, options, configure: null);
|
||||
|
||||
// Assert (does not throw)
|
||||
}
|
||||
|
|
@ -5,18 +5,18 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
public class DefaultRuntimeTargetBuilderTest
|
||||
public class DefaultCodeTargetBuilderTest
|
||||
{
|
||||
[Fact]
|
||||
public void Build_CreatesDefaultRuntimeTarget()
|
||||
public void Build_CreatesDefaultCodeTarget()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var builder = new DefaultRuntimeTargetBuilder(codeDocument, options);
|
||||
var builder = new DefaultCodeTargetBuilder(codeDocument, options);
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension1(),
|
||||
new MyExtension2(),
|
||||
|
|
@ -31,15 +31,15 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
var result = builder.Build();
|
||||
|
||||
// Assert
|
||||
var target = Assert.IsType<DefaultRuntimeTarget>(result);
|
||||
var target = Assert.IsType<DefaultCodeTarget>(result);
|
||||
Assert.Equal(extensions, target.Extensions);
|
||||
}
|
||||
|
||||
private class MyExtension1 : IRuntimeTargetExtension
|
||||
private class MyExtension1 : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
|
||||
private class MyExtension2 : IRuntimeTargetExtension
|
||||
private class MyExtension2 : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using Xunit;
|
|||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
||||
{
|
||||
public class DefaultRuntimeTargetTest
|
||||
public class DefaultCodeTargetTest
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_CreatesDefensiveCopy()
|
||||
|
|
@ -14,14 +14,14 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension2(),
|
||||
new MyExtension1(),
|
||||
};
|
||||
|
||||
// Act
|
||||
var target = new DefaultRuntimeTarget(options, extensions);
|
||||
var target = new DefaultCodeTarget(options, extensions);
|
||||
|
||||
// Assert
|
||||
Assert.NotSame(extensions, target);
|
||||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var target = new DefaultRuntimeTarget(options, Enumerable.Empty<IRuntimeTargetExtension>());
|
||||
var target = new DefaultCodeTarget(options, Enumerable.Empty<ICodeTargetExtension>());
|
||||
|
||||
// Act
|
||||
var writer = target.CreateWriter(new CSharpRenderingContext());
|
||||
|
|
@ -48,13 +48,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension2(),
|
||||
new MyExtension1(),
|
||||
};
|
||||
|
||||
var target = new DefaultRuntimeTarget(options, extensions);
|
||||
var target = new DefaultCodeTarget(options, extensions);
|
||||
|
||||
// Act
|
||||
var result = target.HasExtension<MyExtension1>();
|
||||
|
|
@ -69,13 +69,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension2(),
|
||||
new MyExtension2(),
|
||||
};
|
||||
|
||||
var target = new DefaultRuntimeTarget(options, extensions);
|
||||
var target = new DefaultCodeTarget(options, extensions);
|
||||
|
||||
// Act
|
||||
var result = target.HasExtension<MyExtension1>();
|
||||
|
|
@ -90,13 +90,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension2(),
|
||||
new MyExtension1(),
|
||||
};
|
||||
|
||||
var target = new DefaultRuntimeTarget(options, extensions);
|
||||
var target = new DefaultCodeTarget(options, extensions);
|
||||
|
||||
// Act
|
||||
var result = target.GetExtension<MyExtension1>();
|
||||
|
|
@ -111,7 +111,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension2(),
|
||||
new MyExtension1(),
|
||||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
new MyExtension1(),
|
||||
};
|
||||
|
||||
var target = new DefaultRuntimeTarget(options, extensions);
|
||||
var target = new DefaultCodeTarget(options, extensions);
|
||||
|
||||
// Act
|
||||
var result = target.GetExtension<MyExtension1>();
|
||||
|
|
@ -135,13 +135,13 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
// Arrange
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var extensions = new IRuntimeTargetExtension[]
|
||||
var extensions = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension2(),
|
||||
new MyExtension2(),
|
||||
};
|
||||
|
||||
var target = new DefaultRuntimeTarget(options, extensions);
|
||||
var target = new DefaultCodeTarget(options, extensions);
|
||||
|
||||
// Act
|
||||
var result = target.GetExtension<MyExtension1>();
|
||||
|
|
@ -150,11 +150,11 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
Assert.Null(result);
|
||||
}
|
||||
|
||||
private class MyExtension1 : IRuntimeTargetExtension
|
||||
private class MyExtension1 : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
|
||||
private class MyExtension2 : IRuntimeTargetExtension
|
||||
private class MyExtension2 : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var target = RuntimeTarget.CreateDefault(codeDocument, options);
|
||||
var target = CodeTarget.CreateDefault(codeDocument, options);
|
||||
var context = new CSharpRenderingContext()
|
||||
{
|
||||
Options = options,
|
||||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var target = RuntimeTarget.CreateDefault(codeDocument, options);
|
||||
var target = CodeTarget.CreateDefault(codeDocument, options);
|
||||
var context = new CSharpRenderingContext()
|
||||
{
|
||||
Options = options,
|
||||
|
|
@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
|
|||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var target = RuntimeTarget.CreateDefault(codeDocument, options);
|
||||
var target = CodeTarget.CreateDefault(codeDocument, options);
|
||||
var context = new CSharpRenderingContext()
|
||||
{
|
||||
Options = options,
|
||||
|
|
@ -137,7 +137,7 @@ internal virtual async string TestMethod()
|
|||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var target = RuntimeTarget.CreateDefault(codeDocument, options);
|
||||
var target = CodeTarget.CreateDefault(codeDocument, options);
|
||||
var context = new CSharpRenderingContext()
|
||||
{
|
||||
Options = options,
|
||||
|
|
@ -175,7 +175,7 @@ internal virtual async string TestMethod()
|
|||
var codeDocument = TestRazorCodeDocument.CreateEmpty();
|
||||
var options = RazorParserOptions.CreateDefaultOptions();
|
||||
|
||||
var target = RuntimeTarget.CreateDefault(codeDocument, options);
|
||||
var target = CodeTarget.CreateDefault(codeDocument, options);
|
||||
var context = new CSharpRenderingContext()
|
||||
{
|
||||
Options = options,
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ if (true) { }
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -655,7 +655,7 @@ WriteAttributeValue("" "", 27, false, 28, 6, false);
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Execute_ThrowsForMissingDependency_RuntimeTarget()
|
||||
public void Execute_ThrowsForMissingDependency_CodeTarget()
|
||||
{
|
||||
// Arrange
|
||||
var phase = new DefaultRazorCSharpLoweringPhase();
|
||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
// Act & Assert
|
||||
ExceptionAssert.Throws<InvalidOperationException>(
|
||||
() => phase.Execute(codeDocument),
|
||||
$"The document of kind 'test' does not have a '{nameof(RuntimeTarget)}'. " +
|
||||
$"The document of kind 'test' does not have a '{nameof(CodeTarget)}'. " +
|
||||
$"The document classifier must set a value for '{nameof(DocumentIRNode.Target)}'.");
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
var irDocument = new DocumentIRNode()
|
||||
{
|
||||
DocumentKind = "test",
|
||||
Target = RuntimeTarget.CreateDefault(codeDocument, options),
|
||||
Target = CodeTarget.CreateDefault(codeDocument, options),
|
||||
Options = options,
|
||||
};
|
||||
codeDocument.SetIRDocument(irDocument);
|
||||
|
|
@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
var irDocument = new DocumentIRNode()
|
||||
{
|
||||
DocumentKind = "test",
|
||||
Target = RuntimeTarget.CreateDefault(codeDocument, options),
|
||||
Target = CodeTarget.CreateDefault(codeDocument, options),
|
||||
Options = options,
|
||||
};
|
||||
codeDocument.SetIRDocument(irDocument);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
Options = RazorParserOptions.CreateDefaultOptions(),
|
||||
};
|
||||
|
||||
var expected = new IRuntimeTargetExtension[]
|
||||
var expected = new ICodeTargetExtension[]
|
||||
{
|
||||
new MyExtension1(),
|
||||
new MyExtension2(),
|
||||
|
|
@ -81,9 +81,9 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
}
|
||||
});
|
||||
|
||||
IRuntimeTargetExtension[] extensions = null;
|
||||
ICodeTargetExtension[] extensions = null;
|
||||
|
||||
pass.RuntimeTargetCallback = (builder) => extensions = builder.TargetExtensions.ToArray();
|
||||
pass.CodeTargetCallback = (builder) => extensions = builder.TargetExtensions.ToArray();
|
||||
|
||||
// Act
|
||||
pass.Execute(TestRazorCodeDocument.CreateEmpty(), irDocument);
|
||||
|
|
@ -300,7 +300,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
|
||||
public bool ShouldMatch { get; set; } = true;
|
||||
|
||||
public Action<IRuntimeTargetBuilder> RuntimeTargetCallback { get; set; }
|
||||
public Action<ICodeTargetBuilder> CodeTargetCallback { get; set; }
|
||||
|
||||
public string Namespace { get; set; }
|
||||
|
||||
|
|
@ -326,17 +326,17 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
@method.Name = Method;
|
||||
}
|
||||
|
||||
protected override void ConfigureTarget(IRuntimeTargetBuilder builder)
|
||||
protected override void ConfigureTarget(ICodeTargetBuilder builder)
|
||||
{
|
||||
RuntimeTargetCallback?.Invoke(builder);
|
||||
CodeTargetCallback?.Invoke(builder);
|
||||
}
|
||||
}
|
||||
|
||||
private class MyExtension1 : IRuntimeTargetExtension
|
||||
private class MyExtension1 : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
|
||||
private class MyExtension2 : IRuntimeTargetExtension
|
||||
private class MyExtension2 : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
|
|||
AcceptExtensionNode<TestExtensionIRNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(RuntimeTarget target, CSharpRenderingContext context)
|
||||
public override void WriteNode(CodeTarget target, CSharpRenderingContext context)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Razor.Language
|
|||
Assert.Same(extension, Assert.Single(actual.TargetExtensions));
|
||||
}
|
||||
|
||||
private class MyTargetExtension : IRuntimeTargetExtension
|
||||
private class MyTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue