Merge branch 'master' of ..\AspNetCore-Tooling\ into johluo/tooling-soncolidation-source-2
This commit is contained in:
commit
c565c2a4f1
|
|
@ -0,0 +1,76 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal static class CSharpIdentifier
|
||||
{
|
||||
private const string CshtmlExtension = ".cshtml";
|
||||
|
||||
public static string GetClassNameFromPath(string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
if (path.EndsWith(CshtmlExtension, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
path = path.Substring(0, path.Length - CshtmlExtension.Length);
|
||||
}
|
||||
|
||||
return SanitizeClassName(path);
|
||||
}
|
||||
|
||||
// CSharp Spec §2.4.2
|
||||
private static bool IsIdentifierStart(char character)
|
||||
{
|
||||
return char.IsLetter(character) ||
|
||||
character == '_' ||
|
||||
CharUnicodeInfo.GetUnicodeCategory(character) == UnicodeCategory.LetterNumber;
|
||||
}
|
||||
|
||||
public static bool IsIdentifierPart(char character)
|
||||
{
|
||||
return char.IsDigit(character) ||
|
||||
IsIdentifierStart(character) ||
|
||||
IsIdentifierPartByUnicodeCategory(character);
|
||||
}
|
||||
|
||||
private static bool IsIdentifierPartByUnicodeCategory(char character)
|
||||
{
|
||||
var category = CharUnicodeInfo.GetUnicodeCategory(character);
|
||||
|
||||
return category == UnicodeCategory.NonSpacingMark || // Mn
|
||||
category == UnicodeCategory.SpacingCombiningMark || // Mc
|
||||
category == UnicodeCategory.ConnectorPunctuation || // Pc
|
||||
category == UnicodeCategory.Format; // Cf
|
||||
}
|
||||
|
||||
public static string SanitizeClassName(string inputName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputName))
|
||||
{
|
||||
return inputName;
|
||||
}
|
||||
|
||||
if (!IsIdentifierStart(inputName[0]) && IsIdentifierPart(inputName[0]))
|
||||
{
|
||||
inputName = "_" + inputName;
|
||||
}
|
||||
|
||||
var builder = new StringBuilder(inputName.Length);
|
||||
for (var i = 0; i < inputName.Length; i++)
|
||||
{
|
||||
var ch = inputName[i];
|
||||
builder.Append(IsIdentifierPart(ch) ? ch : '_');
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal class ExtensionInitializer : RazorExtensionInitializer
|
||||
{
|
||||
public override void Initialize(RazorProjectEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
if (builder.Configuration.ConfigurationName == "MVC-1.0")
|
||||
{
|
||||
RazorExtensions.Register(builder);
|
||||
}
|
||||
else if (builder.Configuration.ConfigurationName == "MVC-1.1")
|
||||
{
|
||||
RazorExtensions.Register(builder);
|
||||
RazorExtensions.RegisterViewComponentTagHelpers(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public interface IInjectTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
void WriteInjectProperty(CodeRenderingContext context, InjectIntermediateNode node);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public interface IViewComponentTagHelperTargetExtension : ICodeTargetExtension
|
||||
{
|
||||
void WriteViewComponentTagHelper(CodeRenderingContext context, ViewComponentTagHelperIntermediateNode node);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class InjectDirective
|
||||
{
|
||||
public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective(
|
||||
"inject",
|
||||
DirectiveKind.SingleLine,
|
||||
builder =>
|
||||
{
|
||||
builder
|
||||
.AddTypeToken(Resources.InjectDirective_TypeToken_Name, Resources.InjectDirective_TypeToken_Description)
|
||||
.AddMemberToken(Resources.InjectDirective_MemberToken_Name, Resources.InjectDirective_MemberToken_Description);
|
||||
|
||||
builder.Usage = DirectiveUsage.FileScopedMultipleOccurring;
|
||||
builder.Description = Resources.InjectDirective_Description;
|
||||
});
|
||||
|
||||
public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
builder.AddDirective(Directive);
|
||||
builder.Features.Add(new Pass());
|
||||
builder.AddTargetExtension(new InjectTargetExtension());
|
||||
return builder;
|
||||
}
|
||||
|
||||
internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass
|
||||
{
|
||||
// Runs after the @model and @namespace directives
|
||||
public override int Order => 10;
|
||||
|
||||
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
|
||||
{
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(documentNode);
|
||||
var modelType = ModelDirective.GetModelType(documentNode);
|
||||
|
||||
var properties = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
for (var i = visitor.Directives.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var directive = visitor.Directives[i];
|
||||
var tokens = directive.Tokens.ToArray();
|
||||
if (tokens.Length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var typeName = tokens[0].Content;
|
||||
var memberName = tokens[1].Content;
|
||||
|
||||
if (!properties.Add(memberName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
typeName = typeName.Replace("<TModel>", "<" + modelType + ">");
|
||||
|
||||
var injectNode = new InjectIntermediateNode()
|
||||
{
|
||||
TypeName = typeName,
|
||||
MemberName = memberName,
|
||||
};
|
||||
|
||||
visitor.Class.Children.Add(injectNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class Visitor : IntermediateNodeWalker
|
||||
{
|
||||
public ClassDeclarationIntermediateNode Class { get; private set; }
|
||||
|
||||
public IList<DirectiveIntermediateNode> Directives { get; } = new List<DirectiveIntermediateNode>();
|
||||
|
||||
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
|
||||
{
|
||||
if (Class == null)
|
||||
{
|
||||
Class = node;
|
||||
}
|
||||
|
||||
base.VisitClassDeclaration(node);
|
||||
}
|
||||
|
||||
public override void VisitDirective(DirectiveIntermediateNode node)
|
||||
{
|
||||
if (node.Directive == Directive)
|
||||
{
|
||||
Directives.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Obsolete
|
||||
[Obsolete("This method is obsolete and will be removed in a future version.")]
|
||||
public static IRazorEngineBuilder Register(IRazorEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
builder.AddDirective(Directive);
|
||||
builder.Features.Add(new Pass());
|
||||
builder.AddTargetExtension(new InjectTargetExtension());
|
||||
return builder;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class InjectIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public string TypeName { get; set; }
|
||||
|
||||
public string MemberName { get; set; }
|
||||
|
||||
public override IntermediateNodeCollection Children => IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
if (visitor == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(visitor));
|
||||
}
|
||||
|
||||
AcceptExtensionNode<InjectIntermediateNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(CodeTarget target, CodeRenderingContext context)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
var extension = target.GetExtension<IInjectTargetExtension>();
|
||||
if (extension == null)
|
||||
{
|
||||
ReportMissingCodeTargetExtension<IInjectTargetExtension>(context);
|
||||
return;
|
||||
}
|
||||
|
||||
extension.WriteInjectProperty(context, this);
|
||||
}
|
||||
|
||||
public override void FormatNode(IntermediateNodeFormatter formatter)
|
||||
{
|
||||
formatter.WriteContent(MemberName);
|
||||
|
||||
formatter.WriteProperty(nameof(MemberName), MemberName);
|
||||
formatter.WriteProperty(nameof(TypeName), TypeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class InjectTargetExtension : IInjectTargetExtension
|
||||
{
|
||||
private const string RazorInjectAttribute = "[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]";
|
||||
|
||||
public void WriteInjectProperty(CodeRenderingContext context, InjectIntermediateNode node)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
if (node == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(node));
|
||||
}
|
||||
|
||||
var property = $"public {node.TypeName} {node.MemberName} {{ get; private set; }}";
|
||||
|
||||
if (node.Source.HasValue)
|
||||
{
|
||||
using (context.CodeWriter.BuildLinePragma(node.Source.Value, context))
|
||||
{
|
||||
context.CodeWriter
|
||||
.WriteLine(RazorInjectAttribute)
|
||||
.WriteLine(property);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.CodeWriter
|
||||
.WriteLine(RazorInjectAttribute)
|
||||
.WriteLine(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
||||
{
|
||||
internal class LegacySectionTargetExtension : ISectionTargetExtension
|
||||
{
|
||||
private static readonly string DefaultWriterName = "__razor_section_writer";
|
||||
|
||||
public static readonly string DefaultSectionMethodName = "DefineSection";
|
||||
|
||||
public string SectionMethodName { get; set; } = DefaultSectionMethodName;
|
||||
|
||||
public void WriteSection(CodeRenderingContext context, SectionIntermediateNode node)
|
||||
{
|
||||
context.CodeWriter
|
||||
.WriteStartMethodInvocation(SectionMethodName)
|
||||
.Write("\"")
|
||||
.Write(node.SectionName)
|
||||
.Write("\", ");
|
||||
|
||||
using (context.CodeWriter.BuildAsyncLambda(DefaultWriterName))
|
||||
{
|
||||
context.RenderChildren(node);
|
||||
}
|
||||
|
||||
context.CodeWriter.WriteEndMethodInvocation(endLine: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core design time hosting infrastructure for the Razor view engine.</Description>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PackageTags>$(PackageTags);aspnetcoremvc</PackageTags>
|
||||
<EnableApiCheck>false</EnableApiCheck>
|
||||
<IsShipping>false</IsShipping>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Microsoft.AspNetCore.Razor.Language\CodeGeneration\CodeWriterExtensions.cs">
|
||||
<Link>Shared\CodeWriterExtensions.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../Microsoft.AspNetCore.Razor.Language/Microsoft.AspNetCore.Razor.Language.csproj" />
|
||||
<ProjectReference Include="../Microsoft.CodeAnalysis.Razor/Microsoft.CodeAnalysis.Razor.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class ModelDirective
|
||||
{
|
||||
public static readonly DirectiveDescriptor Directive = DirectiveDescriptor.CreateDirective(
|
||||
"model",
|
||||
DirectiveKind.SingleLine,
|
||||
builder =>
|
||||
{
|
||||
builder.AddTypeToken(Resources.ModelDirective_TypeToken_Name, Resources.ModelDirective_TypeToken_Description);
|
||||
builder.Usage = DirectiveUsage.FileScopedSinglyOccurring;
|
||||
builder.Description = Resources.ModelDirective_Description;
|
||||
});
|
||||
|
||||
public static RazorProjectEngineBuilder Register(RazorProjectEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
builder.AddDirective(Directive);
|
||||
builder.Features.Add(new Pass());
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static string GetModelType(DocumentIntermediateNode document)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(document));
|
||||
}
|
||||
|
||||
var visitor = new Visitor();
|
||||
return GetModelType(document, visitor);
|
||||
}
|
||||
|
||||
private static string GetModelType(DocumentIntermediateNode document, Visitor visitor)
|
||||
{
|
||||
visitor.Visit(document);
|
||||
|
||||
for (var i = visitor.ModelDirectives.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var directive = visitor.ModelDirectives[i];
|
||||
|
||||
var tokens = directive.Tokens.ToArray();
|
||||
if (tokens.Length >= 1)
|
||||
{
|
||||
return tokens[0].Content;
|
||||
}
|
||||
}
|
||||
|
||||
return "dynamic";
|
||||
}
|
||||
|
||||
internal class Pass : IntermediateNodePassBase, IRazorDirectiveClassifierPass
|
||||
{
|
||||
// Runs after the @inherits directive
|
||||
public override int Order => 5;
|
||||
|
||||
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
|
||||
{
|
||||
var visitor = new Visitor();
|
||||
var modelType = GetModelType(documentNode, visitor);
|
||||
|
||||
if (documentNode.Options.DesignTime)
|
||||
{
|
||||
// Alias the TModel token to a known type.
|
||||
// This allows design time compilation to succeed for Razor files where the token isn't replaced.
|
||||
var typeName = $"global::{typeof(object).FullName}";
|
||||
var usingNode = new UsingDirectiveIntermediateNode()
|
||||
{
|
||||
Content = $"TModel = {typeName}"
|
||||
};
|
||||
|
||||
visitor.Namespace?.Children.Insert(0, usingNode);
|
||||
}
|
||||
|
||||
var baseType = visitor.Class?.BaseType?.Replace("<TModel>", "<" + modelType + ">");
|
||||
visitor.Class.BaseType = baseType;
|
||||
}
|
||||
}
|
||||
|
||||
private class Visitor : IntermediateNodeWalker
|
||||
{
|
||||
public NamespaceDeclarationIntermediateNode Namespace { get; private set; }
|
||||
|
||||
public ClassDeclarationIntermediateNode Class { get; private set; }
|
||||
|
||||
public IList<DirectiveIntermediateNode> ModelDirectives { get; } = new List<DirectiveIntermediateNode>();
|
||||
|
||||
public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node)
|
||||
{
|
||||
if (Namespace == null)
|
||||
{
|
||||
Namespace = node;
|
||||
}
|
||||
|
||||
base.VisitNamespaceDeclaration(node);
|
||||
}
|
||||
|
||||
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
|
||||
{
|
||||
if (Class == null)
|
||||
{
|
||||
Class = node;
|
||||
}
|
||||
|
||||
base.VisitClassDeclaration(node);
|
||||
}
|
||||
|
||||
public override void VisitDirective(DirectiveIntermediateNode node)
|
||||
{
|
||||
if (node.Directive == Directive)
|
||||
{
|
||||
ModelDirectives.Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Obsolete
|
||||
[Obsolete("This method is obsolete and will be removed in a future version.")]
|
||||
public static IRazorEngineBuilder Register(IRazorEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
builder.AddDirective(Directive);
|
||||
builder.Features.Add(new Pass());
|
||||
return builder;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class ModelExpressionPass : IntermediateNodePassBase, IRazorOptimizationPass
|
||||
{
|
||||
private const string ModelExpressionTypeName = "Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression";
|
||||
|
||||
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
|
||||
{
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(documentNode);
|
||||
}
|
||||
|
||||
private class Visitor : IntermediateNodeWalker
|
||||
{
|
||||
public List<TagHelperIntermediateNode> TagHelpers { get; } = new List<TagHelperIntermediateNode>();
|
||||
|
||||
public override void VisitTagHelperProperty(TagHelperPropertyIntermediateNode node)
|
||||
{
|
||||
if (string.Equals(node.BoundAttribute.TypeName, ModelExpressionTypeName, StringComparison.Ordinal) ||
|
||||
(node.IsIndexerNameMatch &&
|
||||
string.Equals(node.BoundAttribute.IndexerTypeName, ModelExpressionTypeName, StringComparison.Ordinal)))
|
||||
{
|
||||
var expression = new CSharpExpressionIntermediateNode();
|
||||
|
||||
expression.Children.Add(new IntermediateToken()
|
||||
{
|
||||
Kind = TokenKind.CSharp,
|
||||
Content = "ModelExpressionProvider.CreateModelExpression(ViewData, __model => ",
|
||||
});
|
||||
|
||||
if (node.Children.Count == 1 && node.Children[0] is IntermediateToken token && token.IsCSharp)
|
||||
{
|
||||
// A 'simple' expression will look like __model => __model.Foo
|
||||
|
||||
expression.Children.Add(new IntermediateToken()
|
||||
{
|
||||
Kind = TokenKind.CSharp,
|
||||
Content = "__model."
|
||||
});
|
||||
|
||||
expression.Children.Add(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
if (node.Children[i] is CSharpExpressionIntermediateNode nestedExpression)
|
||||
{
|
||||
for (var j = 0; j < nestedExpression.Children.Count; j++)
|
||||
{
|
||||
if (nestedExpression.Children[j] is IntermediateToken cSharpToken &&
|
||||
cSharpToken.IsCSharp)
|
||||
{
|
||||
expression.Children.Add(cSharpToken);
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expression.Children.Add(new IntermediateToken()
|
||||
{
|
||||
Kind = TokenKind.CSharp,
|
||||
Content = ")",
|
||||
});
|
||||
|
||||
node.Children.Clear();
|
||||
|
||||
node.Children.Add(expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal class MvcImportProjectFeature : RazorProjectEngineFeatureBase, IImportProjectFeature
|
||||
{
|
||||
private const string ImportsFileName = "_ViewImports.cshtml";
|
||||
|
||||
public IReadOnlyList<RazorProjectItem> GetImports(RazorProjectItem projectItem)
|
||||
{
|
||||
if (projectItem == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(projectItem));
|
||||
}
|
||||
|
||||
// Don't add MVC imports for a component - this shouldn't happen for v1, but just in case.
|
||||
if (FileKinds.IsComponent(projectItem.FileKind))
|
||||
{
|
||||
return Array.Empty<RazorProjectItem>();
|
||||
}
|
||||
|
||||
var imports = new List<RazorProjectItem>();
|
||||
AddDefaultDirectivesImport(imports);
|
||||
|
||||
// We add hierarchical imports second so any default directive imports can be overridden.
|
||||
AddHierarchicalImports(projectItem, imports);
|
||||
|
||||
return imports;
|
||||
}
|
||||
|
||||
// Internal for testing
|
||||
internal static void AddDefaultDirectivesImport(List<RazorProjectItem> imports)
|
||||
{
|
||||
imports.Add(DefaultDirectivesProjectItem.Instance);
|
||||
}
|
||||
|
||||
// Internal for testing
|
||||
internal void AddHierarchicalImports(RazorProjectItem projectItem, List<RazorProjectItem> imports)
|
||||
{
|
||||
// We want items in descending order. FindHierarchicalItems returns items in ascending order.
|
||||
var importProjectItems = ProjectEngine.FileSystem.FindHierarchicalItems(projectItem.FilePath, ImportsFileName).Reverse();
|
||||
imports.AddRange(importProjectItems);
|
||||
}
|
||||
|
||||
private class DefaultDirectivesProjectItem : RazorProjectItem
|
||||
{
|
||||
private readonly byte[] _defaultImportBytes;
|
||||
|
||||
private DefaultDirectivesProjectItem()
|
||||
{
|
||||
var preamble = Encoding.UTF8.GetPreamble();
|
||||
var content = @"
|
||||
@using System
|
||||
@using System.Collections.Generic
|
||||
@using System.Linq
|
||||
@using System.Threading.Tasks
|
||||
@using Microsoft.AspNetCore.Mvc
|
||||
@using Microsoft.AspNetCore.Mvc.Rendering
|
||||
@using Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
@inject global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> Html
|
||||
@inject global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json
|
||||
@inject global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component
|
||||
@inject global::Microsoft.AspNetCore.Mvc.IUrlHelper Url
|
||||
@inject global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider
|
||||
@addTagHelper Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
";
|
||||
var contentBytes = Encoding.UTF8.GetBytes(content);
|
||||
|
||||
_defaultImportBytes = new byte[preamble.Length + contentBytes.Length];
|
||||
preamble.CopyTo(_defaultImportBytes, 0);
|
||||
contentBytes.CopyTo(_defaultImportBytes, preamble.Length);
|
||||
}
|
||||
|
||||
public override string BasePath => null;
|
||||
|
||||
public override string FilePath => null;
|
||||
|
||||
public override string PhysicalPath => null;
|
||||
|
||||
public override bool Exists => true;
|
||||
|
||||
public static DefaultDirectivesProjectItem Instance { get; } = new DefaultDirectivesProjectItem();
|
||||
|
||||
public override Stream Read() => new MemoryStream(_defaultImportBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class MvcViewDocumentClassifierPass : DocumentClassifierPassBase
|
||||
{
|
||||
public static readonly string MvcViewDocumentKind = "mvc.1.0.view";
|
||||
|
||||
protected override string DocumentKind => MvcViewDocumentKind;
|
||||
|
||||
protected override bool IsMatch(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode) => true;
|
||||
|
||||
protected override void OnDocumentStructureCreated(
|
||||
RazorCodeDocument codeDocument,
|
||||
NamespaceDeclarationIntermediateNode @namespace,
|
||||
ClassDeclarationIntermediateNode @class,
|
||||
MethodDeclarationIntermediateNode method)
|
||||
{
|
||||
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
|
||||
|
||||
@namespace.Content = "AspNetCore";
|
||||
|
||||
var filePath = codeDocument.Source.RelativePath ?? codeDocument.Source.FilePath;
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
// It's possible for a Razor document to not have a file path.
|
||||
// Eg. When we try to generate code for an in memory document like default imports.
|
||||
var checksum = BytesToString(codeDocument.Source.GetChecksum());
|
||||
@class.ClassName = $"AspNetCore_{checksum}";
|
||||
}
|
||||
else
|
||||
{
|
||||
@class.ClassName = CSharpIdentifier.GetClassNameFromPath(filePath);
|
||||
}
|
||||
|
||||
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>";
|
||||
@class.Modifiers.Clear();
|
||||
@class.Modifiers.Add("public");
|
||||
|
||||
method.MethodName = "ExecuteAsync";
|
||||
method.Modifiers.Clear();
|
||||
method.Modifiers.Add("public");
|
||||
method.Modifiers.Add("async");
|
||||
method.Modifiers.Add("override");
|
||||
method.ReturnType = $"global::{typeof(System.Threading.Tasks.Task).FullName}";
|
||||
}
|
||||
|
||||
private static string BytesToString(byte[] bytes)
|
||||
{
|
||||
if (bytes == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(bytes));
|
||||
}
|
||||
|
||||
var result = new StringBuilder(bytes.Length);
|
||||
for (var i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
// The x2 format means lowercase hex, where each byte is a 2-character string.
|
||||
result.Append(bytes[i].ToString("x2"));
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// 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.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
[assembly: ProvideRazorExtensionInitializer("MVC-1.0", typeof(ExtensionInitializer))]
|
||||
[assembly: ProvideRazorExtensionInitializer("MVC-1.1", typeof(ExtensionInitializer))]
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class RazorExtensions
|
||||
{
|
||||
public static void Register(RazorProjectEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
InjectDirective.Register(builder);
|
||||
ModelDirective.Register(builder);
|
||||
|
||||
InheritsDirective.Register(builder);
|
||||
|
||||
builder.Features.Add(new DefaultTagHelperDescriptorProvider());
|
||||
|
||||
// Register section directive with the 1.x compatible target extension.
|
||||
builder.AddDirective(SectionDirective.Directive);
|
||||
builder.Features.Add(new SectionDirectivePass());
|
||||
builder.AddTargetExtension(new LegacySectionTargetExtension());
|
||||
|
||||
builder.AddTargetExtension(new TemplateTargetExtension()
|
||||
{
|
||||
TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult",
|
||||
});
|
||||
|
||||
builder.Features.Add(new ModelExpressionPass());
|
||||
builder.Features.Add(new MvcViewDocumentClassifierPass());
|
||||
|
||||
builder.Features.Add(new MvcImportProjectFeature());
|
||||
|
||||
// The default C# language version for what this Razor configuration supports.
|
||||
builder.SetCSharpLanguageVersion(LanguageVersion.CSharp7_3);
|
||||
}
|
||||
|
||||
public static void RegisterViewComponentTagHelpers(RazorProjectEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
builder.Features.Add(new ViewComponentTagHelperDescriptorProvider());
|
||||
|
||||
builder.Features.Add(new ViewComponentTagHelperPass());
|
||||
builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension());
|
||||
}
|
||||
|
||||
#region Obsolete
|
||||
[Obsolete("This method is obsolete and will be removed in a future version.")]
|
||||
public static void Register(IRazorEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
EnsureDesignTime(builder);
|
||||
|
||||
InjectDirective.Register(builder);
|
||||
ModelDirective.Register(builder);
|
||||
|
||||
FunctionsDirective.Register(builder);
|
||||
InheritsDirective.Register(builder);
|
||||
|
||||
builder.Features.Add(new DefaultTagHelperDescriptorProvider());
|
||||
|
||||
// Register section directive with the 1.x compatible target extension.
|
||||
builder.AddDirective(SectionDirective.Directive);
|
||||
builder.Features.Add(new SectionDirectivePass());
|
||||
builder.AddTargetExtension(new LegacySectionTargetExtension());
|
||||
|
||||
builder.AddTargetExtension(new TemplateTargetExtension()
|
||||
{
|
||||
TemplateTypeName = "global::Microsoft.AspNetCore.Mvc.Razor.HelperResult",
|
||||
});
|
||||
|
||||
builder.Features.Add(new ModelExpressionPass());
|
||||
builder.Features.Add(new MvcViewDocumentClassifierPass());
|
||||
}
|
||||
|
||||
[Obsolete("This method is obsolete and will be removed in a future version.")]
|
||||
public static void RegisterViewComponentTagHelpers(IRazorEngineBuilder builder)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
EnsureDesignTime(builder);
|
||||
|
||||
builder.Features.Add(new ViewComponentTagHelperDescriptorProvider());
|
||||
builder.Features.Add(new ViewComponentTagHelperPass());
|
||||
builder.AddTargetExtension(new ViewComponentTagHelperTargetExtension());
|
||||
}
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
private static void EnsureDesignTime(IRazorEngineBuilder builder)
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
{
|
||||
if (builder.DesignTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
throw new NotSupportedException(Resources.RuntimeCodeGenerationNotSupported);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
// 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.
|
||||
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal class RazorExtensionsDiagnosticFactory
|
||||
{
|
||||
private const string DiagnosticPrefix = "RZ";
|
||||
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_CannotFindMethod =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3900",
|
||||
() => ViewComponentResources.ViewComponent_CannotFindMethod,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
|
||||
public static RazorDiagnostic CreateViewComponent_CannotFindMethod(string tagHelperType)
|
||||
{
|
||||
var diagnostic = RazorDiagnostic.Create(
|
||||
ViewComponent_CannotFindMethod,
|
||||
new SourceSpan(SourceLocation.Undefined, contentLength: 0),
|
||||
ViewComponentTypes.SyncMethodName,
|
||||
ViewComponentTypes.AsyncMethodName,
|
||||
tagHelperType);
|
||||
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_AmbiguousMethods =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3901",
|
||||
() => ViewComponentResources.ViewComponent_AmbiguousMethods,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
|
||||
public static RazorDiagnostic CreateViewComponent_AmbiguousMethods(string tagHelperType)
|
||||
{
|
||||
var diagnostic = RazorDiagnostic.Create(
|
||||
ViewComponent_AmbiguousMethods,
|
||||
new SourceSpan(SourceLocation.Undefined, contentLength: 0),
|
||||
tagHelperType,
|
||||
ViewComponentTypes.SyncMethodName,
|
||||
ViewComponentTypes.AsyncMethodName);
|
||||
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_AsyncMethod_ShouldReturnTask =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3902",
|
||||
() => ViewComponentResources.ViewComponent_AsyncMethod_ShouldReturnTask,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
|
||||
public static RazorDiagnostic CreateViewComponent_AsyncMethod_ShouldReturnTask(string tagHelperType)
|
||||
{
|
||||
var diagnostic = RazorDiagnostic.Create(
|
||||
ViewComponent_AsyncMethod_ShouldReturnTask,
|
||||
new SourceSpan(SourceLocation.Undefined, contentLength: 0),
|
||||
ViewComponentTypes.AsyncMethodName,
|
||||
tagHelperType,
|
||||
nameof(Task));
|
||||
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_ShouldReturnValue =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3903",
|
||||
() => ViewComponentResources.ViewComponent_SyncMethod_ShouldReturnValue,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
|
||||
public static RazorDiagnostic CreateViewComponent_SyncMethod_ShouldReturnValue(string tagHelperType)
|
||||
{
|
||||
var diagnostic = RazorDiagnostic.Create(
|
||||
ViewComponent_SyncMethod_ShouldReturnValue,
|
||||
new SourceSpan(SourceLocation.Undefined, contentLength: 0),
|
||||
ViewComponentTypes.SyncMethodName,
|
||||
tagHelperType);
|
||||
|
||||
return diagnostic;
|
||||
}
|
||||
|
||||
internal static readonly RazorDiagnosticDescriptor ViewComponent_SyncMethod_CannotReturnTask =
|
||||
new RazorDiagnosticDescriptor(
|
||||
$"{DiagnosticPrefix}3904",
|
||||
() => ViewComponentResources.ViewComponent_SyncMethod_CannotReturnTask,
|
||||
RazorDiagnosticSeverity.Error);
|
||||
|
||||
public static RazorDiagnostic CreateViewComponent_SyncMethod_CannotReturnTask(string tagHelperType)
|
||||
{
|
||||
var diagnostic = RazorDiagnostic.Create(
|
||||
ViewComponent_SyncMethod_CannotReturnTask,
|
||||
new SourceSpan(SourceLocation.Undefined, contentLength: 0),
|
||||
ViewComponentTypes.SyncMethodName,
|
||||
tagHelperType,
|
||||
nameof(Task));
|
||||
|
||||
return diagnostic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ArgumentCannotBeNullOrEmpy" xml:space="preserve">
|
||||
<value>Value cannot be null or empty.</value>
|
||||
</data>
|
||||
<data name="InjectDirective_Description" xml:space="preserve">
|
||||
<value>Inject a service from the application's service container into a property.</value>
|
||||
</data>
|
||||
<data name="InjectDirective_MemberToken_Description" xml:space="preserve">
|
||||
<value>The name of the property.</value>
|
||||
</data>
|
||||
<data name="InjectDirective_MemberToken_Name" xml:space="preserve">
|
||||
<value>PropertyName</value>
|
||||
</data>
|
||||
<data name="InjectDirective_TypeToken_Description" xml:space="preserve">
|
||||
<value>The type of the service to inject.</value>
|
||||
</data>
|
||||
<data name="InjectDirective_TypeToken_Name" xml:space="preserve">
|
||||
<value>TypeName</value>
|
||||
</data>
|
||||
<data name="ModelDirective_Description" xml:space="preserve">
|
||||
<value>Specify the view or page model for the page.</value>
|
||||
</data>
|
||||
<data name="ModelDirective_TypeToken_Description" xml:space="preserve">
|
||||
<value>The model type.</value>
|
||||
</data>
|
||||
<data name="ModelDirective_TypeToken_Name" xml:space="preserve">
|
||||
<value>TypeName</value>
|
||||
</data>
|
||||
<data name="MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword" xml:space="preserve">
|
||||
<value>The 'inherits' keyword is not allowed when a '{0}' keyword is used.</value>
|
||||
</data>
|
||||
<data name="MvcRazorCodeParser_InjectDirectivePropertyNameRequired" xml:space="preserve">
|
||||
<value>A property name must be specified when using the '{0}' statement. Format for a '{0}' statement is '@{0} <Type Name> <Property Name>'.</value>
|
||||
</data>
|
||||
<data name="MvcRazorCodeParser_KeywordMustBeFollowedByTypeName" xml:space="preserve">
|
||||
<value>The '{0}' keyword must be followed by a type name on the same line.</value>
|
||||
</data>
|
||||
<data name="MvcRazorCodeParser_OnlyOneModelStatementIsAllowed" xml:space="preserve">
|
||||
<value>Only one '{0}' statement is allowed in a file.</value>
|
||||
</data>
|
||||
<data name="MvcRazorParser_InvalidPropertyType" xml:space="preserve">
|
||||
<value>Invalid tag helper property '{0}.{1}'. Dictionary values must not be of type '{2}'.</value>
|
||||
</data>
|
||||
<data name="PageDirectiveCannotBeImported" xml:space="preserve">
|
||||
<value>The '@{0}' directive specified in {1} file will not be imported. The directive must appear at the top of each Razor cshtml file.</value>
|
||||
</data>
|
||||
<data name="RuntimeCodeGenerationNotSupported" xml:space="preserve">
|
||||
<value>Runtime code generation for Mvc 1.x is not supported.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class TagHelperDescriptorExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates whether a <see cref="TagHelperDescriptor"/> represents a view component.
|
||||
/// </summary>
|
||||
/// <param name="tagHelper">The <see cref="TagHelperDescriptor"/> to check.</param>
|
||||
/// <returns>Whether a <see cref="TagHelperDescriptor"/> represents a view component.</returns>
|
||||
public static bool IsViewComponentKind(this TagHelperDescriptor tagHelper)
|
||||
{
|
||||
if (tagHelper == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tagHelper));
|
||||
}
|
||||
|
||||
return string.Equals(ViewComponentTagHelperConventions.Kind, tagHelper.Kind, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
public static string GetViewComponentName(this TagHelperDescriptor tagHelper)
|
||||
{
|
||||
if (tagHelper == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(tagHelper));
|
||||
}
|
||||
|
||||
tagHelper.Metadata.TryGetValue(ViewComponentTagHelperMetadata.Name, out var result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="ViewComponent_AmbiguousMethods" xml:space="preserve">
|
||||
<value>View component '{0}' must have exactly one public method named '{1}' or '{2}'.</value>
|
||||
</data>
|
||||
<data name="ViewComponent_AsyncMethod_ShouldReturnTask" xml:space="preserve">
|
||||
<value>Method '{0}' of view component '{1}' should be declared to return {2}&lt;T&gt;.</value>
|
||||
</data>
|
||||
<data name="ViewComponent_CannotFindMethod" xml:space="preserve">
|
||||
<value>Could not find an '{0}' or '{1}' method for the view component '{2}'.</value>
|
||||
</data>
|
||||
<data name="ViewComponent_SyncMethod_CannotReturnTask" xml:space="preserve">
|
||||
<value>Method '{0}' of view component '{1}' cannot return a {2}.</value>
|
||||
</data>
|
||||
<data name="ViewComponent_SyncMethod_ShouldReturnValue" xml:space="preserve">
|
||||
<value>Method '{0}' of view component '{1}' should be declared to return a value.</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class ViewComponentTagHelperConventions
|
||||
{
|
||||
public static readonly string Kind = "MVC.ViewComponent";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,269 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal class ViewComponentTagHelperDescriptorFactory
|
||||
{
|
||||
private readonly INamedTypeSymbol _viewComponentAttributeSymbol;
|
||||
private readonly INamedTypeSymbol _genericTaskSymbol;
|
||||
private readonly INamedTypeSymbol _taskSymbol;
|
||||
private readonly INamedTypeSymbol _iDictionarySymbol;
|
||||
|
||||
private static readonly SymbolDisplayFormat FullNameTypeDisplayFormat =
|
||||
SymbolDisplayFormat.FullyQualifiedFormat
|
||||
.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted)
|
||||
.WithMiscellaneousOptions(SymbolDisplayFormat.FullyQualifiedFormat.MiscellaneousOptions & (~SymbolDisplayMiscellaneousOptions.UseSpecialTypes));
|
||||
|
||||
private static readonly IReadOnlyDictionary<string, string> PrimitiveDisplayTypeNameLookups = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
[typeof(byte).FullName] = "byte",
|
||||
[typeof(sbyte).FullName] = "sbyte",
|
||||
[typeof(int).FullName] = "int",
|
||||
[typeof(uint).FullName] = "uint",
|
||||
[typeof(short).FullName] = "short",
|
||||
[typeof(ushort).FullName] = "ushort",
|
||||
[typeof(long).FullName] = "long",
|
||||
[typeof(ulong).FullName] = "ulong",
|
||||
[typeof(float).FullName] = "float",
|
||||
[typeof(double).FullName] = "double",
|
||||
[typeof(char).FullName] = "char",
|
||||
[typeof(bool).FullName] = "bool",
|
||||
[typeof(object).FullName] = "object",
|
||||
[typeof(string).FullName] = "string",
|
||||
[typeof(decimal).FullName] = "decimal",
|
||||
};
|
||||
|
||||
public ViewComponentTagHelperDescriptorFactory(Compilation compilation)
|
||||
{
|
||||
_viewComponentAttributeSymbol = compilation.GetTypeByMetadataName(ViewComponentTypes.ViewComponentAttribute);
|
||||
_genericTaskSymbol = compilation.GetTypeByMetadataName(ViewComponentTypes.GenericTask);
|
||||
_taskSymbol = compilation.GetTypeByMetadataName(ViewComponentTypes.Task);
|
||||
_iDictionarySymbol = compilation.GetTypeByMetadataName(ViewComponentTypes.IDictionary);
|
||||
}
|
||||
|
||||
public virtual TagHelperDescriptor CreateDescriptor(INamedTypeSymbol type)
|
||||
{
|
||||
var assemblyName = type.ContainingAssembly.Name;
|
||||
var shortName = GetShortName(type);
|
||||
var tagName = $"vc:{HtmlConventions.ToHtmlCase(shortName)}";
|
||||
var typeName = $"__Generated__{shortName}ViewComponentTagHelper";
|
||||
var displayName = shortName + "ViewComponentTagHelper";
|
||||
var descriptorBuilder = TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, typeName, assemblyName);
|
||||
descriptorBuilder.SetTypeName(typeName);
|
||||
descriptorBuilder.DisplayName = displayName;
|
||||
|
||||
if (TryFindInvokeMethod(type, out var method, out var diagnostic))
|
||||
{
|
||||
var methodParameters = method.Parameters;
|
||||
descriptorBuilder.TagMatchingRule(ruleBuilder =>
|
||||
{
|
||||
ruleBuilder.TagName = tagName;
|
||||
AddRequiredAttributes(methodParameters, ruleBuilder);
|
||||
});
|
||||
|
||||
AddBoundAttributes(methodParameters, displayName, descriptorBuilder);
|
||||
}
|
||||
else
|
||||
{
|
||||
descriptorBuilder.Diagnostics.Add(diagnostic);
|
||||
}
|
||||
|
||||
descriptorBuilder.Metadata[ViewComponentTagHelperMetadata.Name] = shortName;
|
||||
|
||||
var descriptor = descriptorBuilder.Build();
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
private bool TryFindInvokeMethod(INamedTypeSymbol type, out IMethodSymbol method, out RazorDiagnostic diagnostic)
|
||||
{
|
||||
var methods = type.GetMembers()
|
||||
.OfType<IMethodSymbol>()
|
||||
.Where(m =>
|
||||
m.DeclaredAccessibility == Accessibility.Public &&
|
||||
(string.Equals(m.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal) ||
|
||||
string.Equals(m.Name, ViewComponentTypes.SyncMethodName, StringComparison.Ordinal)))
|
||||
.ToArray();
|
||||
|
||||
if (methods.Length == 0)
|
||||
{
|
||||
diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_CannotFindMethod(type.ToDisplayString(FullNameTypeDisplayFormat));
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
else if (methods.Length > 1)
|
||||
{
|
||||
diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_AmbiguousMethods(type.ToDisplayString(FullNameTypeDisplayFormat));
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
var selectedMethod = methods[0];
|
||||
var returnType = selectedMethod.ReturnType as INamedTypeSymbol;
|
||||
if (string.Equals(selectedMethod.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal))
|
||||
{
|
||||
// Will invoke asynchronously. Method must not return Task or Task<T>.
|
||||
if (SymbolEqualityComparer.Default.Equals(returnType, _taskSymbol))
|
||||
{
|
||||
// This is ok.
|
||||
}
|
||||
else if (returnType.IsGenericType && SymbolEqualityComparer.Default.Equals(returnType.ConstructedFrom, _genericTaskSymbol))
|
||||
{
|
||||
// This is ok.
|
||||
}
|
||||
else
|
||||
{
|
||||
diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_AsyncMethod_ShouldReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat));
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Will invoke synchronously. Method must not return void, Task or Task<T>.
|
||||
if (returnType.SpecialType == SpecialType.System_Void)
|
||||
{
|
||||
diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_ShouldReturnValue(type.ToDisplayString(FullNameTypeDisplayFormat));
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
else if (SymbolEqualityComparer.Default.Equals(returnType, _taskSymbol))
|
||||
{
|
||||
diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat));
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
else if (returnType.IsGenericType && SymbolEqualityComparer.Default.Equals(returnType.ConstructedFrom, _genericTaskSymbol))
|
||||
{
|
||||
diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat));
|
||||
method = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
method = selectedMethod;
|
||||
diagnostic = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AddRequiredAttributes(ImmutableArray<IParameterSymbol> methodParameters, TagMatchingRuleDescriptorBuilder builder)
|
||||
{
|
||||
foreach (var parameter in methodParameters)
|
||||
{
|
||||
if (GetIndexerValueTypeName(parameter) == null)
|
||||
{
|
||||
// Set required attributes only for non-indexer attributes. Indexer attributes can't be required attributes
|
||||
// because there are two ways of setting values for the attribute.
|
||||
builder.Attribute(attributeBuilder =>
|
||||
{
|
||||
var lowerKebabName = HtmlConventions.ToHtmlCase(parameter.Name);
|
||||
attributeBuilder.Name =lowerKebabName;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddBoundAttributes(ImmutableArray<IParameterSymbol> methodParameters, string containingDisplayName, TagHelperDescriptorBuilder builder)
|
||||
{
|
||||
foreach (var parameter in methodParameters)
|
||||
{
|
||||
var lowerKebabName = HtmlConventions.ToHtmlCase(parameter.Name);
|
||||
var typeName = parameter.Type.ToDisplayString(FullNameTypeDisplayFormat);
|
||||
|
||||
if (!PrimitiveDisplayTypeNameLookups.TryGetValue(typeName, out var simpleName))
|
||||
{
|
||||
simpleName = typeName;
|
||||
}
|
||||
|
||||
builder.BindAttribute(attributeBuilder =>
|
||||
{
|
||||
attributeBuilder.Name = lowerKebabName;
|
||||
attributeBuilder.TypeName = typeName;
|
||||
attributeBuilder.DisplayName = $"{simpleName} {containingDisplayName}.{parameter.Name}";
|
||||
attributeBuilder.SetPropertyName(parameter.Name);
|
||||
|
||||
if (parameter.Type.TypeKind == TypeKind.Enum)
|
||||
{
|
||||
attributeBuilder.IsEnum = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var dictionaryValueType = GetIndexerValueTypeName(parameter);
|
||||
if (dictionaryValueType != null)
|
||||
{
|
||||
attributeBuilder.AsDictionary(lowerKebabName + "-", dictionaryValueType);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private string GetIndexerValueTypeName(IParameterSymbol parameter)
|
||||
{
|
||||
INamedTypeSymbol dictionaryType;
|
||||
if (SymbolEqualityComparer.Default.Equals((parameter.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol))
|
||||
{
|
||||
dictionaryType = (INamedTypeSymbol)parameter.Type;
|
||||
}
|
||||
else if (parameter.Type.AllInterfaces.Any(s => SymbolEqualityComparer.Default.Equals(s.ConstructedFrom, _iDictionarySymbol)))
|
||||
{
|
||||
dictionaryType = parameter.Type.AllInterfaces.First(s => SymbolEqualityComparer.Default.Equals(s.ConstructedFrom, _iDictionarySymbol));
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionaryType = null;
|
||||
}
|
||||
|
||||
if (dictionaryType == null || dictionaryType.TypeArguments[0].SpecialType != SpecialType.System_String)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var type = dictionaryType.TypeArguments[1];
|
||||
var typeName = type.ToDisplayString(FullNameTypeDisplayFormat);
|
||||
|
||||
return typeName;
|
||||
}
|
||||
|
||||
private string GetShortName(INamedTypeSymbol componentType)
|
||||
{
|
||||
var viewComponentAttribute = componentType.GetAttributes().Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, _viewComponentAttributeSymbol)).FirstOrDefault();
|
||||
var name = viewComponentAttribute
|
||||
?.NamedArguments
|
||||
.Where(namedArgument => string.Equals(namedArgument.Key, ViewComponentTypes.ViewComponent.Name, StringComparison.Ordinal))
|
||||
.FirstOrDefault()
|
||||
.Value
|
||||
.Value as string;
|
||||
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
var separatorIndex = name.LastIndexOf('.');
|
||||
if (separatorIndex >= 0)
|
||||
{
|
||||
return name.Substring(separatorIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
// Get name by convention
|
||||
if (componentType.Name.EndsWith(ViewComponentTypes.ViewComponentSuffix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return componentType.Name.Substring(0, componentType.Name.Length - ViewComponentTypes.ViewComponentSuffix.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return componentType.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.Razor;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public sealed class ViewComponentTagHelperDescriptorProvider : RazorEngineFeatureBase, ITagHelperDescriptorProvider
|
||||
{
|
||||
public int Order { get; set; }
|
||||
|
||||
public void Execute(TagHelperDescriptorProviderContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
var compilation = context.GetCompilation();
|
||||
if (compilation == null)
|
||||
{
|
||||
// No compilation, nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
var vcAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.ViewComponentAttribute);
|
||||
var nonVCAttribute = compilation.GetTypeByMetadataName(ViewComponentTypes.NonViewComponentAttribute);
|
||||
if (vcAttribute == null || vcAttribute.TypeKind == TypeKind.Error)
|
||||
{
|
||||
// Could not find attributes we care about in the compilation. Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
var types = new List<INamedTypeSymbol>();
|
||||
var visitor = new ViewComponentTypeVisitor(vcAttribute, nonVCAttribute, types);
|
||||
|
||||
// We always visit the global namespace.
|
||||
visitor.Visit(compilation.Assembly.GlobalNamespace);
|
||||
|
||||
foreach (var reference in compilation.References)
|
||||
{
|
||||
if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly)
|
||||
{
|
||||
if (IsTagHelperAssembly(assembly))
|
||||
{
|
||||
visitor.Visit(assembly.GlobalNamespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var factory = new ViewComponentTagHelperDescriptorFactory(compilation);
|
||||
for (var i = 0; i < types.Count; i++)
|
||||
{
|
||||
var descriptor = factory.CreateDescriptor(types[i]);
|
||||
|
||||
if (descriptor != null)
|
||||
{
|
||||
context.Results.Add(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsTagHelperAssembly(IAssemblySymbol assembly)
|
||||
{
|
||||
return assembly.Name != null && !assembly.Name.StartsWith("System.", StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public sealed class ViewComponentTagHelperIntermediateNode : ExtensionIntermediateNode
|
||||
{
|
||||
public override IntermediateNodeCollection Children { get; } = IntermediateNodeCollection.ReadOnly;
|
||||
|
||||
public string ClassName { get; set; }
|
||||
|
||||
public TagHelperDescriptor TagHelper { get; set; }
|
||||
|
||||
public override void Accept(IntermediateNodeVisitor visitor)
|
||||
{
|
||||
if (visitor == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(visitor));
|
||||
}
|
||||
|
||||
AcceptExtensionNode<ViewComponentTagHelperIntermediateNode>(this, visitor);
|
||||
}
|
||||
|
||||
public override void WriteNode(CodeTarget target, CodeRenderingContext context)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
}
|
||||
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
var extension = target.GetExtension<IViewComponentTagHelperTargetExtension>();
|
||||
if (extension == null)
|
||||
{
|
||||
ReportMissingCodeTargetExtension<IViewComponentTagHelperTargetExtension>(context);
|
||||
return;
|
||||
}
|
||||
|
||||
extension.WriteViewComponentTagHelper(context, this);
|
||||
}
|
||||
|
||||
public override void FormatNode(IntermediateNodeFormatter formatter)
|
||||
{
|
||||
formatter.WriteContent(ClassName);
|
||||
|
||||
formatter.WriteProperty(nameof(ClassName), ClassName);
|
||||
formatter.WriteProperty(nameof(TagHelper), TagHelper?.DisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// 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.
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class ViewComponentTagHelperMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// The key in a <see cref="Microsoft.AspNetCore.Razor.Language.TagHelperDescriptor.Metadata"/> containing
|
||||
/// the short name of a view component.
|
||||
/// </summary>
|
||||
public static readonly string Name = "MVC.ViewComponent.Name";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class ViewComponentTagHelperPass : IntermediateNodePassBase, IRazorOptimizationPass
|
||||
{
|
||||
// Run after the default taghelper pass
|
||||
public override int Order => IntermediateNodePassBase.DefaultFeatureOrder + 2000;
|
||||
|
||||
protected override void ExecuteCore(RazorCodeDocument codeDocument, DocumentIntermediateNode documentNode)
|
||||
{
|
||||
var @namespace = documentNode.FindPrimaryNamespace();
|
||||
var @class = documentNode.FindPrimaryClass();
|
||||
if (@namespace == null || @class == null)
|
||||
{
|
||||
// Nothing to do, bail. We can't function without the standard structure.
|
||||
return;
|
||||
}
|
||||
|
||||
var context = new Context(@namespace, @class);
|
||||
|
||||
// For each VCTH *usage* we need to rewrite the tag helper node to use the tag helper runtime to construct
|
||||
// and set properties on the the correct field, and using the name of the type we will generate.
|
||||
var nodes = documentNode.FindDescendantNodes<TagHelperIntermediateNode>();
|
||||
for (var i = 0; i < nodes.Count; i++)
|
||||
{
|
||||
var node = nodes[i];
|
||||
foreach (var tagHelper in node.TagHelpers)
|
||||
{
|
||||
RewriteUsage(context, node, tagHelper);
|
||||
}
|
||||
}
|
||||
|
||||
// Then for each VCTH *definition* that we've seen we need to generate the class that implements
|
||||
// ITagHelper and the field that will hold it.
|
||||
foreach (var tagHelper in context.TagHelpers)
|
||||
{
|
||||
AddField(context, tagHelper);
|
||||
AddTagHelperClass(context, tagHelper);
|
||||
}
|
||||
}
|
||||
|
||||
private void RewriteUsage(Context context, TagHelperIntermediateNode node, TagHelperDescriptor tagHelper)
|
||||
{
|
||||
if (!tagHelper.IsViewComponentKind())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
context.Add(tagHelper);
|
||||
|
||||
// Now we need to insert a create node using the default tag helper runtime. This is similar to
|
||||
// code in DefaultTagHelperOptimizationPass.
|
||||
//
|
||||
// Find the body node.
|
||||
var i = 0;
|
||||
while (i < node.Children.Count && node.Children[i] is TagHelperBodyIntermediateNode)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
while (i < node.Children.Count && node.Children[i] is DefaultTagHelperBodyIntermediateNode)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
// Now find the last create node.
|
||||
while (i < node.Children.Count && node.Children[i] is DefaultTagHelperCreateIntermediateNode)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
// Now i has the right insertion point.
|
||||
node.Children.Insert(i, new DefaultTagHelperCreateIntermediateNode()
|
||||
{
|
||||
FieldName = context.GetFieldName(tagHelper),
|
||||
TagHelper = tagHelper,
|
||||
TypeName = context.GetFullyQualifiedName(tagHelper),
|
||||
});
|
||||
|
||||
// Now we need to rewrite any set property nodes to use the default runtime.
|
||||
for (i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
if (node.Children[i] is TagHelperPropertyIntermediateNode propertyNode &&
|
||||
propertyNode.TagHelper == tagHelper)
|
||||
{
|
||||
// This is a set property for this VCTH - we need to replace it with a node
|
||||
// that will use our field and property name.
|
||||
node.Children[i] = new DefaultTagHelperPropertyIntermediateNode(propertyNode)
|
||||
{
|
||||
FieldName = context.GetFieldName(tagHelper),
|
||||
PropertyName = propertyNode.BoundAttribute.GetPropertyName(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddField(Context context, TagHelperDescriptor tagHelper)
|
||||
{
|
||||
// We need to insert a node for the field that will hold the tag helper. We've already generated a field name
|
||||
// at this time and use it for all uses of the same tag helper type.
|
||||
//
|
||||
// We also want to preserve the ordering of the nodes for testability. So insert at the end of any existing
|
||||
// field nodes.
|
||||
var i = 0;
|
||||
while (i < context.Class.Children.Count && context.Class.Children[i] is DefaultTagHelperRuntimeIntermediateNode)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
while (i < context.Class.Children.Count && context.Class.Children[i] is FieldDeclarationIntermediateNode)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
context.Class.Children.Insert(i, new FieldDeclarationIntermediateNode()
|
||||
{
|
||||
Annotations =
|
||||
{
|
||||
{ CommonAnnotations.DefaultTagHelperExtension.TagHelperField, bool.TrueString },
|
||||
},
|
||||
Modifiers =
|
||||
{
|
||||
"private",
|
||||
},
|
||||
FieldName = context.GetFieldName(tagHelper),
|
||||
FieldType = "global::" + context.GetFullyQualifiedName(tagHelper),
|
||||
});
|
||||
}
|
||||
|
||||
private void AddTagHelperClass(Context context, TagHelperDescriptor tagHelper)
|
||||
{
|
||||
var node = new ViewComponentTagHelperIntermediateNode()
|
||||
{
|
||||
ClassName = context.GetClassName(tagHelper),
|
||||
TagHelper = tagHelper
|
||||
};
|
||||
|
||||
context.Class.Children.Add(node);
|
||||
}
|
||||
|
||||
private struct Context
|
||||
{
|
||||
private Dictionary<TagHelperDescriptor, (string className, string fullyQualifiedName, string fieldName)> _tagHelpers;
|
||||
|
||||
public Context(NamespaceDeclarationIntermediateNode @namespace, ClassDeclarationIntermediateNode @class)
|
||||
{
|
||||
Namespace = @namespace;
|
||||
Class = @class;
|
||||
|
||||
_tagHelpers = new Dictionary<TagHelperDescriptor, (string, string, string)>();
|
||||
}
|
||||
|
||||
public ClassDeclarationIntermediateNode Class { get; }
|
||||
|
||||
public NamespaceDeclarationIntermediateNode Namespace { get; }
|
||||
|
||||
|
||||
public IEnumerable<TagHelperDescriptor> TagHelpers => _tagHelpers.Keys;
|
||||
|
||||
public bool Add(TagHelperDescriptor tagHelper)
|
||||
{
|
||||
if (_tagHelpers.ContainsKey(tagHelper))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var className = $"__Generated__{tagHelper.GetViewComponentName()}ViewComponentTagHelper";
|
||||
var fullyQualifiedName = $"{Namespace.Content}.{Class.ClassName}.{className}";
|
||||
var fieldName = GenerateFieldName(tagHelper);
|
||||
|
||||
_tagHelpers.Add(tagHelper, (className, fullyQualifiedName, fieldName));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GetClassName(TagHelperDescriptor taghelper)
|
||||
{
|
||||
return _tagHelpers[taghelper].className;
|
||||
}
|
||||
|
||||
public string GetFullyQualifiedName(TagHelperDescriptor taghelper)
|
||||
{
|
||||
return _tagHelpers[taghelper].fullyQualifiedName;
|
||||
}
|
||||
|
||||
public string GetFieldName(TagHelperDescriptor taghelper)
|
||||
{
|
||||
return _tagHelpers[taghelper].fieldName;
|
||||
}
|
||||
|
||||
private static string GenerateFieldName(TagHelperDescriptor tagHelper)
|
||||
{
|
||||
return $"__{tagHelper.GetViewComponentName()}ViewComponentTagHelper";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,183 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal class ViewComponentTagHelperTargetExtension : IViewComponentTagHelperTargetExtension
|
||||
{
|
||||
private static readonly string[] PublicModifiers = new[] { "public" };
|
||||
|
||||
public string TagHelperTypeName { get; set; } = "Microsoft.AspNetCore.Razor.TagHelpers.TagHelper";
|
||||
|
||||
public string ViewComponentHelperTypeName { get; set; } = "global::Microsoft.AspNetCore.Mvc.IViewComponentHelper";
|
||||
|
||||
public string ViewComponentHelperVariableName { get; set; } = "_helper";
|
||||
|
||||
public string ViewComponentInvokeMethodName { get; set; } = "InvokeAsync";
|
||||
|
||||
public string HtmlAttributeNotBoundAttributeTypeName { get; set; } = "Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNotBoundAttribute";
|
||||
|
||||
public string ViewContextAttributeTypeName { get; set; } = "global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewContextAttribute";
|
||||
|
||||
public string ViewContextTypeName { get; set; } = "global::Microsoft.AspNetCore.Mvc.Rendering.ViewContext";
|
||||
|
||||
public string ViewContextPropertyName { get; set; } = "ViewContext";
|
||||
|
||||
public string HtmlTargetElementAttributeTypeName { get; set; } = "Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElementAttribute";
|
||||
|
||||
public string TagHelperProcessMethodName { get; set; } = "ProcessAsync";
|
||||
|
||||
public string TagHelperContextTypeName { get; set; } = "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext";
|
||||
|
||||
public string TagHelperContextVariableName { get; set; } = "context";
|
||||
|
||||
public string TagHelperOutputTypeName { get; set; } = "Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput";
|
||||
|
||||
public string TagHelperOutputVariableName { get; set; } = "output";
|
||||
|
||||
public string TagHelperOutputTagNamePropertyName { get; set; } = "TagName";
|
||||
|
||||
public string TagHelperOutputContentPropertyName { get; set; } = "Content";
|
||||
|
||||
public string TagHelperContentSetMethodName { get; set; } = "SetHtmlContent";
|
||||
|
||||
public string TagHelperContentVariableName { get; set; } = "content";
|
||||
|
||||
public string IViewContextAwareTypeName { get; set; } = "global::Microsoft.AspNetCore.Mvc.ViewFeatures.IViewContextAware";
|
||||
|
||||
public string IViewContextAwareContextualizeMethodName { get; set; } = "Contextualize";
|
||||
|
||||
public void WriteViewComponentTagHelper(CodeRenderingContext context, ViewComponentTagHelperIntermediateNode node)
|
||||
{
|
||||
// Add target element.
|
||||
WriteTargetElementString(context.CodeWriter, node.TagHelper);
|
||||
|
||||
// Initialize declaration.
|
||||
using (context.CodeWriter.BuildClassDeclaration(
|
||||
PublicModifiers,
|
||||
node.ClassName,
|
||||
TagHelperTypeName,
|
||||
interfaces: null,
|
||||
typeParameters: null))
|
||||
{
|
||||
// Add view component helper.
|
||||
context.CodeWriter.WriteVariableDeclaration(
|
||||
$"private readonly {ViewComponentHelperTypeName}",
|
||||
ViewComponentHelperVariableName,
|
||||
value: null);
|
||||
|
||||
// Add constructor.
|
||||
WriteConstructorString(context.CodeWriter, node.ClassName);
|
||||
|
||||
// Add attributes.
|
||||
WriteAttributeDeclarations(context.CodeWriter, node.TagHelper);
|
||||
|
||||
// Add process method.
|
||||
WriteProcessMethodString(context.CodeWriter, node.TagHelper);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteConstructorString(CodeWriter writer, string className)
|
||||
{
|
||||
writer.Write("public ")
|
||||
.Write(className)
|
||||
.Write("(")
|
||||
.Write($"{ViewComponentHelperTypeName} helper")
|
||||
.WriteLine(")");
|
||||
using (writer.BuildScope())
|
||||
{
|
||||
writer.WriteStartAssignment(ViewComponentHelperVariableName)
|
||||
.Write("helper")
|
||||
.WriteLine(";");
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteAttributeDeclarations(CodeWriter writer, TagHelperDescriptor tagHelper)
|
||||
{
|
||||
writer.Write("[")
|
||||
.Write(HtmlAttributeNotBoundAttributeTypeName)
|
||||
.WriteParameterSeparator()
|
||||
.Write(ViewContextAttributeTypeName)
|
||||
.WriteLine("]");
|
||||
|
||||
writer.WriteAutoPropertyDeclaration(
|
||||
PublicModifiers,
|
||||
ViewContextTypeName,
|
||||
ViewContextPropertyName);
|
||||
|
||||
foreach (var attribute in tagHelper.BoundAttributes)
|
||||
{
|
||||
writer.WriteAutoPropertyDeclaration(
|
||||
PublicModifiers,
|
||||
attribute.TypeName,
|
||||
attribute.GetPropertyName());
|
||||
|
||||
if (attribute.IndexerTypeName != null)
|
||||
{
|
||||
writer.Write(" = ")
|
||||
.WriteStartNewObject(attribute.TypeName)
|
||||
.WriteEndMethodInvocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteProcessMethodString(CodeWriter writer, TagHelperDescriptor tagHelper)
|
||||
{
|
||||
using (writer.BuildMethodDeclaration(
|
||||
$"public override async",
|
||||
$"global::{typeof(Task).FullName}",
|
||||
TagHelperProcessMethodName,
|
||||
new Dictionary<string, string>()
|
||||
{
|
||||
{ TagHelperContextTypeName, TagHelperContextVariableName },
|
||||
{ TagHelperOutputTypeName, TagHelperOutputVariableName }
|
||||
}))
|
||||
{
|
||||
writer.WriteInstanceMethodInvocation(
|
||||
$"({ViewComponentHelperVariableName} as {IViewContextAwareTypeName})?",
|
||||
IViewContextAwareContextualizeMethodName,
|
||||
new[] { ViewContextPropertyName });
|
||||
|
||||
var methodParameters = GetMethodParameters(tagHelper);
|
||||
writer.Write("var ")
|
||||
.WriteStartAssignment(TagHelperContentVariableName)
|
||||
.WriteInstanceMethodInvocation($"await {ViewComponentHelperVariableName}", ViewComponentInvokeMethodName, methodParameters);
|
||||
writer.WriteStartAssignment($"{TagHelperOutputVariableName}.{TagHelperOutputTagNamePropertyName}")
|
||||
.WriteLine("null;");
|
||||
writer.WriteInstanceMethodInvocation(
|
||||
$"{TagHelperOutputVariableName}.{TagHelperOutputContentPropertyName}",
|
||||
TagHelperContentSetMethodName,
|
||||
new[] { TagHelperContentVariableName });
|
||||
}
|
||||
}
|
||||
|
||||
private string[] GetMethodParameters(TagHelperDescriptor tagHelper)
|
||||
{
|
||||
var propertyNames = tagHelper.BoundAttributes.Select(attribute => attribute.GetPropertyName());
|
||||
var joinedPropertyNames = string.Join(", ", propertyNames);
|
||||
var parametersString = $"new {{ { joinedPropertyNames } }}";
|
||||
var viewComponentName = tagHelper.GetViewComponentName();
|
||||
var methodParameters = new[] { $"\"{viewComponentName}\"", parametersString };
|
||||
return methodParameters;
|
||||
}
|
||||
|
||||
private void WriteTargetElementString(CodeWriter writer, TagHelperDescriptor tagHelper)
|
||||
{
|
||||
Debug.Assert(tagHelper.TagMatchingRules.Count() == 1);
|
||||
|
||||
var rule = tagHelper.TagMatchingRules.First();
|
||||
|
||||
writer.Write("[")
|
||||
.WriteStartMethodInvocation(HtmlTargetElementAttributeTypeName)
|
||||
.WriteStringLiteral(rule.TagName)
|
||||
.WriteLine(")]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal class ViewComponentTypeVisitor : SymbolVisitor
|
||||
{
|
||||
private static readonly Version SupportedVCTHMvcVersion = new Version(1, 1);
|
||||
|
||||
private readonly INamedTypeSymbol _viewComponentAttribute;
|
||||
private readonly INamedTypeSymbol _nonViewComponentAttribute;
|
||||
private readonly List<INamedTypeSymbol> _results;
|
||||
|
||||
public ViewComponentTypeVisitor(
|
||||
INamedTypeSymbol viewComponentAttribute,
|
||||
INamedTypeSymbol nonViewComponentAttribute,
|
||||
List<INamedTypeSymbol> results)
|
||||
{
|
||||
_viewComponentAttribute = viewComponentAttribute;
|
||||
_nonViewComponentAttribute = nonViewComponentAttribute;
|
||||
_results = results;
|
||||
}
|
||||
|
||||
public override void VisitNamedType(INamedTypeSymbol symbol)
|
||||
{
|
||||
if (IsViewComponent(symbol))
|
||||
{
|
||||
_results.Add(symbol);
|
||||
}
|
||||
|
||||
if (symbol.DeclaredAccessibility != Accessibility.Public)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var member in symbol.GetTypeMembers())
|
||||
{
|
||||
Visit(member);
|
||||
}
|
||||
}
|
||||
|
||||
public override void VisitNamespace(INamespaceSymbol symbol)
|
||||
{
|
||||
foreach (var member in symbol.GetMembers())
|
||||
{
|
||||
Visit(member);
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsViewComponent(INamedTypeSymbol symbol)
|
||||
{
|
||||
if (symbol.DeclaredAccessibility != Accessibility.Public ||
|
||||
symbol.IsAbstract ||
|
||||
symbol.IsGenericType ||
|
||||
AttributeIsDefined(symbol, _nonViewComponentAttribute))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return symbol.Name.EndsWith(ViewComponentTypes.ViewComponentSuffix) ||
|
||||
AttributeIsDefined(symbol, _viewComponentAttribute);
|
||||
}
|
||||
|
||||
private static bool AttributeIsDefined(INamedTypeSymbol type, INamedTypeSymbol queryAttribute)
|
||||
{
|
||||
if (type == null || queryAttribute == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var attribute = type.GetAttributes().Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, queryAttribute)).FirstOrDefault();
|
||||
|
||||
if (attribute != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return AttributeIsDefined(type.BaseType, queryAttribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
internal static class ViewComponentTypes
|
||||
{
|
||||
public const string Assembly = "Microsoft.AspNetCore.Mvc.ViewFeatures";
|
||||
|
||||
public static readonly Version AssemblyVersion = new Version(1, 1, 0, 0);
|
||||
|
||||
public const string ViewComponentSuffix = "ViewComponent";
|
||||
|
||||
public const string ViewComponentAttribute = "Microsoft.AspNetCore.Mvc.ViewComponentAttribute";
|
||||
|
||||
public const string NonViewComponentAttribute = "Microsoft.AspNetCore.Mvc.NonViewComponentAttribute";
|
||||
|
||||
public const string GenericTask = "System.Threading.Tasks.Task`1";
|
||||
|
||||
public const string Task = "System.Threading.Tasks.Task";
|
||||
|
||||
public const string IDictionary = "System.Collections.Generic.IDictionary`2";
|
||||
|
||||
public const string AsyncMethodName = "InvokeAsync";
|
||||
|
||||
public const string SyncMethodName = "Invoke";
|
||||
|
||||
public static class ViewComponent
|
||||
{
|
||||
public const string Name = "Name";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class InjectDirectiveTest
|
||||
{
|
||||
[Fact]
|
||||
public void InjectDirectivePass_Execute_DefinesProperty()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inject PropertyType PropertyName
|
||||
");
|
||||
|
||||
var engine = CreateEngine();
|
||||
var pass = new InjectDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal(2, @class.Children.Count);
|
||||
|
||||
var node = Assert.IsType<InjectIntermediateNode>(@class.Children[1]);
|
||||
Assert.Equal("PropertyType", node.TypeName);
|
||||
Assert.Equal("PropertyName", node.MemberName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectDirectivePass_Execute_DedupesPropertiesByName()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inject PropertyType PropertyName
|
||||
@inject PropertyType2 PropertyName
|
||||
");
|
||||
|
||||
var engine = CreateEngine();
|
||||
var pass = new InjectDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal(2, @class.Children.Count);
|
||||
|
||||
var node = Assert.IsType<InjectIntermediateNode>(@class.Children[1]);
|
||||
Assert.Equal("PropertyType2", node.TypeName);
|
||||
Assert.Equal("PropertyName", node.MemberName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectDirectivePass_Execute_ExpandsTModel_WithDynamic()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inject PropertyType<TModel> PropertyName
|
||||
");
|
||||
|
||||
var engine = CreateEngine();
|
||||
var pass = new InjectDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal(2, @class.Children.Count);
|
||||
|
||||
var node = Assert.IsType<InjectIntermediateNode>(@class.Children[1]);
|
||||
Assert.Equal("PropertyType<dynamic>", node.TypeName);
|
||||
Assert.Equal("PropertyName", node.MemberName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectDirectivePass_Execute_ExpandsTModel_WithModelTypeFirst()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@model ModelType
|
||||
@inject PropertyType<TModel> PropertyName
|
||||
");
|
||||
|
||||
var engine = CreateEngine();
|
||||
var pass = new InjectDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal(2, @class.Children.Count);
|
||||
|
||||
var node = Assert.IsType<InjectIntermediateNode>(@class.Children[1]);
|
||||
Assert.Equal("PropertyType<ModelType>", node.TypeName);
|
||||
Assert.Equal("PropertyName", node.MemberName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectDirectivePass_Execute_ExpandsTModel_WithModelType()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inject PropertyType<TModel> PropertyName
|
||||
@model ModelType
|
||||
");
|
||||
|
||||
var engine = CreateEngine();
|
||||
var pass = new InjectDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal(2, @class.Children.Count);
|
||||
|
||||
var node = Assert.IsType<InjectIntermediateNode>(@class.Children[1]);
|
||||
Assert.Equal("PropertyType<ModelType>", node.TypeName);
|
||||
Assert.Equal("PropertyName", node.MemberName);
|
||||
}
|
||||
|
||||
private RazorCodeDocument CreateDocument(string content)
|
||||
{
|
||||
var source = RazorSourceDocument.Create(content, "test.cshtml");
|
||||
return RazorCodeDocument.Create(source);
|
||||
}
|
||||
|
||||
private ClassDeclarationIntermediateNode FindClassNode(IntermediateNode node)
|
||||
{
|
||||
var visitor = new ClassNodeVisitor();
|
||||
visitor.Visit(node);
|
||||
return visitor.Node;
|
||||
}
|
||||
|
||||
private RazorEngine CreateEngine()
|
||||
{
|
||||
var configuration = RazorConfiguration.Create(RazorLanguageVersion.Version_1_1, "test", Array.Empty<RazorExtension>());
|
||||
return RazorProjectEngine.Create(configuration, RazorProjectFileSystem.Empty, b =>
|
||||
{
|
||||
// Notice we're not registering the InjectDirective.Pass here so we can run it on demand.
|
||||
b.AddDirective(InjectDirective.Directive);
|
||||
b.AddDirective(ModelDirective.Directive);
|
||||
}).Engine;
|
||||
}
|
||||
|
||||
private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument)
|
||||
{
|
||||
for (var i = 0; i < engine.Phases.Count; i++)
|
||||
{
|
||||
var phase = engine.Phases[i];
|
||||
phase.Execute(codeDocument);
|
||||
|
||||
if (phase is IRazorDocumentClassifierPhase)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return codeDocument.GetDocumentIntermediateNode();
|
||||
}
|
||||
|
||||
private string GetCSharpContent(IntermediateNode node)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
var child = node.Children[i] as IntermediateToken;
|
||||
if (child.Kind == TokenKind.CSharp)
|
||||
{
|
||||
builder.Append(child.Content);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private class ClassNodeVisitor : IntermediateNodeWalker
|
||||
{
|
||||
public ClassDeclarationIntermediateNode Node { get; set; }
|
||||
|
||||
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
|
||||
{
|
||||
Node = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using Microsoft.AspNetCore.Razor.Language.Legacy;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class InjectTargetExtensionTest
|
||||
{
|
||||
[Fact]
|
||||
public void InjectDirectiveTargetExtension_WritesProperty()
|
||||
{
|
||||
// Arrange
|
||||
var context = TestCodeRenderingContext.CreateRuntime();
|
||||
var target = new InjectTargetExtension();
|
||||
var node = new InjectIntermediateNode()
|
||||
{
|
||||
TypeName = "PropertyType",
|
||||
MemberName = "PropertyName",
|
||||
};
|
||||
|
||||
// Act
|
||||
target.WriteInjectProperty(context, node);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(
|
||||
"[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]" + Environment.NewLine +
|
||||
"public PropertyType PropertyName { get; private set; }" + Environment.NewLine,
|
||||
context.CodeWriter.GenerateCode());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectDirectiveTargetExtension_WritesPropertyWithLinePragma_WhenSourceIsSet()
|
||||
{
|
||||
// Arrange
|
||||
var context = TestCodeRenderingContext.CreateRuntime();
|
||||
var target = new InjectTargetExtension();
|
||||
var node = new InjectIntermediateNode()
|
||||
{
|
||||
TypeName = "PropertyType<ModelType>",
|
||||
MemberName = "PropertyName",
|
||||
Source = new SourceSpan(
|
||||
filePath: "test-path",
|
||||
absoluteIndex: 0,
|
||||
lineIndex: 1,
|
||||
characterIndex: 1,
|
||||
length: 10)
|
||||
};
|
||||
|
||||
// Act
|
||||
target.WriteInjectProperty(context, node);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Environment.NewLine +
|
||||
"#nullable restore" + Environment.NewLine +
|
||||
"#line 2 \"test-path\"" + Environment.NewLine +
|
||||
"[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]" + Environment.NewLine +
|
||||
"public PropertyType<ModelType> PropertyName { get; private set; }" + Environment.NewLine + Environment.NewLine +
|
||||
"#line default" + Environment.NewLine +
|
||||
"#line hidden" + Environment.NewLine +
|
||||
"#nullable disable" + Environment.NewLine,
|
||||
context.CodeWriter.GenerateCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,370 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.IntegrationTests;
|
||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.IntegrationTests
|
||||
{
|
||||
public class CodeGenerationIntegrationTest : IntegrationTestBase
|
||||
{
|
||||
private readonly static CSharpCompilation DefaultBaseCompilation = MvcShim.BaseCompilation.WithAssemblyName("AppCode");
|
||||
|
||||
public CodeGenerationIntegrationTest()
|
||||
: base(generateBaselines: null)
|
||||
{
|
||||
Configuration = RazorConfiguration.Create(
|
||||
RazorLanguageVersion.Version_1_1,
|
||||
"MVC-1.1",
|
||||
new[] { new AssemblyExtension("MVC-1.1", typeof(ExtensionInitializer).Assembly) });
|
||||
}
|
||||
|
||||
protected override CSharpCompilation BaseCompilation => DefaultBaseCompilation;
|
||||
|
||||
protected override RazorConfiguration Configuration { get; }
|
||||
|
||||
[Fact]
|
||||
public void InvalidNamespaceAtEOF_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToCSharp(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
|
||||
var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics;
|
||||
Assert.Equal("RZ1007", Assert.Single(diagnotics).Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IncompleteDirectives_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
public class MyService<TModel>
|
||||
{
|
||||
public string Html { get; set; }
|
||||
}");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToCSharp(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
|
||||
// We expect this test to generate a bunch of errors.
|
||||
Assert.True(compiled.CodeDocument.GetCSharpDocument().Diagnostics.Count > 0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsViewModel_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
|
||||
public class MyBasePageForViews<TModel> : RazorPage
|
||||
{
|
||||
public override Task ExecuteAsync()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
public class MyModel
|
||||
{
|
||||
|
||||
}
|
||||
");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InheritsWithViewImports_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
|
||||
public class MyBasePageForViews<TModel> : RazorPage
|
||||
{
|
||||
public override Task ExecuteAsync()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class MyModel
|
||||
{
|
||||
|
||||
}");
|
||||
|
||||
AddProjectItemFromText(@"@inherits MyBasePageForViews<TModel>");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Basic_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Sections_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree($@"
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
public class InputTestTagHelper : {typeof(TagHelper).FullName}
|
||||
{{
|
||||
public ModelExpression For {{ get; set; }}
|
||||
}}
|
||||
");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void _ViewImports_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Inject_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
public class MyApp
|
||||
{
|
||||
public string MyProperty { get; set; }
|
||||
}
|
||||
");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectWithModel_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
public class MyModel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class MyService<TModel>
|
||||
{
|
||||
public string Html { get; set; }
|
||||
}
|
||||
|
||||
public class MyApp
|
||||
{
|
||||
public string MyProperty { get; set; }
|
||||
}");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InjectWithSemicolon_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
public class MyModel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class MyApp
|
||||
{
|
||||
public string MyProperty { get; set; }
|
||||
}
|
||||
|
||||
public class MyService<TModel>
|
||||
{
|
||||
public string Html { get; set; }
|
||||
}
|
||||
");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Model_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MultipleModels_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree(@"
|
||||
public class ThisShouldBeGenerated
|
||||
{
|
||||
|
||||
}");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToCSharp(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
|
||||
var diagnotics = compiled.CodeDocument.GetCSharpDocument().Diagnostics;
|
||||
Assert.Equal("RZ2001", Assert.Single(diagnotics).Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelExpressionTagHelper_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree($@"
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
|
||||
public class InputTestTagHelper : {typeof(TagHelper).FullName}
|
||||
{{
|
||||
public ModelExpression For {{ get; set; }}
|
||||
}}
|
||||
");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ViewComponentTagHelper_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
AddCSharpSyntaxTree($@"
|
||||
public class TestViewComponent
|
||||
{{
|
||||
public string Invoke(string firstName)
|
||||
{{
|
||||
return firstName;
|
||||
}}
|
||||
}}
|
||||
|
||||
[{typeof(HtmlTargetElementAttribute).FullName}]
|
||||
public class AllTagHelper : {typeof(TagHelper).FullName}
|
||||
{{
|
||||
public string Bar {{ get; set; }}
|
||||
}}
|
||||
");
|
||||
|
||||
var projectItem = CreateProjectItemFromFile();
|
||||
|
||||
// Act
|
||||
var compiled = CompileToAssembly(projectItem, designTime: true);
|
||||
|
||||
// Assert
|
||||
AssertDocumentNodeMatchesBaseline(compiled.CodeDocument.GetDocumentIntermediateNode());
|
||||
AssertCSharpDocumentMatchesBaseline(compiled.CodeDocument.GetCSharpDocument());
|
||||
AssertSourceMappingsMatchBaseline(compiled.CodeDocument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language.CodeGeneration;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.Language.Extensions
|
||||
{
|
||||
public class LegacySectionTargetExtensionTest
|
||||
{
|
||||
[Fact]
|
||||
public void WriteSection_WritesSectionCode_DesignTime()
|
||||
{
|
||||
// Arrange
|
||||
var node = new SectionIntermediateNode()
|
||||
{
|
||||
Children =
|
||||
{
|
||||
new CSharpExpressionIntermediateNode(),
|
||||
},
|
||||
SectionName = "MySection"
|
||||
};
|
||||
|
||||
var extension = new LegacySectionTargetExtension()
|
||||
{
|
||||
SectionMethodName = "CreateSection"
|
||||
};
|
||||
|
||||
var context = TestCodeRenderingContext.CreateDesignTime();
|
||||
|
||||
// Act
|
||||
extension.WriteSection(context, node);
|
||||
|
||||
// Assert
|
||||
var expected = @"CreateSection(""MySection"", async(__razor_section_writer) => {
|
||||
Render Children
|
||||
}
|
||||
);
|
||||
";
|
||||
|
||||
var output = context.CodeWriter.GenerateCode();
|
||||
Assert.Equal(expected, output, ignoreLineEndingDifferences: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<DefaultItemExcludes>$(DefaultItemExcludes);TestFiles\**</DefaultItemExcludes>
|
||||
|
||||
<!-- Work around https://github.com/microsoft/msbuild/issues/4740 -->
|
||||
<EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="TestFiles\**" />
|
||||
<None Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.CodeAnalysis.Razor\Microsoft.CodeAnalysis.Razor.csproj" />
|
||||
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj" />
|
||||
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(Runtime_MicrosoftCodeAnalysisCSharpPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
|
||||
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<MvcShim Condition="$(TargetFramework) != ''" Include="$(ArtifactsBinDir)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X\$(Configuration)\$(TargetFramework)\Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X.deps.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CopyDepsFromShims" AfterTargets="Build">
|
||||
<Copy SourceFiles="@(MvcShim)" DestinationFolder="$(OutputPath)" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,345 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Extensions;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class ModelDirectiveTest : RazorProjectEngineTestBase
|
||||
{
|
||||
protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_1_1;
|
||||
|
||||
[Fact]
|
||||
public void ModelDirective_GetModelType_GetsTypeFromFirstWellFormedDirective()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@model Type1
|
||||
@model Type2
|
||||
@model
|
||||
");
|
||||
|
||||
var engine = CreateRuntimeEngine();
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
var result = ModelDirective.GetModelType(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Type1", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirective_GetModelType_DefaultsToDynamic()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@" ");
|
||||
|
||||
var engine = CreateRuntimeEngine();
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
var result = ModelDirective.GetModelType(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("dynamic", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirectivePass_Execute_ReplacesTModelInBaseType()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inherits BaseType<TModel>
|
||||
@model Type1
|
||||
");
|
||||
|
||||
var engine = CreateRuntimeEngine();
|
||||
var pass = new ModelDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal("BaseType<Type1>", @class.BaseType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirectivePass_Execute_ReplacesTModelInBaseType_DifferentOrdering()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@model Type1
|
||||
@inherits BaseType<TModel>
|
||||
@model Type2
|
||||
");
|
||||
|
||||
var engine = CreateRuntimeEngine();
|
||||
var pass = new ModelDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal("BaseType<Type1>", @class.BaseType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirectivePass_Execute_NoOpWithoutTModel()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inherits BaseType
|
||||
@model Type1
|
||||
");
|
||||
|
||||
var engine = CreateRuntimeEngine();
|
||||
var pass = new ModelDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal("BaseType", @class.BaseType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirectivePass_Execute_ReplacesTModelInBaseType_DefaultDynamic()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inherits BaseType<TModel>
|
||||
");
|
||||
|
||||
var engine = CreateRuntimeEngine();
|
||||
var pass = new ModelDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal("BaseType<dynamic>", @class.BaseType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirectivePass_DesignTime_AddsTModelUsingDirective()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inherits BaseType<TModel>
|
||||
");
|
||||
|
||||
var engine = CreateDesignTimeEngine();
|
||||
var pass = new ModelDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal("BaseType<dynamic>", @class.BaseType);
|
||||
|
||||
var @namespace = FindNamespaceNode(irDocument);
|
||||
var usingNode = Assert.IsType<UsingDirectiveIntermediateNode>(@namespace.Children[0]);
|
||||
Assert.Equal($"TModel = global::{typeof(object).FullName}", usingNode.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelDirectivePass_DesignTime_WithModel_AddsTModelUsingDirective()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@inherits BaseType<TModel>
|
||||
@model SomeType
|
||||
");
|
||||
|
||||
var engine = CreateDesignTimeEngine();
|
||||
var pass = new ModelDirective.Pass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var @class = FindClassNode(irDocument);
|
||||
Assert.NotNull(@class);
|
||||
Assert.Equal("BaseType<SomeType>", @class.BaseType);
|
||||
|
||||
var @namespace = FindNamespaceNode(irDocument);
|
||||
var usingNode = Assert.IsType<UsingDirectiveIntermediateNode>(@namespace.Children[0]);
|
||||
Assert.Equal($"TModel = global::System.Object", usingNode.Content);
|
||||
}
|
||||
|
||||
private RazorCodeDocument CreateDocument(string content)
|
||||
{
|
||||
var source = RazorSourceDocument.Create(content, "test.cshtml");
|
||||
return RazorCodeDocument.Create(source);
|
||||
}
|
||||
|
||||
private ClassDeclarationIntermediateNode FindClassNode(IntermediateNode node)
|
||||
{
|
||||
var visitor = new ClassNodeVisitor();
|
||||
visitor.Visit(node);
|
||||
return visitor.Node;
|
||||
}
|
||||
|
||||
private NamespaceDeclarationIntermediateNode FindNamespaceNode(IntermediateNode node)
|
||||
{
|
||||
var visitor = new NamespaceNodeVisitor();
|
||||
visitor.Visit(node);
|
||||
return visitor.Node;
|
||||
}
|
||||
|
||||
private RazorEngine CreateRuntimeEngine()
|
||||
{
|
||||
return CreateEngineCore();
|
||||
}
|
||||
|
||||
private RazorEngine CreateDesignTimeEngine()
|
||||
{
|
||||
return CreateEngineCore(designTime: true);
|
||||
}
|
||||
|
||||
private RazorEngine CreateEngineCore(bool designTime = false)
|
||||
{
|
||||
return CreateProjectEngine(b =>
|
||||
{
|
||||
// Notice we're not registering the ModelDirective.Pass here so we can run it on demand.
|
||||
b.AddDirective(ModelDirective.Directive);
|
||||
|
||||
// There's some special interaction with the inherits directive
|
||||
InheritsDirective.Register(b);
|
||||
|
||||
b.Features.Add(new DesignTimeOptionsFeature(designTime));
|
||||
}).Engine;
|
||||
}
|
||||
|
||||
private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument)
|
||||
{
|
||||
for (var i = 0; i < engine.Phases.Count; i++)
|
||||
{
|
||||
var phase = engine.Phases[i];
|
||||
phase.Execute(codeDocument);
|
||||
|
||||
if (phase is IRazorDocumentClassifierPhase)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// InheritsDirectivePass needs to run before ModelDirective.
|
||||
var pass = new InheritsDirectivePass()
|
||||
{
|
||||
Engine = engine
|
||||
};
|
||||
pass.Execute(codeDocument, codeDocument.GetDocumentIntermediateNode());
|
||||
|
||||
return codeDocument.GetDocumentIntermediateNode();
|
||||
}
|
||||
|
||||
private string GetCSharpContent(IntermediateNode node)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
var child = node.Children[i] as IntermediateToken;
|
||||
if (child.Kind == TokenKind.CSharp)
|
||||
{
|
||||
builder.Append(child.Content);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private class ClassNodeVisitor : IntermediateNodeWalker
|
||||
{
|
||||
public ClassDeclarationIntermediateNode Node { get; set; }
|
||||
|
||||
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
|
||||
{
|
||||
Node = node;
|
||||
}
|
||||
}
|
||||
|
||||
private class NamespaceNodeVisitor : IntermediateNodeWalker
|
||||
{
|
||||
public NamespaceDeclarationIntermediateNode Node { get; set; }
|
||||
|
||||
public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node)
|
||||
{
|
||||
Node = node;
|
||||
}
|
||||
}
|
||||
|
||||
private class DesignTimeOptionsFeature : IConfigureRazorParserOptionsFeature, IConfigureRazorCodeGenerationOptionsFeature
|
||||
{
|
||||
private bool _designTime;
|
||||
|
||||
public DesignTimeOptionsFeature(bool designTime)
|
||||
{
|
||||
_designTime = designTime;
|
||||
}
|
||||
|
||||
public int Order { get; }
|
||||
|
||||
public RazorEngine Engine { get; set; }
|
||||
|
||||
public void Configure(RazorParserOptionsBuilder options)
|
||||
{
|
||||
options.SetDesignTime(_designTime);
|
||||
}
|
||||
|
||||
public void Configure(RazorCodeGenerationOptionsBuilder options)
|
||||
{
|
||||
options.SetDesignTime(_designTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using Microsoft.AspNetCore.Razor.Language.Legacy;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class ModelExpressionPassTest
|
||||
{
|
||||
[Fact]
|
||||
public void ModelExpressionPass_NonModelExpressionProperty_Ignored()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = CreateDocument(@"
|
||||
@addTagHelper TestTagHelper, TestAssembly
|
||||
<p foo=""17"">");
|
||||
|
||||
var tagHelpers = new[]
|
||||
{
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly")
|
||||
.BoundAttributeDescriptor(attribute =>
|
||||
attribute
|
||||
.Name("Foo")
|
||||
.TypeName("System.Int32"))
|
||||
.TagMatchingRuleDescriptor(rule =>
|
||||
rule.RequireTagName("p"))
|
||||
.Build()
|
||||
};
|
||||
|
||||
var engine = CreateEngine(tagHelpers);
|
||||
var pass = new ModelExpressionPass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var tagHelper = FindTagHelperNode(irDocument);
|
||||
var setProperty = tagHelper.Children.OfType<TagHelperPropertyIntermediateNode>().Single();
|
||||
|
||||
var token = Assert.IsType<IntermediateToken>(Assert.Single(setProperty.Children));
|
||||
Assert.True(token.IsCSharp);
|
||||
Assert.Equal("17", token.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelExpressionPass_ModelExpressionProperty_SimpleExpression()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Using \r\n here because we verify line mappings
|
||||
var codeDocument = CreateDocument(
|
||||
"@addTagHelper TestTagHelper, TestAssembly\r\n<p foo=\"Bar\">");
|
||||
|
||||
var tagHelpers = new[]
|
||||
{
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly")
|
||||
.BoundAttributeDescriptor(attribute =>
|
||||
attribute
|
||||
.Name("Foo")
|
||||
.TypeName("Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression"))
|
||||
.TagMatchingRuleDescriptor(rule =>
|
||||
rule.RequireTagName("p"))
|
||||
.Build()
|
||||
};
|
||||
|
||||
var engine = CreateEngine(tagHelpers);
|
||||
var pass = new ModelExpressionPass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var tagHelper = FindTagHelperNode(irDocument);
|
||||
var setProperty = tagHelper.Children.OfType<TagHelperPropertyIntermediateNode>().Single();
|
||||
|
||||
var expression = Assert.IsType<CSharpExpressionIntermediateNode>(Assert.Single(setProperty.Children));
|
||||
Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Bar)", GetCSharpContent(expression));
|
||||
|
||||
var originalNode = Assert.IsType<IntermediateToken>(expression.Children[2]);
|
||||
Assert.Equal(TokenKind.CSharp, originalNode.Kind);
|
||||
Assert.Equal("Bar", originalNode.Content);
|
||||
Assert.Equal(new SourceSpan("test.cshtml", 51, 1, 8, 3), originalNode.Source.Value);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ModelExpressionPass_ModelExpressionProperty_ComplexExpression()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
// Using \r\n here because we verify line mappings
|
||||
var codeDocument = CreateDocument(
|
||||
"@addTagHelper TestTagHelper, TestAssembly\r\n<p foo=\"@Bar\">");
|
||||
|
||||
var tagHelpers = new[]
|
||||
{
|
||||
TagHelperDescriptorBuilder.Create("TestTagHelper", "TestAssembly")
|
||||
.BoundAttributeDescriptor(attribute =>
|
||||
attribute
|
||||
.Name("Foo")
|
||||
.TypeName("Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression"))
|
||||
.TagMatchingRuleDescriptor(rule =>
|
||||
rule.RequireTagName("p"))
|
||||
.Build()
|
||||
};
|
||||
|
||||
var engine = CreateEngine(tagHelpers);
|
||||
var pass = new ModelExpressionPass()
|
||||
{
|
||||
Engine = engine,
|
||||
};
|
||||
|
||||
var irDocument = CreateIRDocument(engine, codeDocument);
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
var tagHelper = FindTagHelperNode(irDocument);
|
||||
var setProperty = tagHelper.Children.OfType<TagHelperPropertyIntermediateNode>().Single();
|
||||
|
||||
var expression = Assert.IsType<CSharpExpressionIntermediateNode>(Assert.Single(setProperty.Children));
|
||||
Assert.Equal("ModelExpressionProvider.CreateModelExpression(ViewData, __model => Bar)", GetCSharpContent(expression));
|
||||
|
||||
var originalNode = Assert.IsType<IntermediateToken>(expression.Children[1]);
|
||||
Assert.Equal(TokenKind.CSharp, originalNode.Kind);
|
||||
Assert.Equal("Bar", originalNode.Content);
|
||||
Assert.Equal(new SourceSpan("test.cshtml", 52, 1, 9, 3), originalNode.Source.Value);
|
||||
}
|
||||
|
||||
private RazorCodeDocument CreateDocument(string content)
|
||||
{
|
||||
var source = RazorSourceDocument.Create(content, "test.cshtml");
|
||||
return RazorCodeDocument.Create(source);
|
||||
}
|
||||
|
||||
private RazorEngine CreateEngine(params TagHelperDescriptor[] tagHelpers)
|
||||
{
|
||||
return RazorProjectEngine.Create(b =>
|
||||
{
|
||||
b.Features.Add(new TestTagHelperFeature(tagHelpers));
|
||||
}).Engine;
|
||||
}
|
||||
|
||||
private DocumentIntermediateNode CreateIRDocument(RazorEngine engine, RazorCodeDocument codeDocument)
|
||||
{
|
||||
for (var i = 0; i < engine.Phases.Count; i++)
|
||||
{
|
||||
var phase = engine.Phases[i];
|
||||
phase.Execute(codeDocument);
|
||||
|
||||
if (phase is IRazorDirectiveClassifierPhase)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return codeDocument.GetDocumentIntermediateNode();
|
||||
}
|
||||
|
||||
private TagHelperIntermediateNode FindTagHelperNode(IntermediateNode node)
|
||||
{
|
||||
var visitor = new TagHelperNodeVisitor();
|
||||
visitor.Visit(node);
|
||||
return visitor.Node;
|
||||
}
|
||||
|
||||
private string GetCSharpContent(IntermediateNode node)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
for (var i = 0; i < node.Children.Count; i++)
|
||||
{
|
||||
var child = node.Children[i] as IntermediateToken;
|
||||
if (child.Kind == TokenKind.CSharp)
|
||||
{
|
||||
builder.Append(child.Content);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private class TagHelperNodeVisitor : IntermediateNodeWalker
|
||||
{
|
||||
public TagHelperIntermediateNode Node { get; set; }
|
||||
|
||||
public override void VisitTagHelper(TagHelperIntermediateNode node)
|
||||
{
|
||||
Node = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// 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.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class MvcImportProjectFeatureTest
|
||||
{
|
||||
[Fact]
|
||||
public void AddDefaultDirectivesImport_AddsSingleDynamicImport()
|
||||
{
|
||||
// Arrange
|
||||
var imports = new List<RazorProjectItem>();
|
||||
|
||||
// Act
|
||||
MvcImportProjectFeature.AddDefaultDirectivesImport(imports);
|
||||
|
||||
// Assert
|
||||
var import = Assert.Single(imports);
|
||||
Assert.Null(import.FilePath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddHierarchicalImports_AddsViewImportSourceDocumentsOnDisk()
|
||||
{
|
||||
// Arrange
|
||||
var imports = new List<RazorProjectItem>();
|
||||
var projectItem = new TestRazorProjectItem("/Contact/Index.cshtml");
|
||||
var testFileSystem = new TestRazorProjectFileSystem(new[]
|
||||
{
|
||||
new TestRazorProjectItem("/Index.cshtml"),
|
||||
new TestRazorProjectItem("/_ViewImports.cshtml"),
|
||||
new TestRazorProjectItem("/Contact/_ViewImports.cshtml"),
|
||||
projectItem,
|
||||
});
|
||||
var mvcImportFeature = new MvcImportProjectFeature()
|
||||
{
|
||||
ProjectEngine = Mock.Of<RazorProjectEngine>(projectEngine => projectEngine.FileSystem == testFileSystem)
|
||||
};
|
||||
|
||||
// Act
|
||||
mvcImportFeature.AddHierarchicalImports(projectItem, imports);
|
||||
|
||||
// Assert
|
||||
Assert.Collection(imports,
|
||||
import => Assert.Equal("/_ViewImports.cshtml", import.FilePath),
|
||||
import => Assert.Equal("/Contact/_ViewImports.cshtml", import.FilePath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddHierarchicalImports_AddsViewImportSourceDocumentsNotOnDisk()
|
||||
{
|
||||
// Arrange
|
||||
var imports = new List<RazorProjectItem>();
|
||||
var projectItem = new TestRazorProjectItem("/Pages/Contact/Index.cshtml");
|
||||
var testFileSystem = new TestRazorProjectFileSystem(new[] { projectItem });
|
||||
var mvcImportFeature = new MvcImportProjectFeature()
|
||||
{
|
||||
ProjectEngine = Mock.Of<RazorProjectEngine>(projectEngine => projectEngine.FileSystem == testFileSystem)
|
||||
};
|
||||
|
||||
// Act
|
||||
mvcImportFeature.AddHierarchicalImports(projectItem, imports);
|
||||
|
||||
// Assert
|
||||
Assert.Collection(imports,
|
||||
import => Assert.Equal("/_ViewImports.cshtml", import.FilePath),
|
||||
import => Assert.Equal("/Pages/_ViewImports.cshtml", import.FilePath),
|
||||
import => Assert.Equal("/Pages/Contact/_ViewImports.cshtml", import.FilePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// 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.
|
||||
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
|
||||
{
|
||||
internal static class MvcShim
|
||||
{
|
||||
public static readonly string AssemblyName = "Microsoft.AspNetCore.Razor.Test.MvcShim.Version1_X";
|
||||
|
||||
private static Assembly _assembly;
|
||||
private static CSharpCompilation _baseCompilation;
|
||||
|
||||
public static Assembly Assembly
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_assembly == null)
|
||||
{
|
||||
var filePath = Path.Combine(Directory.GetCurrentDirectory(), AssemblyName + ".dll");
|
||||
_assembly = Assembly.LoadFrom(filePath);
|
||||
}
|
||||
|
||||
return _assembly;
|
||||
}
|
||||
}
|
||||
|
||||
public static CSharpCompilation BaseCompilation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_baseCompilation == null)
|
||||
{
|
||||
_baseCompilation = TestCompilation.Create(Assembly);
|
||||
}
|
||||
|
||||
return _baseCompilation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,264 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Microsoft.AspNetCore.Razor.Language.Intermediate;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class MvcViewDocumentClassifierPassTest : RazorProjectEngineTestBase
|
||||
{
|
||||
protected override RazorLanguageVersion Version => RazorLanguageVersion.Version_1_1;
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_SetsDocumentKind()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("mvc.1.0.view", irDocument.DocumentKind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_NoOpsIfDocumentKindIsAlreadySet()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
irDocument.DocumentKind = "some-value";
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("some-value", irDocument.DocumentKind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_SetsNamespace()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("AspNetCore", visitor.Namespace.Content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_SetsClass()
|
||||
{
|
||||
// Arrange
|
||||
var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: "Test.cshtml");
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>", visitor.Class.BaseType);
|
||||
Assert.Equal(new[] { "public" }, visitor.Class.Modifiers);
|
||||
Assert.Equal("Test", visitor.Class.ClassName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_NullFilePath_SetsClass()
|
||||
{
|
||||
// Arrange
|
||||
var properties = new RazorSourceDocumentProperties(filePath: null, relativePath: null);
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<TModel>", visitor.Class.BaseType);
|
||||
Assert.Equal(new[] { "public" }, visitor.Class.Modifiers);
|
||||
Assert.Equal("AspNetCore_d9f877a857a7e9928eac04d09a59f25967624155", visitor.Class.ClassName);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/Views/Home/Index.cshtml", "_Views_Home_Index")]
|
||||
[InlineData("/Areas/MyArea/Views/Home/About.cshtml", "_Areas_MyArea_Views_Home_About")]
|
||||
public void MvcViewDocumentClassifierPass_UsesRelativePathToGenerateTypeName(string relativePath, string expected)
|
||||
{
|
||||
// Arrange
|
||||
var properties = new RazorSourceDocumentProperties(filePath: "ignored", relativePath: relativePath);
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expected, visitor.Class.ClassName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_UsesAbsolutePath_IfRelativePathIsNotSet()
|
||||
{
|
||||
// Arrange
|
||||
var properties = new RazorSourceDocumentProperties(filePath: @"x::\application\Views\Home\Index.cshtml", relativePath: null);
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", properties));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("x___application_Views_Home_Index", visitor.Class.ClassName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_SanitizesClassName()
|
||||
{
|
||||
// Arrange
|
||||
var properties = new RazorSourceDocumentProperties(filePath: @"x:\Test.cshtml", relativePath: "path.with+invalid-chars");
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("@page", properties));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("path_with_invalid_chars", visitor.Class.ClassName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MvcViewDocumentClassifierPass_SetsUpExecuteAsyncMethod()
|
||||
{
|
||||
// Arrange
|
||||
var codeDocument = RazorCodeDocument.Create(RazorSourceDocument.Create("some-content", "Test.cshtml"));
|
||||
|
||||
var projectEngine = CreateProjectEngine();
|
||||
var irDocument = CreateIRDocument(projectEngine, codeDocument);
|
||||
var pass = new MvcViewDocumentClassifierPass
|
||||
{
|
||||
Engine = projectEngine.Engine
|
||||
};
|
||||
|
||||
// Act
|
||||
pass.Execute(codeDocument, irDocument);
|
||||
var visitor = new Visitor();
|
||||
visitor.Visit(irDocument);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("ExecuteAsync", visitor.Method.MethodName);
|
||||
Assert.Equal("global::System.Threading.Tasks.Task", visitor.Method.ReturnType);
|
||||
Assert.Equal(new[] { "public", "async", "override" }, visitor.Method.Modifiers);
|
||||
}
|
||||
|
||||
private static DocumentIntermediateNode CreateIRDocument(RazorProjectEngine engine, RazorCodeDocument codeDocument)
|
||||
{
|
||||
for (var i = 0; i < engine.Phases.Count; i++)
|
||||
{
|
||||
var phase = engine.Phases[i];
|
||||
phase.Execute(codeDocument);
|
||||
|
||||
if (phase is IRazorIntermediateNodeLoweringPhase)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return codeDocument.GetDocumentIntermediateNode();
|
||||
}
|
||||
|
||||
private class Visitor : IntermediateNodeWalker
|
||||
{
|
||||
public NamespaceDeclarationIntermediateNode Namespace { get; private set; }
|
||||
|
||||
public ClassDeclarationIntermediateNode Class { get; private set; }
|
||||
|
||||
public MethodDeclarationIntermediateNode Method { get; private set; }
|
||||
|
||||
public override void VisitMethodDeclaration(MethodDeclarationIntermediateNode node)
|
||||
{
|
||||
Method = node;
|
||||
}
|
||||
|
||||
public override void VisitNamespaceDeclaration(NamespaceDeclarationIntermediateNode node)
|
||||
{
|
||||
Namespace = node;
|
||||
base.VisitNamespaceDeclaration(node);
|
||||
}
|
||||
|
||||
public override void VisitClassDeclaration(ClassDeclarationIntermediateNode node)
|
||||
{
|
||||
Class = node;
|
||||
base.VisitClassDeclaration(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// 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.
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public static class SourceMappingsSerializer
|
||||
{
|
||||
public static string Serialize(RazorCSharpDocument csharpDocument, RazorSourceDocument sourceDocument)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
var sourceFilePath = sourceDocument.FilePath;
|
||||
var charBuffer = new char[sourceDocument.Length];
|
||||
sourceDocument.CopyTo(0, charBuffer, 0, sourceDocument.Length);
|
||||
var sourceContent = new string(charBuffer);
|
||||
|
||||
for (var i = 0; i < csharpDocument.SourceMappings.Count; i++)
|
||||
{
|
||||
var sourceMapping = csharpDocument.SourceMappings[i];
|
||||
if (!string.Equals(sourceMapping.OriginalSpan.FilePath, sourceFilePath, StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
builder.Append("Source Location: ");
|
||||
AppendMappingLocation(builder, sourceMapping.OriginalSpan, sourceContent);
|
||||
|
||||
builder.Append("Generated Location: ");
|
||||
AppendMappingLocation(builder, sourceMapping.GeneratedSpan, csharpDocument.GeneratedCode);
|
||||
|
||||
builder.AppendLine();
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static void AppendMappingLocation(StringBuilder builder, SourceSpan location, string content)
|
||||
{
|
||||
builder
|
||||
.AppendLine(location.ToString())
|
||||
.Append("|");
|
||||
|
||||
for (var i = 0; i < location.Length; i++)
|
||||
{
|
||||
builder.Append(content[location.AbsoluteIndex + i]);
|
||||
}
|
||||
|
||||
builder.AppendLine("|");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
// 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.
|
||||
|
||||
using Microsoft.AspNetCore.Razor.Language;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X
|
||||
{
|
||||
public class TagHelperDescriptorExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public void IsViewComponentKind_ReturnsFalse_ForNonVCTHDescriptor()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelper = CreateTagHelperDescriptor();
|
||||
|
||||
// Act
|
||||
var result = tagHelper.IsViewComponentKind();
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsViewComponentKind_ReturnsTrue_ForVCTHDescriptor()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelper = CreateViewComponentTagHelperDescriptor();
|
||||
|
||||
// Act
|
||||
var result = tagHelper.IsViewComponentKind();
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetViewComponentName_ReturnsNull_ForNonVCTHDescriptor()
|
||||
{
|
||||
//Arrange
|
||||
var tagHelper = CreateTagHelperDescriptor();
|
||||
|
||||
// Act
|
||||
var result = tagHelper.GetViewComponentName();
|
||||
|
||||
// Assert
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetViewComponentName_ReturnsName_ForVCTHDescriptor()
|
||||
{
|
||||
// Arrange
|
||||
var tagHelper = CreateViewComponentTagHelperDescriptor("ViewComponentName");
|
||||
|
||||
// Act
|
||||
var result = tagHelper.GetViewComponentName();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("ViewComponentName", result);
|
||||
}
|
||||
|
||||
private static TagHelperDescriptor CreateTagHelperDescriptor()
|
||||
{
|
||||
var tagHelper = TagHelperDescriptorBuilder.Create("TypeName", "AssemblyName")
|
||||
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("tag-name"))
|
||||
.Build();
|
||||
|
||||
return tagHelper;
|
||||
}
|
||||
|
||||
private static TagHelperDescriptor CreateViewComponentTagHelperDescriptor(string name = "ViewComponentName")
|
||||
{
|
||||
var tagHelper = TagHelperDescriptorBuilder.Create(ViewComponentTagHelperConventions.Kind, "TypeName", "AssemblyName")
|
||||
.TagMatchingRuleDescriptor(rule => rule.RequireTagName("tag-name"))
|
||||
.AddMetadata(ViewComponentTagHelperMetadata.Name, name)
|
||||
.Build();
|
||||
|
||||
return tagHelper;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<div class="@this.ToString()">
|
||||
Hello world
|
||||
@string.Format("{0}", "Hello")
|
||||
</div>
|
||||
@{
|
||||
var cls = "foo";
|
||||
}
|
||||
<p class="@if(cls != null) { @cls }" />
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
__o = this.ToString();
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
__o = string.Format("{0}", "Hello");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
|
||||
var cls = "foo";
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
if(cls != null) {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
__o = cls;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (0:0,0 [4] Basic.cshtml)
|
||||
IntermediateToken - (0:0,0 [4] Basic.cshtml) - Html - <div
|
||||
HtmlAttribute - (4:0,4 [25] Basic.cshtml) - class=" - "
|
||||
CSharpExpressionAttributeValue - (12:0,12 [16] Basic.cshtml) -
|
||||
IntermediateToken - (13:0,13 [15] Basic.cshtml) - CSharp - this.ToString()
|
||||
HtmlContent - (29:0,29 [24] Basic.cshtml)
|
||||
IntermediateToken - (29:0,29 [1] Basic.cshtml) - Html - >
|
||||
IntermediateToken - (30:0,30 [23] Basic.cshtml) - Html - \n Hello world\n
|
||||
CSharpExpression - (54:2,5 [29] Basic.cshtml)
|
||||
IntermediateToken - (54:2,5 [29] Basic.cshtml) - CSharp - string.Format("{0}", "Hello")
|
||||
HtmlContent - (83:2,34 [10] Basic.cshtml)
|
||||
IntermediateToken - (83:2,34 [2] Basic.cshtml) - Html - \n
|
||||
IntermediateToken - (85:3,0 [6] Basic.cshtml) - Html - </div>
|
||||
IntermediateToken - (91:3,6 [2] Basic.cshtml) - Html - \n
|
||||
CSharpCode - (95:4,2 [25] Basic.cshtml)
|
||||
IntermediateToken - (95:4,2 [25] Basic.cshtml) - CSharp - \n var cls = "foo";\n
|
||||
HtmlContent - (123:7,0 [2] Basic.cshtml)
|
||||
IntermediateToken - (123:7,0 [2] Basic.cshtml) - Html - <p
|
||||
HtmlAttribute - (125:7,2 [34] Basic.cshtml) - class=" - "
|
||||
CSharpCodeAttributeValue - (133:7,10 [25] Basic.cshtml) -
|
||||
IntermediateToken - (134:7,11 [18] Basic.cshtml) - CSharp - if(cls != null) {
|
||||
CSharpExpression - (153:7,30 [3] Basic.cshtml)
|
||||
IntermediateToken - (153:7,30 [3] Basic.cshtml) - CSharp - cls
|
||||
IntermediateToken - (156:7,33 [2] Basic.cshtml) - CSharp - }
|
||||
HtmlContent - (159:7,36 [5] Basic.cshtml)
|
||||
IntermediateToken - (159:7,36 [1] Basic.cshtml) - Html -
|
||||
IntermediateToken - (160:7,37 [2] Basic.cshtml) - Html - />
|
||||
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
Source Location: (13:0,13 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
||||
|this.ToString()|
|
||||
Generated Location: (1030:26,13 [15] )
|
||||
|this.ToString()|
|
||||
|
||||
Source Location: (54:2,5 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
||||
|string.Format("{0}", "Hello")|
|
||||
Generated Location: (1166:31,6 [29] )
|
||||
|string.Format("{0}", "Hello")|
|
||||
|
||||
Source Location: (95:4,2 [25] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
||||
|
|
||||
var cls = "foo";
|
||||
|
|
||||
Generated Location: (1312:36,2 [25] )
|
||||
|
|
||||
var cls = "foo";
|
||||
|
|
||||
|
||||
Source Location: (134:7,11 [18] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
||||
|if(cls != null) { |
|
||||
Generated Location: (1460:42,11 [18] )
|
||||
|if(cls != null) { |
|
||||
|
||||
Source Location: (153:7,30 [3] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
||||
|cls|
|
||||
Generated Location: (1622:47,30 [3] )
|
||||
|cls|
|
||||
|
||||
Source Location: (156:7,33 [2] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml)
|
||||
| }|
|
||||
Generated Location: (1773:52,33 [2] )
|
||||
| }|
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "4120ddad9d4353ed260e0585fe71080d78ff8ab3"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
BeginContext(0, 4, true);
|
||||
WriteLiteral("<div");
|
||||
EndContext();
|
||||
BeginWriteAttribute("class", " class=\"", 4, "\"", 28, 1);
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
WriteAttributeValue("", 12, this.ToString(), 12, 16, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
BeginContext(29, 24, true);
|
||||
WriteLiteral(">\r\n Hello world\r\n ");
|
||||
EndContext();
|
||||
BeginContext(54, 29, false);
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
Write(string.Format("{0}", "Hello"));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndContext();
|
||||
BeginContext(83, 10, true);
|
||||
WriteLiteral("\r\n</div>\r\n");
|
||||
EndContext();
|
||||
#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
|
||||
var cls = "foo";
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
BeginContext(123, 2, true);
|
||||
WriteLiteral("<p");
|
||||
EndContext();
|
||||
BeginWriteAttribute("class", " class=\"", 125, "\"", 158, 1);
|
||||
WriteAttributeValue("", 133, new Microsoft.AspNetCore.Mvc.Razor.HelperResult(async(__razor_attribute_value_writer) => {
|
||||
PushWriter(__razor_attribute_value_writer);
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
if(cls != null) {
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
BeginContext(153, 3, false);
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
Write(cls);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndContext();
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Basic.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
PopWriter();
|
||||
}
|
||||
), 133, 25, false);
|
||||
EndWriteAttribute();
|
||||
BeginContext(159, 5, true);
|
||||
WriteLiteral(" />\r\n");
|
||||
EndContext();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Basic_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(0, 4, true);
|
||||
HtmlContent - (0:0,0 [4] Basic.cshtml)
|
||||
IntermediateToken - (0:0,0 [4] Basic.cshtml) - Html - <div
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
HtmlAttribute - (4:0,4 [25] Basic.cshtml) - class=" - "
|
||||
CSharpExpressionAttributeValue - (12:0,12 [16] Basic.cshtml) -
|
||||
IntermediateToken - (13:0,13 [15] Basic.cshtml) - CSharp - this.ToString()
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(29, 24, true);
|
||||
HtmlContent - (29:0,29 [24] Basic.cshtml)
|
||||
IntermediateToken - (29:0,29 [1] Basic.cshtml) - Html - >
|
||||
IntermediateToken - (30:0,30 [19] Basic.cshtml) - Html - \n Hello world\n
|
||||
IntermediateToken - (49:2,0 [4] Basic.cshtml) - Html -
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(54, 29, false);
|
||||
CSharpExpression - (54:2,5 [29] Basic.cshtml)
|
||||
IntermediateToken - (54:2,5 [29] Basic.cshtml) - CSharp - string.Format("{0}", "Hello")
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(83, 10, true);
|
||||
HtmlContent - (83:2,34 [10] Basic.cshtml)
|
||||
IntermediateToken - (83:2,34 [2] Basic.cshtml) - Html - \n
|
||||
IntermediateToken - (85:3,0 [6] Basic.cshtml) - Html - </div>
|
||||
IntermediateToken - (91:3,6 [2] Basic.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode - (95:4,2 [25] Basic.cshtml)
|
||||
IntermediateToken - (95:4,2 [25] Basic.cshtml) - CSharp - \n var cls = "foo";\n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(123, 2, true);
|
||||
HtmlContent - (123:7,0 [2] Basic.cshtml)
|
||||
IntermediateToken - (123:7,0 [2] Basic.cshtml) - Html - <p
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
HtmlAttribute - (125:7,2 [34] Basic.cshtml) - class=" - "
|
||||
CSharpCodeAttributeValue - (133:7,10 [25] Basic.cshtml) -
|
||||
IntermediateToken - (134:7,11 [18] Basic.cshtml) - CSharp - if(cls != null) {
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(153, 3, false);
|
||||
CSharpExpression - (153:7,30 [3] Basic.cshtml)
|
||||
IntermediateToken - (153:7,30 [3] Basic.cshtml) - CSharp - cls
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
IntermediateToken - (156:7,33 [2] Basic.cshtml) - CSharp - }
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(159, 5, true);
|
||||
HtmlContent - (159:7,36 [5] Basic.cshtml)
|
||||
IntermediateToken - (159:7,36 [3] Basic.cshtml) - Html - />
|
||||
IntermediateToken - (162:7,39 [2] Basic.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
@* These test files validate that end-to-end, incomplete directives don't throw. *@
|
||||
|
||||
@model
|
||||
@model
|
||||
|
||||
@inject
|
||||
@inject
|
||||
@inject MyService<TModel>
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 7 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 8 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml"
|
||||
MyService<TModel> __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ1013: The 'model' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ2001: The 'model' directive may only occur once per document.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ1013: The 'model' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ1013: The 'inject' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ1013: The 'inject' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ1015: The 'inject' directive expects an identifier.
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (102:3,7 [0] IncompleteDirectives.cshtml) -
|
||||
DirectiveToken - (123:6,8 [0] IncompleteDirectives.cshtml) -
|
||||
DirectiveToken - (133:7,8 [17] IncompleteDirectives.cshtml) - MyService<TModel>
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (85:1,0 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (85:1,0 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
MalformedDirective - (87:2,0 [6] IncompleteDirectives.cshtml) - model
|
||||
HtmlContent - (93:2,6 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (93:2,6 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
MalformedDirective - (95:3,0 [7] IncompleteDirectives.cshtml) - model
|
||||
DirectiveToken - (102:3,7 [0] IncompleteDirectives.cshtml) -
|
||||
HtmlContent - (102:3,7 [4] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (102:3,7 [4] IncompleteDirectives.cshtml) - Html - \n\n
|
||||
MalformedDirective - (106:5,0 [7] IncompleteDirectives.cshtml) - inject
|
||||
HtmlContent - (113:5,7 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (113:5,7 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
MalformedDirective - (115:6,0 [8] IncompleteDirectives.cshtml) - inject
|
||||
DirectiveToken - (123:6,8 [0] IncompleteDirectives.cshtml) -
|
||||
HtmlContent - (123:6,8 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (123:6,8 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
MalformedDirective - (125:7,0 [25] IncompleteDirectives.cshtml) - inject
|
||||
DirectiveToken - (133:7,8 [17] IncompleteDirectives.cshtml) - MyService<TModel>
|
||||
HtmlContent - (150:7,25 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (150:7,25 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
Source Location: (102:3,7 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml)
|
||||
||
|
||||
Generated Location: (776:19,0 [0] )
|
||||
||
|
||||
|
||||
Source Location: (123:6,8 [0] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml)
|
||||
||
|
||||
Generated Location: (966:27,0 [0] )
|
||||
||
|
||||
|
||||
Source Location: (133:7,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml)
|
||||
|MyService<TModel>|
|
||||
Generated Location: (1156:35,0 [17] )
|
||||
|MyService<TModel>|
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "844eb91b909a14b78feddd5e6866563b5a75e021"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
BeginContext(83, 4, true);
|
||||
WriteLiteral("\r\n\r\n");
|
||||
EndContext();
|
||||
BeginContext(93, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(102, 4, true);
|
||||
WriteLiteral("\r\n\r\n");
|
||||
EndContext();
|
||||
BeginContext(113, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(123, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(150, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(3,7): Error RZ9999: The 'model' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,1): Error RZ9999: The 'model' directive may only occur once per document.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(4,8): Error RZ9999: The 'model' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(6,8): Error RZ9999: The 'inject' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(7,9): Error RZ9999: The 'inject' directive expects a type name.
|
||||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/IncompleteDirectives.cshtml(8,26): Error RZ9999: The 'inject' directive expects an identifier.
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_IncompleteDirectives_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(83, 4, true);
|
||||
HtmlContent - (83:0,83 [4] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (83:0,83 [4] IncompleteDirectives.cshtml) - Html - \n\n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
MalformedDirective - (87:2,0 [6] IncompleteDirectives.cshtml) - model
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(93, 2, true);
|
||||
HtmlContent - (93:2,6 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (93:2,6 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
MalformedDirective - (95:3,0 [7] IncompleteDirectives.cshtml) - model
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(102, 4, true);
|
||||
HtmlContent - (102:3,7 [4] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (102:3,7 [4] IncompleteDirectives.cshtml) - Html - \n\n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
MalformedDirective - (106:5,0 [7] IncompleteDirectives.cshtml) - inject
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(113, 2, true);
|
||||
HtmlContent - (113:5,7 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (113:5,7 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
MalformedDirective - (115:6,0 [8] IncompleteDirectives.cshtml) - inject
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(123, 2, true);
|
||||
HtmlContent - (123:6,8 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (123:6,8 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
MalformedDirective - (125:7,0 [25] IncompleteDirectives.cshtml) - inject
|
||||
DirectiveToken - (133:7,8 [17] IncompleteDirectives.cshtml) - MyService<TModel>
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(150, 2, true);
|
||||
HtmlContent - (150:7,25 [2] IncompleteDirectives.cshtml)
|
||||
IntermediateToken - (150:7,25 [2] IncompleteDirectives.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@inherits MyBasePageForViews<TModel>
|
||||
@model MyModel
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel : MyBasePageForViews<MyModel>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml"
|
||||
MyBasePageForViews<TModel> __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml"
|
||||
MyModel __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<MyModel> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel - MyBasePageForViews<MyModel> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (10:0,10 [26] InheritsViewModel.cshtml) - MyBasePageForViews<TModel>
|
||||
DirectiveToken - (45:1,7 [7] InheritsViewModel.cshtml) - MyModel
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
Source Location: (10:0,10 [26] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml)
|
||||
|MyBasePageForViews<TModel>|
|
||||
Generated Location: (740:19,0 [26] )
|
||||
|MyBasePageForViews<TModel>|
|
||||
|
||||
Source Location: (45:1,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml)
|
||||
|MyModel|
|
||||
Generated Location: (976:27,0 [7] )
|
||||
|MyModel|
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsViewModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "91cf923452a86b2906083cb0236d6d5b3bc528ef"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml : MyBasePageForViews<MyModel>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<MyModel> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsViewModel_cshtml - MyBasePageForViews<MyModel> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1 @@
|
|||
@model MyModel
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports : MyBasePageForViews<MyModel>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml"
|
||||
MyModel __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<MyModel> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports - MyBasePageForViews<MyModel> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (10:0,10 [26] TestFiles\IntegrationTests\CodeGenerationIntegrationTest\_ViewImports.cshtml) - MyBasePageForViews<TModel>
|
||||
DirectiveToken - (7:0,7 [7] InheritsWithViewImports.cshtml) - MyModel
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml)
|
||||
|MyModel|
|
||||
Generated Location: (752:19,0 [7] )
|
||||
|MyModel|
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InheritsWithViewImports.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "cf2e52e7d1326775fe4ece983a7f8ee1f62235a0"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml : MyBasePageForViews<MyModel>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<MyModel> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InheritsWithViewImports_cshtml - MyBasePageForViews<MyModel> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1 @@
|
|||
@inject MyApp MyPropertyName
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@model MyModel
|
||||
@inject MyApp MyPropertyName
|
||||
@inject MyService<TModel> Html
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml"
|
||||
MyModel __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml"
|
||||
MyApp __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml"
|
||||
global::System.Object MyPropertyName = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml"
|
||||
MyService<TModel> __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml"
|
||||
global::System.Object Html = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyService<MyModel> Html { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (7:0,7 [7] InjectWithModel.cshtml) - MyModel
|
||||
DirectiveToken - (24:1,8 [5] InjectWithModel.cshtml) - MyApp
|
||||
DirectiveToken - (30:1,14 [14] InjectWithModel.cshtml) - MyPropertyName
|
||||
DirectiveToken - (54:2,8 [17] InjectWithModel.cshtml) - MyService<TModel>
|
||||
DirectiveToken - (72:2,26 [4] InjectWithModel.cshtml) - Html
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|
||||
|MyModel|
|
||||
Generated Location: (766:19,0 [7] )
|
||||
|MyModel|
|
||||
|
||||
Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|
||||
|MyApp|
|
||||
Generated Location: (981:27,0 [5] )
|
||||
|MyApp|
|
||||
|
||||
Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|
||||
|MyPropertyName|
|
||||
Generated Location: (1216:35,22 [14] )
|
||||
|MyPropertyName|
|
||||
|
||||
Source Location: (54:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|
||||
|MyService<TModel>|
|
||||
Generated Location: (1422:43,0 [17] )
|
||||
|MyService<TModel>|
|
||||
|
||||
Source Location: (72:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml)
|
||||
|Html|
|
||||
Generated Location: (1669:51,22 [4] )
|
||||
|Html|
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithModel.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "a039b7091118c718dc3023b6ac58d9645cb58e59"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyService<MyModel> Html { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithModel_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
@model MyModel
|
||||
@inject MyApp MyPropertyName;
|
||||
@inject MyService<TModel> Html;
|
||||
@inject MyApp MyPropertyName2 ;
|
||||
@inject MyService<TModel> Html2 ;
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
MyModel __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
MyApp __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 2 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
global::System.Object MyPropertyName = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
MyService<TModel> __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
global::System.Object Html = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
MyApp __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 4 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
global::System.Object MyPropertyName2 = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
MyService<TModel> __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml"
|
||||
global::System.Object Html2 = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyService<MyModel> Html2 { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName2 { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyService<MyModel> Html { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (7:0,7 [7] InjectWithSemicolon.cshtml) - MyModel
|
||||
DirectiveToken - (24:1,8 [5] InjectWithSemicolon.cshtml) - MyApp
|
||||
DirectiveToken - (30:1,14 [14] InjectWithSemicolon.cshtml) - MyPropertyName
|
||||
DirectiveToken - (58:2,8 [17] InjectWithSemicolon.cshtml) - MyService<TModel>
|
||||
DirectiveToken - (76:2,26 [4] InjectWithSemicolon.cshtml) - Html
|
||||
DirectiveToken - (93:3,8 [5] InjectWithSemicolon.cshtml) - MyApp
|
||||
DirectiveToken - (99:3,14 [15] InjectWithSemicolon.cshtml) - MyPropertyName2
|
||||
DirectiveToken - (129:4,8 [17] InjectWithSemicolon.cshtml) - MyService<TModel>
|
||||
DirectiveToken - (147:4,26 [5] InjectWithSemicolon.cshtml) - Html2
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
Source Location: (7:0,7 [7] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyModel|
|
||||
Generated Location: (774:19,0 [7] )
|
||||
|MyModel|
|
||||
|
||||
Source Location: (24:1,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyApp|
|
||||
Generated Location: (993:27,0 [5] )
|
||||
|MyApp|
|
||||
|
||||
Source Location: (30:1,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyPropertyName|
|
||||
Generated Location: (1232:35,22 [14] )
|
||||
|MyPropertyName|
|
||||
|
||||
Source Location: (58:2,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyService<TModel>|
|
||||
Generated Location: (1442:43,0 [17] )
|
||||
|MyService<TModel>|
|
||||
|
||||
Source Location: (76:2,26 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|Html|
|
||||
Generated Location: (1693:51,22 [4] )
|
||||
|Html|
|
||||
|
||||
Source Location: (93:3,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyApp|
|
||||
Generated Location: (1893:59,0 [5] )
|
||||
|MyApp|
|
||||
|
||||
Source Location: (99:3,14 [15] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyPropertyName2|
|
||||
Generated Location: (2132:67,22 [15] )
|
||||
|MyPropertyName2|
|
||||
|
||||
Source Location: (129:4,8 [17] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|MyService<TModel>|
|
||||
Generated Location: (2343:75,0 [17] )
|
||||
|MyService<TModel>|
|
||||
|
||||
Source Location: (147:4,26 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml)
|
||||
|Html2|
|
||||
Generated Location: (2594:83,22 [5] )
|
||||
|Html2|
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InjectWithSemicolon.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5010aab35d235175dab517f8018e41aee9a2ac7f"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyService<MyModel> Html2 { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName2 { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyService<MyModel> Html { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InjectWithSemicolon_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<MyModel> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml"
|
||||
MyApp __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml"
|
||||
global::System.Object MyPropertyName = null;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (8:0,8 [5] Inject.cshtml) - MyApp
|
||||
DirectiveToken - (14:0,14 [14] Inject.cshtml) - MyPropertyName
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
Source Location: (8:0,8 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml)
|
||||
|MyApp|
|
||||
Generated Location: (748:19,0 [5] )
|
||||
|MyApp|
|
||||
|
||||
Source Location: (14:0,14 [14] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml)
|
||||
|MyPropertyName|
|
||||
Generated Location: (974:27,22 [14] )
|
||||
|MyPropertyName|
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/Inject.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "c711078454f5b0e8d2cb77d9cb7fa88cca32b884"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public MyApp MyPropertyName { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_Inject_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1 @@
|
|||
@namespace Test.
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1 @@
|
|||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ1007: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (10:0,10 [6] InvalidNamespaceAtEOF.cshtml)
|
||||
IntermediateToken - (10:0,10 [6] InvalidNamespaceAtEOF.cshtml) - Html - Test.
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "de132bd3e2a46a0d2ec953a168427c01e5829cde"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
BeginContext(10, 6, true);
|
||||
WriteLiteral(" Test.");
|
||||
EndContext();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1 @@
|
|||
TestFiles/IntegrationTests/CodeGenerationIntegrationTest/InvalidNamespaceAtEOF.cshtml(1,2): Error RZ9999: "namespace" is a reserved word and cannot be used in implicit expressions. An explicit expression ("@()") must be used.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_InvalidNamespaceAtEOF_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic> -
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(10, 6, true);
|
||||
HtmlContent - (10:0,10 [6] InvalidNamespaceAtEOF.cshtml)
|
||||
IntermediateToken - (10:0,10 [6] InvalidNamespaceAtEOF.cshtml) - Html - Test.
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1 @@
|
|||
@model System.Collections.IEnumerable
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
@model DateTime
|
||||
|
||||
@addTagHelper "InputTestTagHelper, AppCode"
|
||||
|
||||
<input-test for="Date" />
|
||||
<input-test for="@Model" />
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using TModel = global::System.Object;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<DateTime>
|
||||
{
|
||||
#line hidden
|
||||
#pragma warning disable 0649
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
|
||||
#pragma warning restore 0649
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
|
||||
private global::InputTestTagHelper __InputTestTagHelper;
|
||||
#pragma warning disable 219
|
||||
private void __RazorDirectiveTokenHelpers__() {
|
||||
((System.Action)(() => {
|
||||
#line 1 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml"
|
||||
DateTime __typeHelper = default;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
((System.Action)(() => {
|
||||
#line 3 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml"
|
||||
global::System.Object __typeHelper = "InputTestTagHelper, AppCode";
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
))();
|
||||
}
|
||||
#pragma warning restore 219
|
||||
#pragma warning disable 0414
|
||||
private static System.Object __o = null;
|
||||
#pragma warning restore 0414
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
__InputTestTagHelper = CreateTagHelper<global::InputTestTagHelper>();
|
||||
#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml"
|
||||
__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
__InputTestTagHelper = CreateTagHelper<global::InputTestTagHelper>();
|
||||
#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml"
|
||||
__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => Model);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<DateTime> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - - TModel = global::System.Object
|
||||
UsingDirective - (1:0,1 [12] ) - System
|
||||
UsingDirective - (16:1,1 [32] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [17] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [28] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [30] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [40] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [43] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<DateTime> -
|
||||
DefaultTagHelperRuntime -
|
||||
FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper
|
||||
DesignTimeDirective -
|
||||
DirectiveToken - (231:7,8 [62] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>
|
||||
DirectiveToken - (294:7,71 [4] ) - Html
|
||||
DirectiveToken - (308:8,8 [54] ) - global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper
|
||||
DirectiveToken - (363:8,63 [4] ) - Json
|
||||
DirectiveToken - (377:9,8 [53] ) - global::Microsoft.AspNetCore.Mvc.IViewComponentHelper
|
||||
DirectiveToken - (431:9,62 [9] ) - Component
|
||||
DirectiveToken - (450:10,8 [43] ) - global::Microsoft.AspNetCore.Mvc.IUrlHelper
|
||||
DirectiveToken - (494:10,52 [3] ) - Url
|
||||
DirectiveToken - (507:11,8 [70] ) - global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider
|
||||
DirectiveToken - (578:11,79 [23] ) - ModelExpressionProvider
|
||||
DirectiveToken - (617:12,14 [96] ) - Microsoft.AspNetCore.Mvc.Razor.TagHelpers.UrlResolutionTagHelper, Microsoft.AspNetCore.Mvc.Razor
|
||||
DirectiveToken - (7:0,7 [8] ModelExpressionTagHelper.cshtml) - DateTime
|
||||
DirectiveToken - (33:2,14 [29] ModelExpressionTagHelper.cshtml) - "InputTestTagHelper, AppCode"
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning disable 0414
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - private static System.Object __o = null;
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - #pragma warning restore 0414
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
HtmlContent - (17:1,0 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (17:1,0 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
HtmlContent - (62:2,43 [4] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (62:2,43 [4] ModelExpressionTagHelper.cshtml) - Html - \n\n
|
||||
TagHelper - (66:4,0 [25] ModelExpressionTagHelper.cshtml) - input-test - TagMode.SelfClosing
|
||||
DefaultTagHelperBody -
|
||||
DefaultTagHelperCreate - - InputTestTagHelper
|
||||
DefaultTagHelperProperty - (83:4,17 [4] ModelExpressionTagHelper.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes
|
||||
CSharpExpression -
|
||||
IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model =>
|
||||
IntermediateToken - - CSharp - __model.
|
||||
IntermediateToken - (83:4,17 [4] ModelExpressionTagHelper.cshtml) - CSharp - Date
|
||||
IntermediateToken - - CSharp - )
|
||||
DefaultTagHelperExecute -
|
||||
HtmlContent - (91:4,25 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (91:4,25 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
TagHelper - (93:5,0 [27] ModelExpressionTagHelper.cshtml) - input-test - TagMode.SelfClosing
|
||||
DefaultTagHelperBody -
|
||||
DefaultTagHelperCreate - - InputTestTagHelper
|
||||
DefaultTagHelperProperty - (110:5,17 [6] ModelExpressionTagHelper.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes
|
||||
CSharpExpression -
|
||||
IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model =>
|
||||
IntermediateToken - (111:5,18 [5] ModelExpressionTagHelper.cshtml) - CSharp - Model
|
||||
IntermediateToken - - CSharp - )
|
||||
DefaultTagHelperExecute -
|
||||
HtmlContent - (120:5,27 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (120:5,27 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Source Location: (7:0,7 [8] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|
||||
|DateTime|
|
||||
Generated Location: (1259:25,0 [8] )
|
||||
|DateTime|
|
||||
|
||||
Source Location: (33:2,14 [29] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|
||||
|"InputTestTagHelper, AppCode"|
|
||||
Generated Location: (1521:33,37 [29] )
|
||||
|"InputTestTagHelper, AppCode"|
|
||||
|
||||
Source Location: (83:4,17 [4] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|
||||
|Date|
|
||||
Generated Location: (2200:49,102 [4] )
|
||||
|Date|
|
||||
|
||||
Source Location: (111:5,18 [5] TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml)
|
||||
|Model|
|
||||
Generated Location: (2592:56,94 [5] )
|
||||
|Model|
|
||||
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
#pragma checksum "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "0906a816db301fe624bbe5a96c4b3013071ea492"
|
||||
// <auto-generated/>
|
||||
#pragma warning disable 1591
|
||||
namespace AspNetCore
|
||||
{
|
||||
#line hidden
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
public class TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<DateTime>
|
||||
{
|
||||
#line hidden
|
||||
#pragma warning disable 0169
|
||||
private string __tagHelperStringValueBuffer;
|
||||
#pragma warning restore 0169
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __backed__tagHelperScopeManager = null;
|
||||
private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __tagHelperScopeManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__backed__tagHelperScopeManager == null)
|
||||
{
|
||||
__backed__tagHelperScopeManager = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager(StartTagHelperWritingScope, EndTagHelperWritingScope);
|
||||
}
|
||||
return __backed__tagHelperScopeManager;
|
||||
}
|
||||
}
|
||||
private global::InputTestTagHelper __InputTestTagHelper;
|
||||
#pragma warning disable 1998
|
||||
public async override global::System.Threading.Tasks.Task ExecuteAsync()
|
||||
{
|
||||
BeginContext(17, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(64, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(66, 25, false);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => {
|
||||
}
|
||||
);
|
||||
__InputTestTagHelper = CreateTagHelper<global::InputTestTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__InputTestTagHelper);
|
||||
#line 5 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml"
|
||||
__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => __model.Date);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
__tagHelperExecutionContext.AddTagHelperAttribute("for", __InputTestTagHelper.For, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(91, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
BeginContext(93, 27, false);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input-test", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "test", async() => {
|
||||
}
|
||||
);
|
||||
__InputTestTagHelper = CreateTagHelper<global::InputTestTagHelper>();
|
||||
__tagHelperExecutionContext.Add(__InputTestTagHelper);
|
||||
#line 6 "TestFiles/IntegrationTests/CodeGenerationIntegrationTest/ModelExpressionTagHelper.cshtml"
|
||||
__InputTestTagHelper.For = ModelExpressionProvider.CreateModelExpression(ViewData, __model => Model);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
__tagHelperExecutionContext.AddTagHelperAttribute("for", __InputTestTagHelper.For, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
|
||||
await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
|
||||
if (!__tagHelperExecutionContext.Output.IsContentModified)
|
||||
{
|
||||
await __tagHelperExecutionContext.SetOutputContentAsync();
|
||||
}
|
||||
Write(__tagHelperExecutionContext.Output);
|
||||
__tagHelperExecutionContext = __tagHelperScopeManager.End();
|
||||
EndContext();
|
||||
BeginContext(120, 2, true);
|
||||
WriteLiteral("\r\n");
|
||||
EndContext();
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
|
||||
[global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
|
||||
public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<DateTime> Html { get; private set; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
Document -
|
||||
NamespaceDeclaration - - AspNetCore
|
||||
UsingDirective - (1:0,1 [14] ) - System
|
||||
UsingDirective - (16:1,1 [34] ) - System.Collections.Generic
|
||||
UsingDirective - (51:2,1 [19] ) - System.Linq
|
||||
UsingDirective - (71:3,1 [30] ) - System.Threading.Tasks
|
||||
UsingDirective - (102:4,1 [32] ) - Microsoft.AspNetCore.Mvc
|
||||
UsingDirective - (135:5,1 [42] ) - Microsoft.AspNetCore.Mvc.Rendering
|
||||
UsingDirective - (178:6,1 [45] ) - Microsoft.AspNetCore.Mvc.ViewFeatures
|
||||
ClassDeclaration - - public - TestFiles_IntegrationTests_CodeGenerationIntegrationTest_ModelExpressionTagHelper_cshtml - global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<DateTime> -
|
||||
DefaultTagHelperRuntime -
|
||||
FieldDeclaration - - private - global::InputTestTagHelper - __InputTestTagHelper
|
||||
MethodDeclaration - - public async override - global::System.Threading.Tasks.Task - ExecuteAsync
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(17, 2, true);
|
||||
HtmlContent - (17:1,0 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (17:1,0 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(64, 2, true);
|
||||
HtmlContent - (64:3,0 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (64:3,0 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(66, 25, false);
|
||||
TagHelper - (66:4,0 [25] ModelExpressionTagHelper.cshtml) - input-test - TagMode.SelfClosing
|
||||
DefaultTagHelperBody -
|
||||
DefaultTagHelperCreate - - InputTestTagHelper
|
||||
DefaultTagHelperProperty - (83:4,17 [4] ModelExpressionTagHelper.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes
|
||||
CSharpExpression -
|
||||
IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model =>
|
||||
IntermediateToken - - CSharp - __model.
|
||||
IntermediateToken - (83:4,17 [4] ModelExpressionTagHelper.cshtml) - CSharp - Date
|
||||
IntermediateToken - - CSharp - )
|
||||
DefaultTagHelperExecute -
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(91, 2, true);
|
||||
HtmlContent - (91:4,25 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (91:4,25 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(93, 27, false);
|
||||
TagHelper - (93:5,0 [27] ModelExpressionTagHelper.cshtml) - input-test - TagMode.SelfClosing
|
||||
DefaultTagHelperBody -
|
||||
DefaultTagHelperCreate - - InputTestTagHelper
|
||||
DefaultTagHelperProperty - (110:5,17 [6] ModelExpressionTagHelper.cshtml) - for - Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression InputTestTagHelper.For - HtmlAttributeValueStyle.DoubleQuotes
|
||||
CSharpExpression -
|
||||
IntermediateToken - - CSharp - ModelExpressionProvider.CreateModelExpression(ViewData, __model =>
|
||||
IntermediateToken - (111:5,18 [5] ModelExpressionTagHelper.cshtml) - CSharp - Model
|
||||
IntermediateToken - - CSharp - )
|
||||
DefaultTagHelperExecute -
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - BeginContext(120, 2, true);
|
||||
HtmlContent - (120:5,27 [2] ModelExpressionTagHelper.cshtml)
|
||||
IntermediateToken - (120:5,27 [2] ModelExpressionTagHelper.cshtml) - Html - \n
|
||||
CSharpCode -
|
||||
IntermediateToken - - CSharp - EndContext();
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Inject -
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue